PHP DATABASE CODE

How to use select /where query for displaying data in at least two html text fields…what is query…
example:mysql_query(“SELECT * FROM Persons
WHERE FirstName=‘Peter’” and lastname=‘smith’); but this query i have to use with html element
example:where firstname=’$_post(‘nm’)
send me reply

this is very bad idea with out sanatizing the post

[php]mysql_query("SELECT * FROM Persons
WHERE FirstName=’$_post(‘nm’)’ and lastname=’$_post(‘ln’)’); [/php]

Better to try and stop people form posting anything they want do some char setting or is_numeric if you want to only have numbers sent add slashes stript tags just to give you some functions to use as examples.

[php]
$name= mysql_escape_string($_post[‘nm’]);
$lastname= mysql_escape_string($_post[‘ln’]);

mysql_query("SELECT * FROM Persons WHERE FirstName=’$name’ and lastname=’$lastname’); [/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service