I have a page where i show the each person's brief record and there is link for details of each person which takes to another page if someone wants to edit record there is option on that page but making another get variable in not working.
<form action="std_edit.php?edit_id=<?php echo $std_id; ?>">
<input class="std_edit" type="submit" name="edit" value = "Edit">
</form>
i echoed the previous get variable and its printing fine. how can i make it work fine for me?
First thing you can "GET" a variable as long as you can see that in the URL. e.g: exmaple.com?std_id=Boo
In code you do something:
$std_id = $_GET['std_id']; //$std_id will be Boo
<form action="std_edit.php?edit_id=<?php echo $std_id; ?>">
<input class="std_edit" type="submit" name="edit" value = "Edit">
</form>
If you want some variable it has to be there in URL. Taking sample example above, you cannot do something like:
$std_id = $_GET['id'];
Reason, id is not there in URL.
The problem is that any GET variables set in your action
attribute will be lost when you submit the form. This is because upon submit, the GET request is completely rebuild. All you have to do is:
<form action="std_edit.php">
<input type="hidden" name="edit_id" value="<?php echo $std_id; ?>" />
<input class="std_edit" type="submit" name="edit" value = "Edit" />
</form>
That will make it work again.