Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if/else...elseif

Status
Not open for further replies.

MITPRO

IS-IT--Management
Jan 4, 2006
137
US
Hello people. Thanks to the guys that helped me the first time. I came up with a solution to my problem and it works, but now i confused myself into another problem that i can't seem to solve. I apologize if my point becomes a little long.

Here is the code:

<?

if (isset($_GET['wrong']))
$login_wrong=1;
elseif (@$_POST['login'])
{
$login=@$_POST['login'];
$password=@$_POST['password'];
$q="Select password from users where login='$login'";
$res=$db->query($q);
$row=@$db->fetch($res);

if ($db->num_rows($res)&&md5($password)==$row['password'])
{
$ip=$_SERVER['REMOTE_ADDR'];
$uid="-$login-$ip-";
$uid=md5($uid);
$_SESSION['log_id']=$uid;
$_SESSION['ip']=$ip;
echo $_SESSION['login']=$login;
header("Location:index.php?w=profile");
//exit;
}
else $login_wrong=1;
}
?>

Okay this code test if the customer is logged in. If they are not it will ask them to log in if they have a username or password, or to register with us. Now if you have a username and password, and you came to the site and was browsing; you find an item and you click the cart, you are asked to login, but when you login it goes to the header("Location:index.php?w=profile"); location instead of going directly to the cart. I can understand going to the account information page if you have not registered, but for those who have registered it should show the cart after login...I Hope You Guys Follow Me, Anyway, another problem is when a customer clicks the cart and it directs them to there profile, they have an option to select there cart after being logged in, but the item selected before being logged in was not saved to the cart for viewing, it show s empty. I dnt know what i need to do, or if i have done everything right.

I know i said a lot, but if anyone needs more info, or has specific questions to brake down this problems, please help.

Thanks.
 
your description is quite difficult to follow.

the code redirects because of the header function. if you don't want a redirect then delete the header function. the code will then continue to execute. so just put the login code in another file and require the file on each page you want to control.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top