divinedesigns1 Posted June 21, 2012 Share Posted June 21, 2012 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 More sharing options...
Don E Posted June 21, 2012 Share Posted June 21, 2012 (edited) 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 June 21, 2012 by Don E Link to comment Share on other sites More sharing options...
birbal Posted June 21, 2012 Share Posted June 21, 2012 (edited) 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 June 21, 2012 by birbal Link to comment Share on other sites More sharing options...
divinedesigns1 Posted June 21, 2012 Author Share Posted June 21, 2012 nope no errors at all, ok ill try changing the header(); Link to comment Share on other sites More sharing options...
birbal Posted June 21, 2012 Share Posted June 21, 2012 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now