overlordofevil Posted April 15, 2008 Share Posted April 15, 2008 I just moved hosting company and having problems getting my login script to work. I know the php and mysql is working fine. I have tested the scripts by changing up what happens when I select to login. Such as I changed it to just verify that my login name and password exists. So I think my problem is with my redirect to another page but I can't see the problem. When i log in it just stops and doesn't redirect. I have changed the redirect from header(Location: home.php) to header(Location:http://testdb.nerowi.com/page.php) to see if using the entire path might help but it hasn't helped. here is the current code <?php session_start(); ?> <html> <body> <?php //process.php - Takes care of login and logout scripts include ("login.inc"); //holds the variables for the db login $user = $_POST ['user']; $pass = $_POST ['pass']; $query = "SELECT * FROM id WHERE username='$user' AND password='$pass'"; $result = mysql_query($query) or die (mysql_error()); if ($result) { $line = mysql_fetch_array($result); { $_SESSION['user_id'] = $line['id']; $_SESSION['user_name'] = $line['username']; $_SESSION['user_pass'] = $line['password']; $_SESSION['user_rights'] = $line['accesslvl']; $_SESSION['chapter_id'] = $line['chid']; header("Location: http://testdb.nerowi.com/home.php"); } } ?> </body> </html> This works fine on my test server I have here at the office and it worked fine on my old host company problem is it just won't respond tothe new host. Any suggestions would be appreciated. Link to comment https://forums.phpfreaks.com/topic/101230-solved-headerredirect-problem/ Share on other sites More sharing options...
themistral Posted April 15, 2008 Share Posted April 15, 2008 Hmmm, as it works on 2 other servers I would suggest that the new server setup is the cause, and the only real way to find out why that might be is to ask your new hosts! Link to comment https://forums.phpfreaks.com/topic/101230-solved-headerredirect-problem/#findComment-517808 Share on other sites More sharing options...
overlordofevil Posted April 15, 2008 Author Share Posted April 15, 2008 yeah thats what i was thinking but i figured i would ask and see if you guys had any other suggestion. Thanks Link to comment https://forums.phpfreaks.com/topic/101230-solved-headerredirect-problem/#findComment-517831 Share on other sites More sharing options...
lalomarquez Posted April 15, 2008 Share Posted April 15, 2008 I'm very new at this, and since I experiment with everything even if I don't know what it is for, in this situation for curiosity sake, I would test it using ob_start(); at the very top of the page and ob_flush(); at the very bottom. Or perhaps getting rid of those html tags and spaces at the beginning of your code. Maybe I'm just talking nonsense and the session_start() does the same thing... Link to comment https://forums.phpfreaks.com/topic/101230-solved-headerredirect-problem/#findComment-517840 Share on other sites More sharing options...
conker87 Posted April 15, 2008 Share Posted April 15, 2008 You're outputting before you do the header(). Big mistake Since you don't need the body or html tags, try: <?php session_start(); //process.php - Takes care of login and logout scripts include ("login.inc"); //holds the variables for the db login $user = $_POST ['user']; $pass = $_POST ['pass']; $query = "SELECT * FROM id WHERE username='$user' AND password='$pass'"; $result = mysql_query($query) or die (mysql_error()); if ($result) { $line = mysql_fetch_array($result); { $_SESSION['user_id'] = $line['id']; $_SESSION['user_name'] = $line['username']; $_SESSION['user_pass'] = $line['password']; $_SESSION['user_rights'] = $line['accesslvl']; $_SESSION['chapter_id'] = $line['chid']; header("Location: http://testdb.nerowi.com/home.php"); } } ?> Link to comment https://forums.phpfreaks.com/topic/101230-solved-headerredirect-problem/#findComment-517862 Share on other sites More sharing options...
overlordofevil Posted April 15, 2008 Author Share Posted April 15, 2008 that was such a simple fix I can't believed it worked.... sigh... Thanks for looking over the code and finding my mistake. Link to comment https://forums.phpfreaks.com/topic/101230-solved-headerredirect-problem/#findComment-517984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.