CrazeD Posted February 14, 2007 Share Posted February 14, 2007 I have installed PHPTriad on my computer, which is PHP, Apache, and MySQL all in one. I made a couple scripts for a login system and made a database. The script works fine...offline. It doesn't work on my hosting, the username/password don't match. It's the EXACT same code, EXACT same database...yet it doesn't work?! How can that be? Any help is great...thanks. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/ Share on other sites More sharing options...
redarrow Posted February 14, 2007 Share Posted February 14, 2007 where the code to see the problam are you using the $_POST and $_GET correctly. cross match php.ini on yours and the hosting? Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-184458 Share on other sites More sharing options...
JasonLewis Posted February 14, 2007 Share Posted February 14, 2007 inserted all the correct data in the database. double check everything. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-184459 Share on other sites More sharing options...
CrazeD Posted February 14, 2007 Author Share Posted February 14, 2007 Here's my code; <?php require_once('mysql.php'); if (isset ($_POST['submit'])) { if ( (!empty ($_POST['username'])) && (!empty ($_POST['password'])) ) { $query = "SELECT * FROM pr0n_members WHERE username='$username' AND password='$password'"; $result=mysql_query($query); $num=mysql_num_rows($result); if($num > 0) { session_start(); $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); header ('Location: loggedin.php'); exit(); } else { print '<p>An error has occured:<b> That username/password combination was not found, please try again!</b></p>'; } } else { print '<p>An error has occured:<b> Please enter both a username and a password!</b></p>'; } } else { print '<form action="login_page.php" method="post"> <p>Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /><br /> <input type="submit" name="submit" value="Login" /></p></form>'; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-184953 Share on other sites More sharing options...
hitman6003 Posted February 14, 2007 Share Posted February 14, 2007 Change: $result=mysql_query($query); to: $result=mysql_query($query) or die(mysql_error()); See if you are getting an error. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-184966 Share on other sites More sharing options...
CrazeD Posted February 15, 2007 Author Share Posted February 15, 2007 The error is the fact that that both the username and password do not match, defined in my code: } else { print '<p>An error has occured:<b> Please enter both a username and a password!</b></p>'; } Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185033 Share on other sites More sharing options...
redarrow Posted February 15, 2007 Share Posted February 15, 2007 <?php session_start(); require_once('mysql.php'); if ( (empty ($_POST['username'])) || (empty ($_POST['password'])) ) { print '<p>An error has occured:<b> That username/password combination was not found, please try again!</b></p>'; } if (isset ($_POST['submit'])) { $query = "SELECT * FROM pr0n_members WHERE username='$username' AND password='$password'"; $result=mysql_query($query); $num=mysql_num_rows($result); if($num > 0) { $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); header ('Location: loggedin.php'); exit(); } }else{ echo"<p>An error has occured:<b> please register! "; } echo '<form action="login_page.php" method="post"> <p>Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /><br /> <input type="submit" name="submit" value="Login" /></p></form>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185038 Share on other sites More sharing options...
CrazeD Posted February 15, 2007 Author Share Posted February 15, 2007 That doesn't work either.... Here, so you guys can see what's happening: http://crazed.110mb.com/login_page.php Username is 1, password is 1 Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185062 Share on other sites More sharing options...
redarrow Posted February 15, 2007 Share Posted February 15, 2007 did you make the page loggedin.php for the header to use.? $num >0 to $num ==1 Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185070 Share on other sites More sharing options...
redarrow Posted February 15, 2007 Share Posted February 15, 2007 try this should goto google when logged in. so add this to yours ok or die(mysql_error()); <?php session_start(); require_once('mysql.php'); if (isset ($_POST['submit'])) { $query = "SELECT * FROM pr0n_members WHERE username='$username' AND password='$password'"; $result=mysql_query($query) or die(mysql_error()); $num=mysql_num_rows($result); if($num > 0) { $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); header ('Location: http://www.goole.com'); exit(); } } echo '<form action="login_page.php" method="post"> <p>Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /><br /> <input type="submit" name="submit" value="Login" /></p></form>'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185077 Share on other sites More sharing options...
CrazeD Posted February 15, 2007 Author Share Posted February 15, 2007 Your script doesn't do anything when I click login, it just refreshes the page pretty much. I don't understand though... this exact script works on my machine but not on my hosting. How can I export an SQL table with PHPMyAdmin? I didn't see any export button despite looking for quite some time. Maybe if I upload the exact SQL table it might work.... Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185096 Share on other sites More sharing options...
JasonLewis Posted February 15, 2007 Share Posted February 15, 2007 it shouldnt make a difference if you copy the database information exactly the same. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185310 Share on other sites More sharing options...
ted_chou12 Posted February 15, 2007 Share Posted February 15, 2007 I cant even seem to login...:http://crazed.110mb.com/login_page.php Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185312 Share on other sites More sharing options...
CrazeD Posted February 15, 2007 Author Share Posted February 15, 2007 I cant even seem to login...:http://crazed.110mb.com/login_page.php Yeah...that's the problem. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-185866 Share on other sites More sharing options...
JasonLewis Posted February 16, 2007 Share Posted February 16, 2007 here try this: <?php session_start(); require_once('mysql.php'); if(isset($_POST['submit'])){ $username = $_POST['username']; $password = $_POST['password']; if($username != "" && $password != ""){ $query = "SELECT * FROM pr0n_members WHERE username='$username' AND password='$password'"; $result=mysql_query($query); $num=mysql_num_rows($result); if($num > 0) { $_SESSION['username'] = $username; $_SESSION['loggedin'] = time(); header('Location: loggedin.php'); exit(); }else{ print '<p>An error has occured:<b> That username/password combination was not found, please try again!</b></p>'; } }else{ print '<p>An error has occured:<b> Please enter both a username and a password!</b></p>'; } }else{ echo <<<html <form action="login_page.php" method="post"> <p>Username: <input type="text" name="username" /><br /> Password: <input type="password" name="password" /><br /><br /> <input type="submit" name="submit" value="Login" /></p> </form> html; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-186115 Share on other sites More sharing options...
The_Assistant Posted February 16, 2007 Share Posted February 16, 2007 ProjectFear's script should do the trick. Thats pretty much how i do my logins when i need to code one. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-186138 Share on other sites More sharing options...
CrazeD Posted February 16, 2007 Author Share Posted February 16, 2007 YES! That worked, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-186648 Share on other sites More sharing options...
The_Assistant Posted February 17, 2007 Share Posted February 17, 2007 ProjectFear sure knows his stuff. Quote Link to comment https://forums.phpfreaks.com/topic/38445-cant-retrieve-info-from-mysql-db/#findComment-186820 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.