t12igger Posted November 26, 2012 Share Posted November 26, 2012 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 More sharing options...
Muddy_Funster Posted November 26, 2012 Share Posted November 26, 2012 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.... Link to comment https://forums.phpfreaks.com/topic/271188-passing-values-through-html-forms/#findComment-1395136 Share on other sites More sharing options...
t12igger Posted November 26, 2012 Author Share Posted November 26, 2012 Thank you so much. That worked beautifully. And i learned something new and useful. I appreciate all your help. Link to comment https://forums.phpfreaks.com/topic/271188-passing-values-through-html-forms/#findComment-1395138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.