Jump to content

sanitizing form data with PHP for MYSQL


woocha

Recommended Posts

You should use mysql_real_escape_string() when inserting data into a mysql database. Tags don't mean anything to the database. You may want to use strip_tags() or htmlentities() when display data back to the screen so th browsers don't try to interpret the data as HTML.

 

Ken

Link to comment
Share on other sites

I tried this bit of code and it returned empty

$string = mysql_real_escape_string($string);

 

did I do something wrong?

 

If you are not using mysql_real_escape_string is it working????

 

if so then check your php version if not wrong then this is working in >=4.3 version of PHP.

 

Regards

Link to comment
Share on other sites

If you want something that will help you create secure forms with little coding effort, you should check out the pear html quickform class. There is a great tutorial here that shows you how to do it.

 

Only setback is that it outputs everything in tables.

Link to comment
Share on other sites

Ken is right. I wouldn't worry about learning a class to handle this, because...

 

1) there are really only like three functions you need to use

2) you should understand the principles behind it

3) if you freelance, or work in a team, or use code other people have written, it's probably going to be done the 'basic' way

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.