dezkit Posted May 10, 2008 Share Posted May 10, 2008 <form action="<? $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td>Something: <td><input type="text" name="something"> </table> </form> ? Quote Link to comment Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 $something = str_replace('"', '', $_POST['something']); $something = str_replace("'", '', $something); Quote Link to comment Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 where do you put that Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 11, 2008 Share Posted May 11, 2008 You apply it to the input. And I'm going to make it even easier. $quotes = array("\"", "'"); $cleaninput = str_replace($quotes, "", $_POST['something']); Quote Link to comment Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 i still don't get it, lmfao Quote Link to comment Share on other sites More sharing options...
DarkWater Posted May 11, 2008 Share Posted May 11, 2008 Huh? What do you mean? You have 270+ posts, so I'll assume that you know how to handle form data...You want the receiving script to remove the quotes, correct? Or do you just want them to not be allowed in the text box? That'll be Javascript. Quote Link to comment Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 ahh, yeahh, javascript thanks lol Quote Link to comment Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 bump, if anyone knows the code Quote Link to comment Share on other sites More sharing options...
networkthis Posted May 11, 2008 Share Posted May 11, 2008 as stated above you could use the str_replace() Function or if you want to allow only certain characters to come through in the fields you can try the following $strip_message = $_POST['something']; $message = ereg_replace("[^A-Za-z0-9]", "", $strip_message ); This will only allow the characters A-Z a-z and the numbers 0-9 to come through on your fields, give it a try, if you need you can add more things to allow to not be stripped just add them in Quote Link to comment Share on other sites More sharing options...
mlin Posted May 11, 2008 Share Posted May 11, 2008 dude, you don't want any quotes in the posted data. We've already posted the code to strip any quotes from the strings that your user posts. I'll try to break it down one more time. your html form has an input with name='something' like your example above once that form is submitted, you need to get the post with the name something $something = $_POST['something']; now you want to strip single quotes from the string $something = str_replace("'", '', $something); now you still need to strip double quotes $something = str_replace('"', '', $something); does that help man? Quote Link to comment Share on other sites More sharing options...
networkthis Posted May 11, 2008 Share Posted May 11, 2008 <?php $strip_something = $_POST['something']; $something = ereg_replace("[^A-Za-z0-9]", "", $something ); ?> <form action="<? $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td>Something: <td><input type="text" name="something" value="<?php echo $something; ?>" > </table> <input name="submit" type="submit" value="Submit" /> <input id="button2" type="reset" value="Reset" /></form> Quote Link to comment Share on other sites More sharing options...
networkthis Posted May 11, 2008 Share Posted May 11, 2008 Or as stated twice now by mlin You can simply use the str_replace function and strip the varialbe $something. You must have the value set to value="<?php echo $something; ?>" Good Luck!!!!!!! <?php $something = str_replace("'", '', $something); $something = str_replace('"', '', $something); ?> <form action="<? $_SERVER['PHP_SELF']; ?>"> <table> <tr> <td>Something: <td><input type="text" name="something" value="<?php echo $something; ?>" > </table> <input name="submit" type="submit" value="Submit" /> <input id="button2" type="reset" value="Reset" /></form> Quote Link to comment Share on other sites More sharing options...
redarrow Posted May 11, 2008 Share Posted May 11, 2008 <?php $strip_something = ' "john""""" """"'; $something = preg_replace("/[^A-Za-z0-9]/", "", $strip_something ); echo $something; ?> Quote Link to comment 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.