verdrm Posted August 14, 2007 Share Posted August 14, 2007 Hi Everyone, I have two issues. They are probably really simple but I'm stuck. 1. I want to block the input of certain text into a MySQL table coming from a text field. When the user submits the form, I need something that can check the form field, and if the text matches what I want to block, it gives them an error. So, if they type "Quizno's", the PHP page with the INSERT INTO code would stop "Quizno's" from being inserted. Can anyone post the PHP for that? 2. I also want the above code to block names with apostrophes. I have tried \'s and some other things in my IF statement. See example below: if ($restaurant=="Quizno's") echo "Restaurant not allowed due to the policy of your organization."; I can't seem to get the IF statement working with apostrophes. Does anyone know the solution for that? Quote Link to comment https://forums.phpfreaks.com/topic/64955-two-problems/ Share on other sites More sharing options...
Barand Posted August 15, 2007 Share Posted August 15, 2007 Apostrophes should be no problem if handled correctly. If magic_quotes is ON they will be escaped automatically for you so you need to be aware of the added backslash <?php if ($_POST['restaurant'] == "Quinzo\'s") echo "Match"; else echo "No match"; ?> <form method='post'> <input type="text" name="restaurant" value="Quinzo's"> <br/> <input type="submit" name="sub" value="Click me"> </form> Quote Link to comment https://forums.phpfreaks.com/topic/64955-two-problems/#findComment-324146 Share on other sites More sharing options...
verdrm Posted August 15, 2007 Author Share Posted August 15, 2007 Thanks, but that doesn't really resolve either one of my questions. I want to stop the user from inserting "Quizno's" into the database, not echo whether they do or not. This "Quinzo\'s" does not work for me as far as showing the apostrophe. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/64955-two-problems/#findComment-324160 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.