Jump to content
Killersites Forums

what code do i need to change


Recommended Posts

hi what code do i need to change if i want users who logged in invalid information to be redirected to another page instead of the original log in page.

 

<?

include_once "connect.php";

include_once "functions.php";

 

if (isset ( $_GET ["logout"] )) {

$_SESSION ['user'] = 0;

$msg = "Logged Out";

header('location: index.php');

exit();

}

 

 

if ($userid) {

$msg = "Already Logged";

header('location: members.php');

exit();

}

elseif (isset ( $_POST ["password"] ) && isset ( $_POST ["email"] )) {

$inEmail = fixquotes ( $_POST ["email"] );

$inPassword = fixquotes ( $_POST ["password"] );

$rs = mysql_query ( "SELECT id FROM users AS u WHERE email='$inEmail' AND password='$inPassword'" ) or die ( mysql_error () );

if (mysql_num_rows ( $rs )) {

list($userid) = mysql_fetch_array ( $rs );

$_SESSION ['user'] = $userid;

$msg = "Logged in";

header('location: members.php');

exit();

} elseif ($_REQUEST['register']) {

$inName = fixquotes($_REQUEST['name']);

$street = fixquotes($_REQUEST['street']);

$city = fixquotes($_REQUEST['city']);

$state = fixquotes($_REQUEST['state']);

$zipcode = fixquotes($_REQUEST['zipcode']);

$website = fixquotes($_REQUEST['website']);

$firstName = fixquotes($_REQUEST['firstName']);

$lastName = fixquotes($_REQUEST['lastName']);

$workPhone = fixquotes($_REQUEST['workPhone']);

$cellPhone = fixquotes($_REQUEST['cellPhone']);

$fax = fixquotes($_REQUEST['fax']);

$dot = fixquotes($_REQUEST['dot']);

$mc = fixquotes($_REQUEST['mc']);

$trucks = intval($_REQUEST['trucks']);

$website = "http://".str_replace("http://", "", $website);

if (!$inName || !$inEmail || !$inPassword || !checkEmail($inEmail) || !$state

|| !$firstName || !$workPhone || !$dot) {

$msg = "Invalid Registery Details";

} else {

mysql_query("INSERT INTO users

(name, email, password, street, city, state, zipcode, website,

firstName, lastName, workPhone, cellPhone, fax, dot, mc, trucks)

VALUES('$inName', '$inEmail', '$inPassword', '$street', '$city',

'$state', '$zipcode', '$website', '$firstName', '$lastName',

'$workPhone', '$cellPhone', '$fax', '$dot', '$mc', '$trucks')") or die(mysql_error());

$rs = mysql_query ( "SELECT id FROM users AS u WHERE email='$inEmail' AND password='$inPassword'" ) or die ( mysql_error () );

list($userid) = mysql_fetch_array ( $rs );

if ($userid) {

$_SESSION ['user'] = $userid;

$msg = "Registered Successfully";

$headers = "MIME-Version: 1.0\n";

$headers .= "Content-type: text/html; charset=windows-1255\n";

$headers .= "From: Movers Community \n";

$MSG = "

Thank you for registering to MoversCommunity.com

 

 

These are your user details:

 

 

Company Name: $inName,

 

Contact Email: $inEmail,

 

Password: $inPassword,

 

Street: $street,

 

City: $city,

 

State: $state,

 

Zipcode: $zipcode,

 

Website: $website,

 

Contact First Name: $firstName,

 

Contact Last Name: $lastName,

 

Work Phone: $workPhone,

 

Cell Phone: $cellPhone,

 

Fax: $fax,

 

DOT#: $dot,

 

MC#: $mc,

 

# of Trucks: $trucks

";

mail($inEmail, "Registered Successfully", $MSG, $headers);

}

else {

$msg = "Invalid Registery Details";

}

}

}

else {

$_SESSION ['user'] = 0;

$msg = "Invalid Login Details";

}

}

 

include "header.php";

?>

07.png Login / Register

<?

if (!empty($msg)) {

echo "

$msg
";

if ($_SESSION['user']!=0) {//logged

include "footer.php";

exit();

}

}

?>

 

LOGIN

Email:

 

 

Password:

 

 

 

OR REGISTER

 

width="544" style='border:1px solid #2165a5;background:#eeeeee'>

    Company

Information

 * Required Fields

Company Name *

       Street  

City  

State*  

-Select State-

<?getOptions(array_keys($states),$_POST['state']);?>

Zip Code  

Website  

    

style='color:white'>Contact Information

Contact First Name

*  

name="firstName" value='<?=$_POST['firstName']?>'>

Contact Last Name   

name="lastName" value='<?=$_POST['lastName']?>'>

Contact Work Phone

*  

name="workPhone" value='<?=$_POST['workPhone']?>'>

Contact Cell Phone  

name="cellPhone" value='<?=$_POST['cellPhone']?>'>

Contact Fax Number  

Contact E-mail

*  

name="email" value='<?=$_POST['email']?>'>

Required Password

*  

name="password" value='<?=$_POST['password']?>'>

    

style='color:white'>Truck Information

DOT Number

*  

name="dot" value='<?=$_POST['dot']?>'>

MC Number  

name="mc" value='<?=$_POST['mc']?>'>

Number of Trucks  

-Select-

<?

$trackArr = array();

for ($i=1; $i<=25; ++$i)

$trackArr[] = $i;

getOptions(array_keys($trackArr), $_POST['trucks']);

?>

 

type="submit">

 

<? include "footer.php";?>

Link to post
Share on other sites

hi,

 

It would me much easier for peop;e to help you if you upload your file and post a link.

 

keep in mind that php is a server-side script, meaning it reside on the server and not all servers are configure the same, so it may not work on your test server but might work online on different configuration

Link to post
Share on other sites
hi,

 

It would me much easier for peop;e to help you if you upload your file and post a link.

 

keep in mind that php is a server-side script, meaning it reside on the server and not all servers are configure the same, so it may not work on your test server but might work online on different configuration

In this case, providing the PHP code is actually better than posting a link, since obviously the PHP code won't show on the server.

 

In response to your question...

 

This is the bit of code that handles incorrect logins:

 

    else {
        $_SESSION ['user'] = 0;
        $msg = "Invalid Login Details";
   }

 

You could change it to something like this to redirect the user to an error page:

 

    else {
        $_SESSION ['user'] = 0;
        header('location: error.php');
   }

 

This uses the PHP header() function to change the page. I haven't tested this, but it should work fine. You'll need to change "error.php" to link to your error page.

Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Loading...
×
×
  • Create New...