The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Form Post Method, $_Get in Form Post Action
Freshman
post 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>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 17th November 2019 - 03:42 PM