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']} ?>' /> <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.
Hidden Value not passing- basic noob
Moderator: General Moderators
- evilmonkey
- Forum Regular
- Posts: 823
- Joined: Sun Oct 06, 2002 1:24 pm
- Location: Toronto, Canada
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:
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:
Read the "Posting code in the forums" topic too please.
Code: Select all
echo "e;<form method='post' action='page2.php'><input name='eventnamemodify' type='hidden' value='{$rowї'eventname']}' /> <input type='submit' name='submit' value='modify' /></form>"e;;Code: Select all
echo "e;<form method=\"e;post\"e; action=\"e;page2.php\"e;><input name=\"e;eventnamemodify\"e; type=\"e;hidden\"e; value=\"e;{$rowї'eventname']}\"e; /> <input type=\"e;submit\"e; name=\"e;submit\"e; value=\"e;modify\"e; /></form>"e;;