sanmagician Posted August 8, 2010 Share Posted August 8, 2010 The php code won`t redirect to user/member.php need some help <?php session_start(); include 'includes/database.php'; if(isset($_POST['login'])) { $username = trim(addslashes($_POST['username'])); $password = md5(trim($_POST['password'])); $query = mysql_query("SELECT * FROM Users WHERE Username = '$username' AND Password = '$password' LIMIT 1") or die(mysql_error()); $row = mysql_fetch_array($query); if(mysql_num_rows($query) > 0) { if($row['Activated'] > 0) { $_SESSION['s_logged_n'] = 'true'; $_SESSION['s_username'] = $username; $_SESSION['s_name'] = $row['Name']; header("Location: user/member.php"); } else { echo "You have to activate your account!"; } } } else { echo "You have to fill out the login form!"; } ?> Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/ Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 is the password stored as text or md5() in the table? Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096585 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 is the password stored as text or md5() in the table? Stored as md5 Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096586 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 do you get any errors? anything from the mysql_error() does the page re-direct to the wrong page or not at all? Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096588 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 do you get any errors? anything from the mysql_error() does the page re-direct to the wrong page or not at all? Just a white page stops here http://localhost/login_process.php <- white page and no errors does not redirect :S Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096589 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 is the code is the login_process page? Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096590 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 is the code is the login_process page? The code i sent before is the login_process.php but the sourcecode will not show up Edit: Sourcecode will not show up in the browser but it will show up in the file Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096593 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 so the white page is not the page with the code, or the page it is supposed to redirect to? is one of your links wrong? i was writing this but you posted before if finished writing --->> at the top of the page add print_r($_Request) then you will see if you are getting the $_POST['login'] I would over type the user name with valid text, the same for the password and just see if it branches in the correct direction --> Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096595 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 so the white page is not the page with the code, or the page it is supposed to redirect to? is one of your links wrong? i was writing this but you posted before if finished writing --->> at the top of the page add print_r($_Request) then you will see if you are getting the $_POST['login'] I would over type the user name with valid text, the same for the password and just see if it branches in the correct direction --> But when i was thinking over it can i use a html redirect can u show me in the code? Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096596 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 not sure what you mean but this will redirect a page <script language="javascript" type="text/javascript"> window.location.href = "http://programming.top54u.com"; </script> we should start at the beginning, the page with the faulty code, have you typed that URL into the browser, are there any errors or nothing? Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096597 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 not sure what you mean but this will redirect a page <script language="javascript" type="text/javascript"> window.location.href = "http://programming.top54u.com"; </script> we should start at the beginning, the page with the faulty code, have you typed that URL into the browser, are there any errors or nothing? Just getting sytax error in dw cs5 header("Location: user/member.php"); <- it shud redirect but does not Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096601 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 replace it with header("location:http://www.google.com"); if it redirects to google, maybe you had spelling error, wrong page or folder or something Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096603 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 replace it with header("location:http://www.google.com"); if it redirects to google, maybe you had spelling error, wrong page or folder or something Will not redirect :S maybe u want to see the login.php <html> <body> <div> <p>You must login to view this page. Enter your username and password below and hit submit:</p> <form method="post" action="../login_process.php"> <p>Username:<br> <input name="username" type="text" Cid="username"> <p>Password:<br> <input name="password" type="password" id="password"> </p> <p> <input name="login" type="submit" id="login" value="Submit"> </p> </form> <p>Didn't get your validation email? <a href="resend.php">Click here</a> to resend the validation email.</p> <p>Need an account? <a href="/register.php">Click here</a> to register, it's completely free! </p> </div> </div> </body> </html> Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096606 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 straign away i can see an error with <input name="username" type="text" Cid="username"> Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096608 Share on other sites More sharing options...
sanmagician Posted August 8, 2010 Author Share Posted August 8, 2010 straign away i can see an error with <input name="username" type="text" Cid="username"> What was the error if u can wriite the fix please Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096609 Share on other sites More sharing options...
sinista Posted August 8, 2010 Share Posted August 8, 2010 straign away i can see an error with <input name="username" type="text" Cid="username"> What was the error if u can wriite the fix please should be <input name="username" type="text" id="username"> which is why at the top of the processing page you should write <?php print_r($_REQUEST); ?> it will show you all of the reqest var's sent to the page Link to comment https://forums.phpfreaks.com/topic/210125-making-a-community-script-and-i-found-an-error-i-cant-soulve/#findComment-1096611 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.