0

Sorry, if it is obvious for you. I'm new in JavaScript.

I have written a script within a PHP and the page wants user a password to open a new window.

If the password is wrong or if it is null, it will give a specific error inside the current page by going to another url. but if the condition is satisfied, it will open a new page.

The problem is that I don't know how to close the former page automatically.

Here is my code:

<?php
$var1="1";
$pass=$_POST['password'];
if ($pass==$var1) 
{ ?>
<script>
window.open('1.html');
</script>
<?php
}
elseif ($pass=="")
{header("location:null.html");}

else {header("location:error.html");}

?>

Thank you

4
  • What's wrong with the existing window? Commented Nov 24, 2013 at 21:46
  • If you're going to close the current page afterwards, why not just go to the other page instead of opening a window and then closing the old one? Commented Nov 24, 2013 at 21:50
  • there is nothing wrong with it . I can give it a url like two other conditions with php but I want it to be closed. I think the link you offered me , solves the problem. thnaks Commented Nov 24, 2013 at 21:52
  • @ markasoftware because the size of the current page is too small (just a small password field ) and the user has to make that bigger by hand Commented Nov 24, 2013 at 21:57

1 Answer 1

1

This could help: https://stackoverflow.com/a/8890426/3021964

Should work, since you've opened the window with window.open('1.html').

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.