Page 1 of 1

Hidden Value not passing- basic noob

Posted: Wed Jul 13, 2005 10:58 am
by imstupid
hello everyone-
this seems like an easy problem, however I couldn't find a solution when doing any searches, so I apologize for repeating if this has been answered before. Basically, I am putting mysql data into a table, then trying to pass a value in a hidden field from one php file to another, and it's not going through. Here's page one's code (I cut out a lot obviously):

<?PHP
$result = mysql_query("SELECT * FROM eventtable")
or die(mysql_error());

while($row = mysql_fetch_array( $result )) {

echo "<tr><td>";
echo $row['eventname'];
echo "</td><td>";
echo "<br>" ;
echo "<form method='post' action='page2.php'><input name='eventnamemodify' type='hidden' value='<?PHP echo {$row['eventname']} ?>' />&nbsp;&nbsp;<input type='submit' name='submit' value='modify' /></form>";
echo "<br>" ;
echo "</td></tr>";
?>

-----
AND HERE IS PAGE2'S CODE


<?PHP

$eventnamemodify = $_REQUEST['eventnamemodify'] ;

echo $eventnamemodify ;

?>

and nothing prints out.

Thanks for the help in advance.

Posted: Wed Jul 13, 2005 11:09 am
by evilmonkey
You have a few problems with that code snippet, most obvious being the fact that you don't need to open your <?php tag again. Your line should look like this:

Code: Select all

echo &quote;<form method='post' action='page2.php'><input name='eventnamemodify' type='hidden' value='{$row&#1111;'eventname']}' />&nbsp;&nbsp;<input type='submit' name='submit' value='modify' /></form>&quote;;
Also, where do you connect to your database? Make sure that you're connected to the mysql server before running the mysql_query() command. Also (I'm not sure), but I think HTML needs double quotes as opposed to single quotes. If the line I gave you fails, try this:

Code: Select all

echo &quote;<form method=\&quote;post\&quote; action=\&quote;page2.php\&quote;><input name=\&quote;eventnamemodify\&quote; type=\&quote;hidden\&quote; value=\&quote;{$row&#1111;'eventname']}\&quote; />&nbsp;&nbsp;<input type=\&quote;submit\&quote; name=\&quote;submit\&quote; value=\&quote;modify\&quote; /></form>&quote;;
Read the "Posting code in the forums" topic too please.

Posted: Wed Jul 13, 2005 11:39 am
by imstupid
Awesomesauce! it works!
Sorry about the code posting without the tags. I just forgot.