Jump to content

php security.


fredted40x

Recommended Posts

Hi,

 

I have craeted a mini message board using html, php, and AJAX, and now i would like to check that its secure. I would like to get it to prevent hackers and also prevent people stealing php code.

 

Can anyone point me to any sites or give me any tips that i can use.

 

Thank you.

Link to comment
Share on other sites

1. Make sure you validate inputs.

2. If you are dealing with databases, always use mysql_real_escape_string() function. This function properly scrubs your input so it doesn't include invalid characters.

3. Hide your php errors.

4. Make sure to md5 passwords or any vital information.. if you store it into db.

5. Use captcha, it prevents spammers.

 

That's what came into my mind right now. Hope it helps you :)

You can always google, there's a lot to study.

Link to comment
Share on other sites

1. Make sure you validate inputs.

2. If you are dealing with databases, always use mysql_real_escape_string() function. This function properly scrubs your input so it doesn't include invalid characters.

3. Hide your php errors.

4. Make sure to md5 passwords or any vital information.. if you store it into db.

5. Use captcha, it prevents spammers.

 

That's what came into my mind right now. Hope it helps you :)

You can always google, there's a lot to study.

 

Ahhh captcha, good idea. for got about them.

 

 

So far i have md5ds passwords and i have just found the escape_string function on google so will be adding that.

 

Could you explain a little more about how to hid php errors?

 

Thanks again

Link to comment
Share on other sites

Adding below code in your script would never show any php errors to your users. Add it to your code when you are done debugging it.

 

error_reporting(0);  

 

No. That makes sure that no single error is reported meaning that altough your application does not function it also does not show any errors in your error log the correct setting is:

 

error_reporting(E_ALL);
ini_set('display_errors', 1);//1=development, 0=production

 

You also shouldn't set these in your PHP script but in your php.ini. On your development machine display_errors = On and on your production machine display_errors = Off

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.