Reputation: 983
I have an HTML form with a form action of foo.php. However, when I click the submit button, I get redirected to the "foo.php", but I don't get redirected back to the page where the form is located. Could anyone tell me if there is some sort of code that is necessary for this to happen?
Here's my PHP file, if this helps:
<?php
$title = $_POST['title'];
$content = $_POST['content'];
$postid = $_POST['postid'];
?>
Upvotes: 0
Views: 104
Reputation: 7040
It very simple. Try to understand your task first. You need to redirect to another page after completing your task whatever save/update/processing data.
just set header in your php script after completing your work.
<?php
// your all code will goes here
header("Location: myform.php");
?>
Upvotes: 0
Reputation: 628
Two ways:
<?php
header('Location: myform.php');
?>
or use javascript:
<script>
window.location('myform.php');
Upvotes: 1
Reputation: 86336
You can set header redirect back to form file, after processing the form data. Assuming your form file has name "form.php
"
header('location: form.php');
Upvotes: 1