justinede Posted July 7, 2010 Share Posted July 7, 2010 Hey All, Last night I finally escaped the menacing claws of GoDaddy. Everything is working fine on my new host, FatCow, except for my login script. The script worked fine on GoDaddy. I checked everything, the php.ini file is default. It seems that a session isnt correctly being set-up. Here is my checklogin.php <?php ob_start(); session_start(); $host="justinledelsoncom.fatcowmysql.com"; // Host name $username="justin_client"; // Mysql username $password="**********"; // Mysql password $db_name="justin_client"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; // To protect MySQL injection (more detail about MySQL injection) $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" $_SESSION['myusername'] = $myusername; $_SESSION['mypassword'] = $mypassword; header("location:users/$myusername/"); } else { echo "Wrong Username or Password"; } ob_end_flush(); ?> Here is my code on the user's specific page: <?php session_start(); if($_SESSION['myusername'] !== "gavriel"){ header("location:http://justinledelson.com/includes/errors/unauthorized.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/ Share on other sites More sharing options...
AbraCadaver Posted July 7, 2010 Share Posted July 7, 2010 "Working fine except for" and "busted" are PHP error messages? error_reporting(E_ALL); ini_set('display_errors', '1'); Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082572 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2010 Share Posted July 7, 2010 What about it "doesn't work"? What is the error you're getting? Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082576 Share on other sites More sharing options...
justinede Posted July 7, 2010 Author Share Posted July 7, 2010 I am not getting an error. It is redirecting me to the unauthorized.php page. Look at the second script. If the session variable dosnt equal gavriel, send to unauthorized.php. Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082579 Share on other sites More sharing options...
Pikachu2000 Posted July 7, 2010 Share Posted July 7, 2010 Comment out the header() redirect temporarily, and put this in instead. See if the SESSION vars have values or not. echo "<pre>"; var_dump($_SESSION); echo "</pre>"; Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082583 Share on other sites More sharing options...
phpology Posted July 7, 2010 Share Posted July 7, 2010 Something random but check your /tmp folder maybe to see if you can write to it. Had a problem like that quite some time ago which had me confused. Or debug your $_SESSION with print_r($_SESSION) Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082584 Share on other sites More sharing options...
justinede Posted July 7, 2010 Author Share Posted July 7, 2010 @Picka I added that and it gives me: array(0) { } on the page.. Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082587 Share on other sites More sharing options...
kenrbnsn Posted July 7, 2010 Share Posted July 7, 2010 Remove the "ob_start()" line from your first script and see if any errors show. Ken Quote Link to comment https://forums.phpfreaks.com/topic/207034-transfered-hosts-now-script-is-busted/#findComment-1082602 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.