Lamez Posted October 11, 2008 Share Posted October 11, 2008 ok I have a page where the user can put in a string, and I have strings in the database. I want to know the best way to check to see if the user's string matches the database string. -Thanks Guys! Link to comment https://forums.phpfreaks.com/topic/128019-solved-best-way-to-do-this/ Share on other sites More sharing options...
smithmr8 Posted October 11, 2008 Share Posted October 11, 2008 Can you give any more information ? Something like this maybe, $string = $_POST['string']; $sql = mysql_query("SELECT * FROM `table_name` WHERE `string`='$string'"); if (mysql_num_rows($sql) >= 1){ echo "Existing String"; } else { echo "String Not In Table"; } Link to comment https://forums.phpfreaks.com/topic/128019-solved-best-way-to-do-this/#findComment-662908 Share on other sites More sharing options...
Lamez Posted October 11, 2008 Author Share Posted October 11, 2008 Wow that worked wonders, thank you so much, here is how I used that code: <?php //begin checking for blacklisted... //$par = parse_url($n_url); //$n_url = $par['host'];//grab base url $n_url = addwww($n_url);//add www //$n_url = addPro($n_url);//add http:// $string = $_POST['string']; $sql = mysql_query("SELECT * FROM `blacklist` WHERE `url`='".$n_url."'"); $r = mysql_fetch_array($sql); if (mysql_num_rows($sql) >= 1){ $_SESSION['o_url'] = $r['url']; header("Location: ?url=".$black); } //end check, everything cleared... ?> Link to comment https://forums.phpfreaks.com/topic/128019-solved-best-way-to-do-this/#findComment-662917 Share on other sites More sharing options...
smithmr8 Posted October 11, 2008 Share Posted October 11, 2008 No Problem. Link to comment https://forums.phpfreaks.com/topic/128019-solved-best-way-to-do-this/#findComment-662922 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.