Jump to content

Passing Values Through Html Forms


t12igger

Recommended Posts

I started PHP programming about a week ago.

 

I've been at this all night. For some reason I can't get the value to go through. This is what I have:

 

 

if (isset($_GET['updateid'])) {

 

echo '<form name="box" method="post" action="homework.php">

Name: <input type="text" name="updatename"><br>

Shout:<input type="text" size="150" name="updateshout"><br>

<input type="hidden" name="updateid" value="<?php echo $_GET[\'updateid\']; ?>">

 

<input type="submit" name="button" value="Submit">

 

</form>';

 

I am trying to get the set updateid to pass as a hidden value in my form so when I update my database, it can utilize the updateid to know which rows to update.

 

This line right here: <input type="hidden" name="updateid" value="<?php echo $_GET[\'updateid\']; ?> is not working properly, and I am not getting any error messages. What am I doing wrong?

Link to comment
https://forums.phpfreaks.com/topic/271188-passing-values-through-html-forms/
Share on other sites

This is a perfect example of when a heredoc statement should be used :

$form = <<<FORM_TXT
<form name="box" method="post" action="homework.php">
Name: <input type="text" name="updatename"><br>
Shout:<input type="text" size="150" name="updateshout"><br>
<input type="hidden" name="updateid" value="{$_GET['updateid']}">

<input type="submit" name="button" value="Submit">

</form>
FORM_TXT;
echo $form;

 

Another thing, you should probably be validating that $_GET['updateid'], or else people could just manualy enter any ID they wanted to change into the url and load the update form for that id....

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.