Reputation: 735
In my project, the first PHP page takes input from user and submits it to the second PHP page. In the second PHP page, the values which come from first page are validated against values from database, using functions. I want to redirect to the first page if any of the values submitted is wrong. Please help me out with the code. If not possible in PHP please mention the code in any other like jQuery or Ajax.
Upvotes: 3
Views: 14019
Reputation: 119
echo"<script type='text/javascript'>alert('Data Failed');window.location.href='index.php';</script>";
Upvotes: 1
Reputation: 31
This might help you
echo '<script>alert("your error message"); location.replace(document.referrer);</script>';
Upvotes: 0
Reputation: 3867
@M LOHIT
<script type="text/javascript">alert("Stupid message");window.location.href='previouspage';
</script>
This will surely work for you
Upvotes: 1
Reputation: 66465
Here is code that does exactely what you want (according to your title):
<script type="text/javascript">alert("Stupid message");history.go(-1);</script>
I don't like this way of working, you'd better to use sessions, or creating one file that displays the form and does the validating.
Upvotes: 7