cugopob.vlad Posted March 4, 2009 Report Share Posted March 4, 2009 hi i was working on a page in my site that includes the php if statement and i want to make it so that if the statement is false it sends it to another page. could anybody tell me how to do that thanks. Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted March 4, 2009 Report Share Posted March 4, 2009 if ($result == 0) { // Redirect the user to the wherever.php page. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/wherever.php'; header("Location: $url"); exit(); } else { // other stuff happens } Quote Link to comment Share on other sites More sharing options...
jlhaslip Posted March 5, 2009 Report Share Posted March 5, 2009 processing include ("contact.html"); $name = $_REQUEST['yourname']; $email = $_REQUEST['email']; if ($name == "") { echo "Sorry but you need to put your name in."; // Redirect the user to the wherever1.php page. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/wherever1.php'; header("Location: $url"); exit(); } elseif ($email == "") { echo "Sorry but we need your email address to get back to you"; // Redirect the user to the wherever2.php page. // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/wherever2.php'; header("Location: $url"); exit(); } // do stuff here with the $name and $email variables ?> Quote Link to comment Share on other sites More sharing options...
cugopob.vlad Posted March 6, 2009 Author Report Share Posted March 6, 2009 oh ok thank you VERY MUCH. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.