Reputation: 37
I have the following html form in one of my php files:
<form action="reply.php?id=$id" method="post" class="form-horizontal" role="form">
When this form is submitted I want to pass the $id variable from this file into my reply file.
In my reply file I have used the following get method but all that is stored in the $queryid variable is $id instead of the int value that it should be.
$queryid = (int)$_GET['id'];
I realise it's probably something simple I am missing but I just can't seem to work it out.
Upvotes: 1
Views: 2387
Reputation: 131
You need to echo the ID in php right, now you are literally assigning the Id to "$id"
Use this:
<form action="reply.php?id=<?php echo $id; ?>" method="post" class="form-horizontal" role="form">
But I would recommend just inserting the ID as a hidden input and sending it with the rest of the post data.
<input type="hidden" value="<?php echo $id; ?>" name="id"> </input>
Upvotes: 2
Reputation: 748
Try this:
<?php
$queryid = isset($_GET['id']) ? $_GET['id'] : '';
?>
<form action="reply.php?id=<?php echo htmlspecialchars($queryid); ?>" method="POST" class="form-horizontal" role="form">
Upvotes: 0