I have a simple form when I submit it checks if number exist in database and then it echoes one of two links depending if the condition is satisfied. Now I want him to echo and that number (correct one that exist in database) to the end of the link. How could i do that? For example this is number I get from form
$example = $_POST['example'];
and after a condition I have this
echo "<script>window.location = 'www.examplelink.com/something';</script>";
I presume it would go like this
echo "<script>window.location = 'www.examplelink.com/something example=".$example."';</script>";
But it's not working
Usually the GET
method is a reference to the search parameters on a URL. At the end of your URL, simply define the search parameters by adding a '?' then example=...
This can be followed up with an ampersand to distinguish between different search variables.
echo "<script>window.location = 'www.examplelink.com/something.php?example=".$example."';</script>";
If you use this then you must call the $_GET['example']
variable when PHP reloads the page.
Why don't you just redirect the user using PHP?
if ( $variable1 == $variable2 ) {
header("Location: http://www.examplelink.com/somethingexample=" . $example );
}
or even:
if ( $variable1 == $variable2 ) {
header("Location: http://www.examplelink.com/somethingexample=" . $_POST['example'] );
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.