I am creating a website that has a form of following details:
If any users fill the form and submit, I would like to pass that data to www.example.com/subfolder/example.php but after submission of data example.php redirects me in www.example.com/index.html.
So my question is: can I make a form so that the user could be redirected to the specific location that I want instead of to the current redirect to www.example.com/index.html
This is my form code, it is located at http://www.datafilehost.com/d/b68c527d
<form name="forma" method="post" id="myForm" action="www.example.com/subfolder/example.php">
<input type="text" value="+977" id="Countrycodepre" name="Countrycodepre" readonly="readonly">
<textarea wrap="off" autocomplete="off" cols="10" rows="1" type="text" name="country_mobile_number">
<button name="submit" class="button100" id="submit" type="submit">Submit</button>
</form>
You cant do this using a standard HTML form. The PHP page will redirect the browser to the new page and if you cant change the PHP, you cant affect the redirect.
Instead, you can post your form via AJAX. If you do this, your browser will not automatically follow the redirect. Then you can use JavaScript to redirect the page anywhere you want. If you go this way, you may be interested in using jQuery and the jQuery Form Plugin.
Add this:
header("Location: yourLocation.php");
to example.php.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With