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开发者_JAVA百科, 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.
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.
@M LOHIT
<script type="text/javascript">alert("Stupid message");window.location.href='previouspage';
</script>
This will surely work for you
echo"<script type='text/javascript'>alert('Data Failed');window.location.href='index.php';</script>";
This might help you
echo '<script>alert("your error message"); location.replace(document.referrer);</script>';
精彩评论