Jump to content

Login page not going to the next page


divinedesigns1
 Share

Recommended Posts

hey im having a little problem, getting to the next page after login, how it should work is i log in with a username and password, then go to the admin page but i log in but cant get to the admin page im using a header(); to get to the admin page but blaaah isnt working,

<?phpif(isset($_POST['username'])){ include_once("../php/config.php"); $username = stripslashes($_POST['username']); $username = strip_tags($_POST['username']); $username = mysqli_real_escape_string($con, $username); $password = preg_replace("[^A-Za-z0-9]", "", $_POST['password']); $password = md5($password);  $query = "SELECT * FROM user WHERE username='$username' AND password='$password'"; $result = mysqli_query($con, $query); if($result){ $login_check = mysqli_num_rows($result);   while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){	$id = $row['id'];	session_register('id');	$_SESSION['id'] = $id;	$username = $row['username'];	session_register('username');	$_SESSION['username'] = $username;	header("location: admin.php?id=' . row['id'] . '");	exit();   } }else{   echo 'There\'s no such username or password';  }}?>

Link to comment
Share on other sites

Is PHP displaying any errors? With header(), you can just do this if you want:

header("location: admin.php?id=row['id']");

If you were using single quotes, then the way you had it should be okay. ie

 header('location: admin.php?id=' . row['id'] );

Edited by Don E
Link to comment
Share on other sites

is there any error showing? do you have error enabled for every type of error? possible reasons..make sure you dont have any output before header call. not even a white space.

header("location: admin.php?id=' . row['id'] . '");
it will not evaluate correct url dots will be treated as string character as it is inside double quotes.
header("location: admin.php?id={row['id'] } "); 

Edited by birbal
Link to comment
Share on other sites

ini_set('display_error',true); ini_set('error_reporting',E_ALL|E_NOICE);[/CODprepend it top of the script or make changes to the specific directive to your php.ini. (recomended for development enviourment)ht http://php.net/ini_set <=reference
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...