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> ? Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/ 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); Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-537938 Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 where do you put that Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-537947 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']); Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-537951 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 Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-537953 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. Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-537959 Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 ahh, yeahh, javascript thanks lol Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-537961 Share on other sites More sharing options...
dezkit Posted May 11, 2008 Author Share Posted May 11, 2008 bump, if anyone knows the code Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-538056 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 Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-538066 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? Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-538069 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> Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-538074 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> Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-538075 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; ?> Link to comment https://forums.phpfreaks.com/topic/105082-remove-quotes-from-submited-in-forms/#findComment-538083 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.