-1

I'm trying to make the page go back when the user presses the OK button on the alert box. The alert box appears but it doesn't go back to the previous page

Would i have to use a confirm window because i don't want to provide the cancel option, i just want a window to appear so the user has to click OK and it goes back to the previous page

print '<script type="text/javascript">';
print 'alert("Invalid please try again.")';
print 'history.back();';
print '</script>'; 

Just to provide a little more information I'm doing this after OR

$link =mysqli_connect(*sensitive info*) OR  print '<script type="text/javascript">';
    print 'alert("Invalid please try again.")';
    print 'history.back();';
    print '</script>'; 
exit();
user3166873
  • 85
  • 3
  • 10

4 Answers4

2

Try this, You have missed to add ;

 print '<script type="text/javascript">';
 print 'alert("Invalid please try again.");';
                                 .........^
 print 'history.back();';
 print '</script>';
Krish R
  • 22,583
  • 7
  • 50
  • 59
1

I think you're missing a semicolon ; after alert().

print '<script type="text/javascript">';
print 'alert("Invalid please try again.");';
print 'history.back();';
print '</script>'; 
magnetronnie
  • 505
  • 3
  • 16
0

You have missed the ';' after your alert

print '<script type="text/javascript">';
print 'alert("Invalid please try again.");';
print 'history.back();';
print '</script>'; 

To find our errors in code you can use websites such as http://www.jslint.com/ to catch these errors easily.

Dean Meehan
  • 2,511
  • 22
  • 36
0
echo "<script type=\"text/javascript\">"; 
echo "alert(\"Invalid please try again.\")"; 
echo "window.location= \"/*Write ur page Link Here*/\""; 
echo "</script>";   

Hope above code will work for you. and yeah ";" is missing after your alert line.

iDhavalVaja
  • 153
  • 1
  • 10