Hidden Value not passing- basic noob

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
imstupid
Forum Commoner
Posts: 84
Joined: Fri Feb 18, 2005 1:24 pm

Hidden Value not passing- basic noob

Post 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.
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post 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.
imstupid
Forum Commoner
Posts: 84
Joined: Fri Feb 18, 2005 1:24 pm

Post by imstupid »

Awesomesauce! it works!
Sorry about the code posting without the tags. I just forgot.
Post Reply