Jump to content

[SOLVED] redirect wont work


phpSensei

Recommended Posts

 

Alright, this is a login validation thing. When leaves the field empty, things redirect to right page. But when the login is a success, the page would not budge. Its like a blank page with nothing in it.

 

i even tried to echo something outside of the if/else, and still nothing.

 

why wont it redirect? NO ERRORS COME UP BTW.

 

 

 

 

<?php
   include("../config/connection.php"); // Set the connection file
									  //include our session handling file, make sure you have the right file name
session_start();
$action = $_GET['mode'];


switch($action){


case 'login':
$username = trim($_POST['username']);
$password = trim(md5($_POST['password']));
$cookie = $_POST['autologin'];
$redirect = $_POST['redirect'];

if(($username == "")||($password == "")){

header("LOCATION: ".$redirect."?error=001");


}
else
{
$username = strip_tags($username);
$password = strip_tags($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);

$row=mysql_fetch_array(mysql_query("SELECT * FROM ap_users WHERE ap_username = '$username' and ap_password = '$password'")) or die(mysql_error());
if(($row['ap_username']==$username)&&($row['ap_password']==$password)){


if(isset($cookie)){
/////////////////////////////////////
setcookie("ap_user",$username,time()+1000000000000000000000000000);
setcookie("ap_id",$row['ap_id'],time()+1000000000000000000000000000);
setcookie("session_logged_in",true,time()+1000000000000000000000000000);

header("LOCATION: ".$redirect);


}// end if cookie isset
////////////////////////////////////////

else
{
$_SESSION['username']==$username;
$_SESSION['user_id'] == $row['ap_id'];
$_SESSION['session_logged_in']== true;
header("LOCATION: ".$redirect);

}
/////////////////////////////////////////




}// end if password and username are correct
else
{

header("LOCATION: ".$redirect."?error=002");

}// end if username or password dont exsist
}// end else

break;
}// and case
?>

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.