Open a new link in an if statement with PHP
25,306
Solution 1
PHP won't be able to handle opening a new window for you. The most you can do is a redirection.
header('Location: http://destination.com');
Opening a new window can be done with JavaScript
window.open('http://destination.com');
Solution 2
header('Location: http://host/'.[your new page]);
exit;
Solution 3
you may use
header("location:pagename.php");
Open in new window
window.open('pagename.php');
Solution 4
Use header to redirect:
<?php
$var1="1";
$pass=$_POST['password'];
if ($pass==$var1)
{
echo "ok";
header('Location: main.html');
exit;
}
elseif ($pass=="")
{
echo "No Entry";
}
else
{
echo "Wrong Password";
}
?>
Author by
Nima
Updated on July 05, 2022Comments
-
Nima almost 2 years
I have the 'else if' statement below, and I want to open a new page in my host (main.html), if the entry password is correct.
<?php $var1="1"; $pass=$_POST['password']; if ($pass==$var1) { echo "ok"; //***here is your help*** } elseif ($pass=="") {echo "No Entry"; } else { echo "Wrong Password";} ?>
Please suggest a PHP code for opening a new window.
Thanks.