Jump to content

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....

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.