BMorganVA Posted March 2, 2010 Share Posted March 2, 2010 I making a registration form. Everything works except one part. Depending on what the condition is (i.e. User name in use, email in use, successful registration), I want the page to show up differently. I don't know how to do that. I tried using the header function to different pages, but that won't work because it isn't the first thing on the page. Here is my code: <?php require("includes/connect.php"); $resultUser = mysql_query("SELECT COUNT(*) FROM `sq_users` WHERE `Username`= "$_POST[user]""); if ($resultUser == 1) header("Location: "Location:http://localhost/social/uregister.php""); echo("$resultUser"); $resultEmail = mysql_query("SELECT COUNT(*) FROM `sq_users` WHERE `Email`= "$_POST[email]""); if ($_POST['email'] == $resultEmail) header("Location:http://localhost/social/eregister.php"); $passwd = $_POST[password1]; $passenc = md5($passwd); $verifyBase = microtime(); $verify = md5($verifyBase); $sql = "INSERT INTO `sq_users` (`Username`, `Passwd`, `Email`, `Valid`) VALUES ('$_POST[user]', '$passenc', '$_POST[email]', '$verify')"; if(!mysql_query($sql,$con)) { die('Error:' . mysql_error()); } mysql_close($con); ?> Thanks for the help. Also, if you need an example of what I'm talking about, go to Facebook and type the wrong password when you login. Notice the URL and how it has the parameter "?login_attempt=1". Delete the parameter and the page displays differently. That's what I'm trying to do. Link to comment https://forums.phpfreaks.com/topic/193851-set-page-up-if-something-happens/ Share on other sites More sharing options...
meltingpoint Posted March 2, 2010 Share Posted March 2, 2010 In the first part you have- Location twice (see below). I believe that it is not parsing that and moving onto the echo statement which is outputting to the browser which will result in the output to header error. header("Location: "Location:http://localhost/social/uregister.php""); Additionally- if that is where you want it to go after the error is detected- then there should be an exit; directly after to prevent the script from continuing. It should look like so-- header("Location: http://localhost/social/uregister.php"); exit; echo $resultUser; Link to comment https://forums.phpfreaks.com/topic/193851-set-page-up-if-something-happens/#findComment-1020220 Share on other sites More sharing options...
BMorganVA Posted March 2, 2010 Author Share Posted March 2, 2010 I would like it if there was a way to do the via parameters. BTW, for clearer explaining, I want a "If this action happens, the page looks like this." Kind of thing. Ignore this line of code, it was just for testing. echo("$resultUser"); Link to comment https://forums.phpfreaks.com/topic/193851-set-page-up-if-something-happens/#findComment-1020227 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.