Form Post Method, $_Get in Form Post Action |
Form Post Method, $_Get in Form Post Action |
Freshman |
Dec 19 2018, 08:54 AM
Post
#1
|
Newbie Group: Members Posts: 12 Joined: 19-December 18 Member No.: 26,776 |
Hi all,
I'm very new to HTML and PhP but learning as I go. In code below I would like to 'insert' the id (from the URL) to the Action in the Form Post method. As you will see I tried to pass the $id value into the Action but it is not working. If I hardcode the correct value then all my following code work 100% URL would be something like: www.mydomain.com/add.html?id=123 CODE <?php //getting id from URL $id = $_GET['id']; ?> <html> <head> <title>Add Data</title> </head> <body> <br/><br/> <form method="post" name="form1" action="addrec.php?id="&<?php echo $id;?>> <table width="25%" border="0"> <tr> <td>Day <?php echo $id;?> N </td> <td><input type="text" name="HDay"></td> </tr> <tr> <td>Month</td> <td><input type="text" name="HMonth"></td> </tr> <tr> <td>Relation</td> <td><input type="text" name="Relation"></td> </tr> <tr> <td></td> <td><input type="submit" name="Submit" value="Add"></td> </tr> </table> </form> </body> </html> |
Freshman |
Dec 20 2018, 02:01 AM
Post
#2
|
Newbie Group: Members Posts: 12 Joined: 19-December 18 Member No.: 26,776 |
Final update:
@ChristianJ - Thanks this worked (Not sure how to give a 'thumbs up' on your post or to mark as 'solved') CODE action="addrec.php?id=<?php echo $id;?>"> This post has been edited by Freshman: Dec 20 2018, 02:02 AM |
pandy |
Dec 20 2018, 04:15 AM
Post
#3
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,731 Joined: 9-August 06 Member No.: 6 |
Ah, simple as that.
Normally .html files aren't parsed for PHP. You can see that by doing a View Source. If PHP isn't parsed you see the raw PHP in the page source. If it is you don't. If it's important to you, you can make the server parse HTML files too though. |
Lo-Fi Version | Time is now: 26th April 2024 - 09:18 AM |