Hi Guys,
I'm new to php and have come up with what I think is how you're supposed to check for valid data.
Can you please tell me if I'm on the right track, and if I'm missing anything from this example:
formfield1 id='name'
formfield2 id='pass'
$name = getElementByID('name')
$pass = getElementByID('pass')
$cleaner-name = stripslashes($name)
$cleanest-name = mysql_real_escape_string($name)
$cleaner-pass = stripslashes($pass)
$cleanest-pass = mysql_real_escape_string($pass)
$some-pattern = test
if(!eregi($some-pattern,$cleanest-name))
give error message
else
enter into database
In other words, there are 2 form fields, both with their own id's, ("name" and "pass"). I assign them to variables "$name" and "$pass". I know I've kind of mixed in php and javascript, so if someone can tell me how to get a css id with php I'd really appreciate it.
I pass both variables through stripslashes(), and mysql_real_escape_string() to ensure that any malicious code wont hurt the website.
Then I compare the resulting values against my pattern to ensure that they're valid.
If it's valid, it gets put into the database, if it's not, the user get's an error.
Is there anything I've missed?








Bookmarks