PHP - Disappearing Link When Adding A New One
Hey guys, Been working on a project but only recently started using php.
What happens is.... I have a general quiz split accross a multipage form and then a results section. The problem is, is that when it comes to if statements on the last page and deciding the difficulty level for the users quiz, it wont let me add the 3rd and final link. Here is the code to explain. I have put bits in bold and a comment. (at the bottom section) I've tried everything, Thanks for any help in advance guys. Code: [Select] <?php session_start(); $_SESSION['q11'] = $_POST['q11']; $_SESSION['q12'] = $_POST['q12']; $_SESSION['q13'] = $_POST['q13']; $_SESSION['q14'] = $_POST['q14']; $_SESSION['q15'] = $_POST['q15']; $protectscore = 0; //initialize score to zero $detectscore = 0; $resolvescore = 0; $overallScore = 0; ?> <html> <head> <title>Results</title> <h1>Protection Section</h1> <p><b>Question 1</b> <?php if ($_SESSION['q1'] == "1"){ echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 2</b> <?php if ($_SESSION['q2'] == "2") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 3</b> <?php if ($_SESSION['q3'] == "3") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 4</b> <?php if ($_SESSION['q4'] == "1") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 5</b> <?php if ($_SESSION['q5'] == "2") { echo("<b>Correct</b>"); $protectscore = $protectscore +1; }else{ echo("<b>Incorrect</b>"); } ?> <h1>Detection Section</h1> <b>Question 1</b> <?php if ($_SESSION['q6'] == "3") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 2</b> <?php if ($_SESSION['q7'] == "3") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 3</b> <?php if ($_SESSION['q8'] == "1") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR><b>Question 4</b> <?php if ($_SESSION['q9'] == "2") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR><b>Question 5</b> <?php if ($_SESSION['q10'] == "1") { echo("<b>Correct</b>"); $detectscore = $detectscore +1; }else{ echo("<b>Incorrect</b>"); } ?> <h1>Resolve Section</h1> <b>Question 1</b> <?php if ($_SESSION['q11'] == "2") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 2</b> <?php if ($_SESSION['q12'] == "1") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><b><BR>Question 3</b> <?php if ($_SESSION['q13'] == "3") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR><b>Question 4</b> <?php if ($_SESSION['q14'] == "3") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?><BR> <b>Question 5</b> <?php if ($_SESSION['q15'] == "1") { echo("<b>Correct</b>"); $resolvescore = $resolvescore +1; }else{ echo("<b>Incorrect</b>"); } ?> </p> <hr> <b>Total Sco </b>You answered <?php echo ($protectscore + $detectscore + $resolvescore); ?> question<?php if ($overallScore != 1) { echo("s"); } ?> Correctly <?php $qs = '15'; $overallScore = $protectscore + $detectscore + $resolvescore; $overallPercent = number_format(($overallScore * 100) / $qs); $ProtectionPercent = number_format(($protectscore * 100) / 5); $DetectionPercent = number_format(($detectscore * 100) / 5); $ResolvingPercent = number_format(($resolvescore * 100) / 5); ?><BR> <strong>Total Percentage is:</strong> <?php echo $overallPercent?> % <BR> Your Percentage From Protection Section is: <?php echo $ProtectionPercent?> % <BR> Your Percentage From Detection Section is: <?php echo $DetectionPercent?> %<BR> Your Percentage From Resolving Section is: <?php echo $ResolvingPercent?> %<BR> <HR> This section adds the link perfectly fine <?php if ($ProtectionPercent <= 30){ // beg echo '<li><a href="http://www.google.com> View Personalised Protection Content</a>'; } elseif ($ProtectionPercent > 30 && $ProtectionPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Protection Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Protection Content</a>'; } ?><BR> <HR> This link add fine, however when i add the resolving if statement. This link disappear here and the Resolving section just doesnt appear <?php if ($DetectionPercent <= 30){ // beg echo '<li><a href="http://www.google.com> View Personalised Detection Content</a>'; } elseif ($DetectionPercent > 30 && $DetectionPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Detection Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Detection Content</a>'; } When this part is added, this is when the error occurs <?php if ($ResolvingPercent <= 30){ // beg echo '<li><a href="http://www.google.com> View Personalised Resolving Content</a>'; } elseif ($ResolvingPercent > 30 && $ResolvingPercent <= 60){ //int echo '<li><a href="http://www.youtube.com"> View Personalised Resolving Content</a>'; } else //exp { echo '<li><a href="http://www.facebook.com">View Personalised Resolving Content</a>'; } ?> ?> MOD EDIT: [code] . . . [/code] tags added. Similar TutorialsHey Guys, I'm querying a database that is going to return a html page. In this page I'm going to define content areas with a class. eg: <div class="category"></div> Anywhere I have this class in the html code, I want to dynamically insert a link into it. So when I retrieve the code from the database, I need the code to check for this tag (class="category") and add a standard link (<a href="..">Add new Category</a>) Not 100% sure whats the most efficient way to go about this. i have a database field called photo. it is used to generate photo id in a software progam for our soccer league. I also want to be able to view the photo on our approval page. could someone help me with the coding of the http h-link? i am having issues with it. the photo field has the following paramaters: images/picture.jpg i want the link on the approval page to look like this: <a href="http://bccsl.org/managers/images/picture.jpg">"http://bccsl.org/managers/images/picture.jpg</a> thanks stefan Code: [Select] <?php /* connection and protection */ include 'dbc.php'; page_protect(); mysql_query( "SET NAMES utf8" ); if(isset($_POST["update"]) AND isset($_POST["hiddenid"])) { $updated=false; $activateapproved=array(); $deactivateapproved=array(); foreach($_POST["hiddenid"] AS $value) { if(isset($_POST["checkboxapproved"][$value])) $activateapproved[]=intval($value); else $deactivateapproved[]=intval($value); } if(count($activateapproved)>0) { $SQL=sprintf("UPDATE players SET approved=1 WHERE id in (%s)" , implode(",", $activateapproved)); mysql_query($SQL) OR DIE(mysql_error()); $updated=true; } if(count($deactivateapproved)>0) { $SQL=sprintf("UPDATE players SET approved=0 WHERE id in (%s)" , implode(",", $deactivateapproved)); mysql_query($SQL) OR DIE(mysql_error()); $updated=true; } if($updated==true) { header("Location: ".$_SERVER["PHP_SELF"].""); exit(); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Player Approval</title> <script type="text/javascript" src="public_smo_scripts.js"></script> <link href="styles.css" rel="stylesheet" type="text/css"> </head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="5" class="main"> <tr> <td colspan="3"> </td> </tr> <tr> <td width="160" valign="top"> <? include 'menu.php'; ?> <p> </p> <p> </p> <p> </p> <p> </p></td> <td width="732" valign="top"><p> </p> <?php if(isset($_GET["todo"]) AND $_GET["todo"]=="updated") { echo "Updated succesfully"; } ?> <form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" name="Form"> <table border="1" cellpadding="2" cellspacing="2"> <tr> <td><div align="center">First</div></td> <td><div align="center">Last</div></td> <td><div align="center">Address</div></td> <td><div align="center">City</div></td> <td><div align="center">Postal</div></td> <td><div align="center">Phone #</div></td> <td><div align="center">Feet</div></td> <td><div align="center">Inches</div></td> <td><div align="center">Weight</div></td> <td><div align="center">Birthdate</div></td> <td><div align="center">Team ID</div></td> <td><div align="center">Type</div></td> <td><div align="center">photo</div></td> <td><div align="center">Date Added</div></td> <td><div align="center">Approved</div></td> </tr> <?php $sql="select * from players where teamid='$_POST[teamid]' order by status ASC"; $res=mysql_query($sql) or die(mysql_error()); while($r=mysql_fetch_assoc($res)) { ?> <tr> <input type="hidden" name="hiddenid[]" value="<?php echo $r["id"]?>"> <td> <div align="center"><?php echo empty($r["first"])?' ':htmlspecialchars($r["first"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["last"])?' ':htmlspecialchars($r["last"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["address"])?' ':htmlspecialchars($r["address"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["city"])?' ':htmlspecialchars($r["city"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["postal"])?' ':htmlspecialchars($r["postal"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["phone"])?' ':htmlspecialchars($r["phone"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["feet"])?' ':htmlspecialchars($r["feet"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["inches"])?' ':htmlspecialchars($r["inches"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["weight"])?' ':htmlspecialchars($r["weight"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["birth"])?' ':htmlspecialchars($r["birth"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["teamid"])?' ':htmlspecialchars($r["teamid"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["status"])?' ':htmlspecialchars($r["status"]); ?> </div></td> <td> <div align="center"><?php echo empty($r["photo"])?'<a href="http://bccsl.org/managers/:htmlspecialchars($r["photo"])</a>'; ?> </div></td> <td> <div align="center"><?php echo empty($r["dateadded"])?' ':htmlspecialchars($r["dateadded"]); ?> </div></td> <td> <div align="center"> <input type="checkbox" name="checkboxapproved[<?php echo $r["id"]?>]" value="1"<?php echo empty($r["approved"])?'':' checked="checked"'; ?> /> </div></td> </tr> <?php } ?> </table> <p> <input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/> select/unselect <input type="submit" value="update" name="update"> </p> </form> <table width="178" border="1" cellpadding="0" cellspacing="1"> <tr> <th colspan="2" scope="col">Type</th> </tr> <tr> <td width="113"><div align="center">Church Player</div></td> <td width="50"><div align="center">1</div></td> </tr> <tr> <td><div align="center">Import Player</div></td> <td><div align="center">2</div></td> </tr> <tr> <td><div align="center">Witness Player</div></td> <td><div align="center">3</div></td> </tr> </table> </td> <td width="196" valign="top"> </td> </tr> <tr> <td colspan="3"> </td> </tr> </table> </body> </html> <a href="http://bccsl.org/managers/">http://bccsl.org/managers/</a> Is it possible to add more then one thing in a link? so i can $_GET more then one thing from a link signup.php?state=1?name=sam i tried that and a few other things and it didnt work. I have been becoming more and more familiar with PHP over the past few months, but this problem stumps me. How can I take a string of words separated by spaces taken from an XML feed (example: word1 word2 word3 word4) and turn it into something like this: <a href="word1">word1</a> <a href="word2">word2</a> ... and so on. This has to be done on the fly, since it is taking the words from the XML feed, they change depending on the page. I want them to be in a vertical column, and be able to link each one to the search page for that word, so each link has to be different. An even more in-depth problem, how can I sort it then so that there are multiple columns if necessary, say one page only has 3 words, but another has 50. How can I split them up into multiple vertical columns, say with 10 words in each? Have I confused anyone yet? I'm trying to add a link to edit my results. Not sure the best way to create the link, nothing I've tried works. There's probably a better way than what I've tried: echo 'There were ', mysql_num_rows($result), ' Matching Photographers:'; while ($row = mysql_fetch_array($result)) { echo "<br />Photographer Info:<br />"; echo "Photographer Name: $row[name]<br />"; echo "Photographer Email: $row[email]<br />"; echo "Photographer ID: $row[PHOTOGRAPHERID]<br />"; echo "Photographer Company: $row[c_name]<br />"; echo "Edit Photographer <a href="update.php?id=' . $row[PHOTOGRAPHERID] . '">Here</a>"; } I have an 'I agree' button on this page https://www.setstuffrentals.com/credit-card-authorization/
I basically need the button to redirect to another web page after a customer hits 'I agree'. I don't know PHP much. Can someone help step by step, please? I am sending emails using PHPMailer. My configuration is below.
When adding a link to the message, should I use anchor tags? Both seem to work. What is the implication to recipients who are not using HTML email?
On a side note, if anything below seems wrong, please let me know.
Thanks
$msg='<p>Hello</p><p>Link: http://phpmailer.worxware.com/</p><p>Link: http://phpmailer.worxware.com</p><a href="http://phpmailer.worxware.com">http://phpmailer.worxware.com</a>'; $mail = new myPHPMailer(true); $mail->AddReplyTo('myEmail@xxx.com', 'Michael Reed'); $mail->SetFrom('myEmail@xxx.com', 'Michael Reed'); $mail->AddAddress('johndoe@xxx.com', 'John Doe'); $mail->Subject = "Here is your email"; //AltBody property need not be sent since PHPMailer will create an alternate automatically $mail->MsgHTML($message); return ($mail->Send()); class myPHPMailer extends PHPMailer { public function __construct($allow_exceptions=false){ $this->isSMTP(); $this->SMTPDebug = 0; $this->Host = "smtp.gmail.com"; $this->Port = 587; $this->SMTPSecure='tls'; // sets the prefix to the server. Used for gmail only. $this->SMTPAuth = true; $this->Username = 'xxx'; $this->Password = 'xxx'; } } Hi,
I am using fancybox on my site and the function I am using to display the title and data-caption is this.
$(document).ready(function() { $('.fancybox').fancybox({ beforeShow : function(){ this.title = this.title +"<br>" + $(this.element).data("caption"); } }); }); // readyI would like to change this so that I can add a hypertext link. Here is what a sample of the HTML looks like: <img src="img/portfolio/GSI_web.png" height="194" width="400" alt="Globalsoftwareinc.com" /> <h4>www.globalsoftwareinc.com</h4> <div class="portfolio-desc align-center"> <div class="folio-info"> <h5><a title="globalsoftwareinc.com" href="#" title="www.globalsoftwareinc.com">Globalsoftwareinc.com</a></h5> <a title="Global Software Inc. website" href="img/portfolio/GSI_web_large.png" class="fancybox" data-caption="I was the interactive web designer at Global Software, Inc. and assisted in the re-design and development of Global Software, Inc. in Drupal<br>www.globalsoftwareinc.com"><i class="fa fa-plus fa-2x"></i></a> </div> </div> </div> </article>so for example I would want to make www.globalsoftwareinc a hyperlink and that isn't do-able currently. It breaks the code. thanks in advance! Hi, I am adding "active_filter", "passive_filter" classes to links based on regex pattern coming from the URL: Line 46: https://github.com/laanes/product_filtering/blob/master/APF_URL.php The function gets called on line 89 in he https://github.com/laanes/product_filtering/blob/master/boxes/advanced_product_filtering_box.inc.php You can see it in action he http://www.swanseatimber.co.uk/shop/hafele/brand_281.html by clicking on a category on the left, under the heading "Filter Your Results". The clicked category gets a green background because of the added "active_filter" class. When you click again, it will get "passive_filter" class and the products are not filtered any more. The problem: When moving to other pages by using the pagination at the top of the product results, the class doesn't get added. Therefore, you can't remove the filter because function creating the href on line 72 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php and the function clearing all filters on line 100 in he https://github.com/laanes/product_filtering/blob/master/APF_URL.php both fail. What's interesting - when selecting a filter, moving to the next page, clicking in the browser url bar and hiting enter(hard reload i think?), the problem disappears and you can play with the filters again. I really hope you find a minute to look into it and help me. Hi, I've read a lot of places that it's not recommended to store binary files in my db. So instead I'm supposed to upload the image to a directory, and store the link to that directory in database. First, how would I make a form that uploads the picture to the directory (And what kinda directories are we talking?). Secondly, how would I retrieve that link? And I guess I should rename the picture.. I'd appreciate any help, or a good tutorial (Haven't found any myself). i have this login in system the login page is in a folder called login with a couple other files related to a login system. when a user logs in the php creates several cookies and is suppose to redirect to another page which is in a separate folder. on the page you are suppose to get redirected to, it calls a file that checks to see if the user is loged on by checking some cookies against the database but the cookies aren't their anymore even though they were set. here is the login script Code: [Select] <?php require('database.php'); //Include DB connection information if (isset($_POST['login'])) { //Execute the following if form is submitted $ip = mysql_real_escape_string($_SERVER["REMOTE_ADDR"]); //Geet user's IP Address $email = mysql_real_escape_string($_POST['email']); //Post email from form $password = mysql_real_escape_string(sha1(md5($_POST['pass']))); //Post password from form and encrypt if (empty($email) || empty($password)) { //Check for empty fields die("<b>Error:</b> All fields are required to be filled in."); } $check = mysql_query("SELECT * FROM users WHERE email = '$email'") or die(mysql_error()); $check2 = mysql_num_rows($check); if ($check2 == 0) { //Check if account exists die("<b>Error:</b> Email and password do not match the database."); } $row = mysql_fetch_array($check); $key = $row['key']; $ppas = $password . $key; $db_password = $row['password']; if ($ppas != $db_password) { //Check if password is correct die("<b>Error:</b> Email and password do not match the database."); } $allowed = $row['pp']; if ($allowed != 1) { //Check if they have permission die("<b>Error:</b> You do not have permission to view this section."); } function randomstring($length = 10) { $validCharacters = "abcdefghijklmnopqrstuxyvwz1234567890"; $validCharNumber = strlen($validCharacters); $result = ""; for ($i = 0; $i < $length; $i++) { $index = mt_rand(0, $validCharNumber - 1); $result .= $validCharacters[$index]; } return $result; } $session = randomstring(); $pas = $password . $key; mysql_query("UPDATE users SET session_id='$session' WHERE email='$email' AND password='$pas' ") or die(mysql_error()); //Add session ID to DB mysql_query("UPDATE users SET login_ip='$ip' WHERE email='$email' AND password='$pas'") or die(mysql_error()); //Add login IP to DB $level = $row['accounttype']; $pp = $row['pp']; $fs = $row['fs']; $fam = $row['fam']; $fname = $row['firstname']; $gbsa = $row['gbsa']; $future = time() + 1209600; setcookie("uemail", $email, $future); //Set cookie containing username setcookie("sessionid", $session, $future); //Set cookie containging session ID setcookie("acounttype", $level, $future); setcookie("pp", $pp, $future); setcookie("fs", $fs, $future); setcookie("fam", $fam, $future); setcookie("gbsa", $gbsa, $future); setcookie("name", $fname, $future); ////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////// $page = mysql_real_escape_string($_GET['page']); if ($page == 1){ header("Location: ../pinkpanthers/index.php"); //Redirect to members page }else{ header("Location: ../main.php"); } }else { //If form is not submitted display the form echo<<<login <center> <h1>Log In </h1> <h2>Or GO <a href="../main.php">Home</a></h2> <form method="post" action=""> Email: <input type="text" name="email"><br> Password: <input type="password" name="pass"><br> <input type="submit" name="login" value="Login"><br><br> </form></center> login; } ?> and here is the check login page Code: [Select] <?php require('../login/database.php'); //Include DB connection information $ip = mysql_real_escape_string($_SERVER["REMOTE_ADDR"]); //Get user's IP Address $email = mysql_real_escape_string($_COOKIE['uemail']); //Get username stored in cookie $pp = mysql_real_escape_string($_COOKIE['pp']); if ($pp == 1){ $sessionid = mysql_real_escape_string($_COOKIE['sessionid']); //Get user's session ID $query = "SELECT * FROM `users` WHERE `email` = '$email' AND `session_id` = '$sessionid' AND `login_ip` = '$ip' AND `pp` = '1' "; $check = mysql_query($query) or die(mysql_error()); //Check if all information provided from the user is valid by checking in the DB $answer = mysql_num_rows($check); //Return number of results found. Equal to 0 if not logged in or 1 if logged in. if ($answer == 0 || $sessionid == '') { //Check if login is valid. If not redirect user to login page header('Location: ../login/login.php?page=1'); exit(); } $row = mysql_fetch_array($check); $email = stripslashes($row['email']); }else{ header('Location: ../login/login.php?page=1'); } ?> I've been trying to pass a cookie along to one of my sub domains, and the I'm getting an error: An error #2 occurred in script 'C:\xampp\htdocs\optifit-hcg\application\controllers\test.php' on line 66: file_get_contents(http://localhost.optifit-hcg/horz_text_menu) [function.file-get-contents]: failed to open stream: HTTP request failed! The idea is that the script on the sub domain would return some data based on the cookie contents, but when I print_r() both $_SESSION and $_COOKIE the arrays are blank. Please let me know if you see anything wrong: Code: [Select] $opts['http']['method'] = 'GET'; $opts['http']['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $cookie_string = 'Cookie: '; // If there are cookies, send them with the request if( count( $_COOKIE ) > 0 ) { $i = 1; foreach( $_COOKIE as $k => $v ) { if( $i !== 1 ) { $cookie_string .= '; '; } $cookie_string .= $k . '=' . urlencode( $v ); $i++; } // Development environment not compiled with curl wrappers if( ENVIRONMENT != 'development' ) { $opts['http']['header'][] = $cookie_string; } else { $opts['http']['header'] = $cookie_string; } } $context = stream_context_create( $opts ); $contents = file_get_contents( 'http://localhost.optifit-hcg/horz_text_menu', FALSE, $context ); echo $contents; I've been using clean URLs and it's been giving my PHP sessions for my user system some trouble. I display the logged in users username on every page via a header.php file that I require on every page. Sometimes when I click a link to navigate to a page with a clean URL, the session information "disappears" and asks the user to login but if I navigate to another page from the clean url that the session "disappeared" on, the logged in users username is displayed at the top of the page like normal. Any idea certain pages cause the session to "disappear"
Header.php where the user info is displayed. $_SESSION['username'] is set on the login page <? session_start(); if (isset($_SESSION['username'])) { echo "Welcome back, " . $_SESSION['username']; } ?> Edited June 13, 2020 by Nematode128 Hi All, I'm quite new to this PHP stuff and have been creating a site just for the hell of it really but i have a rather bizarre problem that has been driving me nuts for about a week... I have two drops downs, the first gives a list of teams from a mysql table and then this populates the next drop down with a list of players from the selected team.. so far so good. When I hit the select/submit button to select the player, what should happen is both the "team" and "player" are put into another query which gives the stats on the selected player for all the games that he has played in. however, what actually happens in the Session variable sets the "team" variable to blank. I can see this happening when I use Print_r ($_SESSION); So essentially when I click on either submit button from my drop down forms the other value is being removed from the Session array. Oh, the session is still valid (not being destroyed and replaced with another session). First drop down $query_teams="select Team from $teams"; $team_result=mysql_query($query_teams); $num_team=mysql_numrows($team_result); echo $num_team; print_r ($row_team); $team_count = 0; echo '<form method="post" action="map_selector.php">'; echo "<SELECT name='country'>"; while ($row_team1 = mysql_fetch_assoc($team_result)) { $team_info = $row_team1["Team"]; echo "<OPTION value='$team_info'>$team_info </option>"; } echo '</select>'; echo '<center><input type="submit" value="Search"></center>'; $country = $_POST["country"]; $_SESSION["country"] = $country; echo '</form>'; So SCOTLAND is selected Some sql queries to get the results for the possible players and then Drop down 2 $row_full = array_unique($row_home); echo '<form method="post" action="map_selector.php">'; echo "<SELECT name='Player'>"; foreach ($row_full as $key => $value) { echo "<OPTION value='$value'> $value"; } echo '</select>'; echo "@"; echo $country; echo "@"; echo '<center><input type="submit" value="Search"></center>'; $country=$_POST["country"]; $player=$_POST["Player"]; echo "#"; echo $country; echo "#"; echo '</form>'; $_SESSION["Player"] = $player; $selected_player = $_SESSION["Player"]; echo $player; echo $selected_player; echo $country; Print_r ($_SESSION); so Print_r ($_Session) returns: Array ( [Player] => [country] => Scotland [] => ) then a player "Paul Hartley" is selected from the player list and submit is click and then Print_r($_Session) shows: Array ( [Player] => Paul Hartley [country] => [] => ) Can anyone please help... I just can;t understand why this is happening when I'm using a Sessions which, I thought, would retain all variable values until a time-out or a destroy Thanks nhsal69 Hi I've got this database I created with fields ProductId ProductName Image I've managed to get it to list the ID,productname, and Image urls in a list. My next step is to have the image field actually display an image and make it clickable: heres what I've done so far: Code: [Select] <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("productfeed", $con); $result = mysql_query("SELECT * FROM productfeeds"); echo "<table border='0'> <tr> <th>Firstname</th> <th>Lastname</th> <th>Image</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; echo "<td>" . $row['ImageURL'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Heres what I want to do: Code: [Select] while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['ProductID'] . "</td>"; echo "<td>" . $row['ProductName'] . "</td>"; // my changes beneath echo "<td>" . <a href="<?php echo $row['ImageURL'];?>"> <img src="<?php echo $row['LinkURL']; ?>"> </a>. "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> Can you guys point me in the right direction? Many thanks Hello.
I have a bit of a problem. When I fetch the link field from the database.i don't see an actual link on the page.
One more thing, what type of field should I use to store the link in the database? Probably there is where I went wrong.
All help is
Hi Support, I have a form, where it collects user description input. I can collect the inputs and store it with newline. The issue is - how to collect the http link to actual hyperlink ref during display. The following is my code: <textarea name="description" cols="50" rows="10" id="description"><?php echo str_replace("<br>", "\n", $description);?></textarea></td> For example, User input: Hi, Check it out - http://www.google.com/ I would like to display google link as href so that Viewers can click the link and go to the page. Right now, it is not href and user need to copy the link to new tabs or pages and then it can come. Thanks for your help. Regards, Ahsan hi hope you all are fine. i have been working on a Email Form (like user fills up the form which send the information to our email) but i was having problem with (URL field i created) link of form is (http://services.shadowaura.com/allquotations/static.php) field which is not working is "Inspirational Website:" when i submit the form it says (Forbidden You don't have permission to access /allquotations/staticworking.php on this server. Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.) Can some one help me out ????????????? code behind this form is: Code: [Select] <?php /* Email Variables */ $emailSubject = 'Shadow Aura Contact Info!'; $webMaster = '*****@shadowaura.com'; /* Data Variables */ $Name = $_POST['Name']; $email = $_POST['email']; $Cell = $_POST['Cell']; $Phone = $_POST['Phone']; $CompanyName = $_POST['CompanyName']; $TypeOfBusiness = $_POST['TypeOfBusiness']; $Address = $_POST['Address']; $YourBudget = $_POST['YourBudget']; $HaveDomain = $_POST['HaveDomain']; $RunningWeb = $_POST['RunningWeb']; $WebLink = $_POST['WebLink']; $Inspiration1 = $_POST['Inspiration1']; $Inspiration2 = $_POST['Inspiration2']; $NumberPages = $_POST['NumberPages']; $UseFlash = $_POST['UseFlash']; $TimeFrame = $_POST['TimeFrame']; $Provided = $_POST['Provided']; $Comments = $_POST['Comments']; $body = <<<EOD <h1> Static Website Quotation </h1> <br> <b>Name of Client:</b>$Name<br> <b>Your Email:</b>$email<br> <b>Cell Number:</b>$Cell<br> <b>Line Phone Number:</b>$Phone<br> <b>Company Name:</b>$CompanyName<br> <b>Type of Business:</b>$TypeOfBusiness<br> <b>Address:</b>$Address<br> <b>Your Budget:</b>$YourBudget <br> <b>Do you have Domain:</b>$HaveDomain<br> <b>Your Site is Running:</b>$RunningWeb <br> <b>Website Link:</b><a href="$WebLink">$WebLink</a><br> <b>Inspiration:</b>$Inspiration1<br> <b>2nd Inspiration:</b>$Inspiration2<br> <b>Number of Pages:</b>$NumberPages<br> <b>Use Flash:</b>$UseFlash <br> <b>Time Frame:</b>$TimeFrame<br> <b>You will provide:</b>$Provided<br> <b>Comments:</b>$Comments<br> EOD; $headers = "From: $email\r\n"; $headers .= "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<<EOD <html> <head> <title>sent message</title> <meta http-equiv="refresh" content="3;URL=http://services.shadowaura.com/"> <style type="text/css"> <!-- body { background-color: #8CC640; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; font-style: normal; line-height: normal; font-weight: normal; color: #fec001; text-decoration: none; padding-top: 200px; margin-left: 150px; width: 800px; } --> </style> </head> <div align="center">Your email will be answered soon as possible! You will return to <b>Shadow Aura Services</b> in a few seconds !</div> </div> </body> </html> EOD; echo "$theResults"; ?> here's my code that i've used to send an email. Code: [Select] $link = "<a href=\"http://www.example.com/" . $num . "\">" . $num . "</a>"; $query = "SELECT content FROM emails"; $result = mysql_query($query) or die(); $email_content = mysql_result($result, 0); $email = sprintf($email_content, $first, $name, $from, $link, $record, $rec, $inc, $max); $email_body = stripslashes(htmlentities($email, ENT_QUOTES, 'UTF-8')); // this is sent to another php script via post.... $subject = $_POST['subject']; $message = nl2br(html_entity_decode($_POST['email_body'])); $to = "me@whatever.com"; $charset='UTF-8'; $encoded_subject="=?$charset?B?" . base64_encode($subject) . "?=\n"; $headers="From: " . $userEmail . "\n" . "Content-Type: text/html; charset=$charset; format=flowed\n" . "MIME-Version: 1.0\n" . "Content-Transfer-Encoding: 8bit\n" . "X-Mailer: PHP\n"; mail($to,$encoded_subject,$message,$headers); in the db, emails.content is of the text type and contains several lines of text with %4$s which inserts the value of $link into the body. when the email arrives, there is a link and it appears fine, with the value of $num hyperlinked. however when you click on it it doesn't go anywhere. when copying the link location from the email it gives me x-msg://87/%22http://www.example.com/16 what is x-msg? how can i get this to work properly? Hi guys, I'm using a twitter script that grabs the title and publishings it like so: "Title - Read More at..." I was wondering how i would be able to post the direct link into twitter.. like news.php?id=1 for example. Code: [Select] $tweet->post('statuses/update', array('status' => ''.$_POST[title].' - more at MY URL')); This part is in the script to publish automatically when the users adds to the news database. How am i able to get the ID just after the posting of the news? Thanks! |