I try open url from user input value but its no value
<form> <p>*number:</p> <input type="text" name="numberpage" value=""/> </form> <a href="./page.php?page=editdatapo&id=<?php echo $_POST['numberpage']; ?>">find</a>
here result that should be
user input = 13
output url
localhost/page.php?page=editdatapo&id=13
but output like this
localhost/page.php?page=editdatapo&id=
Advertisement
Answer
<form action="./page.php" method="GET"> <p>*number:</p> <input type="hidden" name="page" value="editdatapo" /> <input required type="text" name="id"/> <input type="submit" value="Find" /> </form>
Try using GET
. After hitting submit, it will redirect to:
page.php?page=editdatapo&id=USER_INPUT
This way, you dont have to use $_POST
just to access the link. You can just type the id then hit Enter/Find directly.
By default, forms without the method
attribute uses GET
and you can omit it if you really want to.