Jump to content

remove quotes from submited in forms


dezkit

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

<?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
Share on other sites

Or as stated twice now by mlin  8) 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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.