Ask a Question related to PHP Development, Design and Development.
-
Ralph Freshour #1
Search & Replace Function?
I have some textfield that users will enter data into on my web site
and then I'll use php and write it to mysql - for security purposes,
is there a function or way to make sure that they only enter in alpha
and numeric data?
Thanks...
Ralph Freshour Guest
-
Search and replace
I'm certain this has been asked 1000 times.. however ... I recently imported some data - all INTs ... from an excel sheet, but the damn thing... -
Search and Replace - Best Approach
Hundreds of HTML file are generated by a program that includes in every file big chunks of comments, unused DHTML and Javascript functions. Always... -
Search and replace (super global replace)
I am using the 30 day trail of acrobate professional....before I buy it I have a few questions.... 1) is there a "search and replace" function... -
search an replace
Hi This scripts sucks in a 109mb file and i'm trying to do a search and replace on unxtime to the format from strftime. Which is working... ... -
search replace
Hi , How do I search replace text in a file from a perl script. i.e. by opening the file in write mode and then do a search replace. I don't... -
Erwin Moller #2
Re: Search & Replace Function?
Ralph Freshour wrote:
yes, check all the characters.> I have some textfield that users will enter data into on my web site
> and then I'll use php and write it to mysql - for security purposes,
> is there a function or way to make sure that they only enter in alpha
> and numeric data?
>
> Thanks...
You can use a regular expression, or make your own little routine.
In case of a regex, ask somebody else. I never took the time to study them,
but know they are extremely powerfull once you get to know them.
In case of your own little routine:
just walk through the whole string and get a character at a time.
Check if the character is in a string with 'acceptable characters'
AcceptableCharacters = "abcdefghijklmnopqrstuvwxyz _1234567890-";
use strlen to get the length of any string.
use strrpos to find an occurence of any string in another string. It returns
false when not found.
use substr to get a character (or more) out of a string.
You'll have to code the rest. :-)
Good luck,
Erwin
Erwin Moller Guest
-
Tom Thackrey #3
Re: Search & Replace Function?
On 16-Sep-2003, Ralph Freshour <ralph@primemail.com> wrote:
if (preg_match('/[^0-9a-z]/i',$input_string))> I have some textfield that users will enter data into on my web site
> and then I'll use php and write it to mysql - for security purposes,
> is there a function or way to make sure that they only enter in alpha
> and numeric data?
// bad string
else
// good string
--
Tom Thackrey
[url]www.creative-light.com[/url]
Tom Thackrey Guest
-
-
Randell D. #5
Re: Search & Replace Function?
"Ralph Freshour" <ralph@primemail.com> wrote in message
news:va7emv0seqvdutqp0qvomqemk413u1as61@4ax.com...You could just use htmlentities() and/or htmlspecialchars() and/or> I have some textfield that users will enter data into on my web site
> and then I'll use php and write it to mysql - for security purposes,
> is there a function or way to make sure that they only enter in alpha
> and numeric data?
>
> Thanks...
>
addslashes() or eregi_replace() (though the latter depends on regular
expressions and thats not the easiest to use).
Randell D. Guest
-
Randell D. #6
Re: Search & Replace Function?
"Ralph Freshour" <ralph@primemail.com> wrote in message
news:va7emv0seqvdutqp0qvomqemk413u1as61@4ax.com...Try this> I have some textfield that users will enter data into on my web site
> and then I'll use php and write it to mysql - for security purposes,
> is there a function or way to make sure that they only enter in alpha
> and numeric data?
>
> Thanks...
>
<?
$string="asbjhda12341dAsdf=a-!scda sd";
preg_match_all ("([[:alnum:]]+)", $string,$regs);
$c=implode("",$regs[0]);
print("$string = $c");
?>
The output should be
asbjhda12341dAsdf=a-!scda sd = asbjhda12341dAsdfascdasd
Note - it literally only returns alpha numeric - No periods, spaces,
apostraphes or anything else...
Randell D. Guest



Reply With Quote

