pmiller624 Posted December 24, 2008 Share Posted December 24, 2008 Hi, im new here and also somewhat new to php, though i do know java and a little c++ anyways im trying to make a user check all it does it check if the given user, pass, and ip are correct I can only get it to work with just using user, pass but when i try to and ip and always comes up as false heres what I have <?php $host="localhost"; // Host name $username="****"; // Mysql username $password="*****"; // Mysql password $db_name="*****"; // Database name $tbl_name="user"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("null"); mysql_select_db("$db_name")or die("null"); // username and password sent from form $myusername=$_GET['u']; $mypassword=$_GET['p']; $myip=$_GET['i']; // 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); $mypassword = stripslashes($myip); $myusername = mysql_real_escape_string($myip); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword' and password='$myip'"; $result=mysql_query($sql); $num_rows = mysql_num_rows($result); if($num_rows > 0) { echo 'true'; } else { echo 'false'; } ?> I call it with something like http://website.com/check.php?u=bob&p=123&i=111.111.1.11 does anyone know why it always comes up as false Thanks Quote Link to comment https://forums.phpfreaks.com/topic/138348-solved-help-needed-with-user-check/ Share on other sites More sharing options...
JasonLewis Posted December 24, 2008 Share Posted December 24, 2008 Your setting $myusername to $myip and same with $mypassword, look: $mypassword = stripslashes($myip); $myusername = mysql_real_escape_string($myip); Then in your query your checking if password is equal to myip. password='$myip'"; Quote Link to comment https://forums.phpfreaks.com/topic/138348-solved-help-needed-with-user-check/#findComment-723406 Share on other sites More sharing options...
pmiller624 Posted December 25, 2008 Author Share Posted December 25, 2008 haha thank you very much Quote Link to comment https://forums.phpfreaks.com/topic/138348-solved-help-needed-with-user-check/#findComment-723418 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.