Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving issues in passing a variable to another page in PHP
    primarykey
    data
    text
    <pre><code>&lt;?php $hostname = "****"; //name of the server $username = "***"; //id of the user $password = "****"; //password of the user $db = "**"; //name of the database //connect to the database $conn = mysql_connect($hostname,$username,$password); if (!$conn) { die("Could not connect: " . mysql_error()); } //select the database $db_selected = mysql_select_db($db, $conn); if (!$db_selected) { die ("Can\"t use " . $db . mysql_error()); } echo "&lt;form action='Assign6next.php' method=\"post\"&gt;"; $sql= "SELECT * FROM Author"; //This selects all columns from author echo "Author List"; //Echo name echo "&lt;br&gt;"; $result= mysql_query($sql, $conn); //The result of the query in database echo '&lt;select name="AuthorName"&gt;&lt;OPTION&gt;';//Creates dropdown for Author dropdown echo "Select an Author&lt;/OPTION&gt;"; // echo "&lt;br&gt;"; while ($row = mysql_fetch_array($result)){ //While in the loop return results in row $last= $row["AuthorLast"]; //Create variable last for Last Names $first = $row["AuthorFirst"]; //Create variables for first Names echo "&lt;OPTION value=$last,$first&gt;$last,$first&lt;/OPTION&gt;"; } echo '&lt;/SELECT&gt;'; //End of drop down list echo "&lt;br&gt;"; echo "&lt;INPUT type='submit' value='Get Titles' name='submit'&gt;"; if (isset($_POST['submit'])) { //echo "button 1 has been pressed"; $auth = $_POST['AuthorName']; //echo $auth; //echo "&lt;br&gt;"; //$data = "foo:*:1023:1000::/home/foo:/bin/sh"; list($lastn, $firstn) = explode(",", $auth); echo "&lt;input type='hidden' name='lname' value=$lastn&gt;"; //echo "&lt;/INPUT&gt;"; //echo '&lt;input type="hidden" name="lname" value="'.$lastn.'"&gt;'; //echo '&lt;input type="hidden" name="lname" value="' . htmlspecialchars($lastn) . '"&gt;'; //$_COOKIE['lname'] = $lastn; //echo $lastn; //echo "&lt;br&gt;";// foo //echo $firstn; // * } echo "&lt;/form&gt;"; /////// //close the connection to MySQL mysql_close($conn); ?&gt; </code></pre> <p>here in the above code I have lastname string in $lastn and passing this as hidden variable to another page.</p> <pre><code>&lt;?php $lastn = $_POST['lname']; echo $lastn; echo "string"; ?&gt; </code></pre> <p>I'm trying to catch the hidden variable using above code but only "string" is getting displayed but not the last name which i'm getting from previous page.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload