Jump to content

Set page up if something happens.


BMorganVA

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.