Jump to content

PHP Security? (Standard Sanatise Code)


justlukeyou

Recommended Posts

I am currently working on my PHP/MySQL driven website.  However, I have read in recent weeks that there are a number of security measures which need to be taken and one of them is sanitising input to prevent html/MySQL injection into a database.  So I was wondering if there is an 'industry standard' for sanitising PHP.  For example, if a website only want there database to be searched by letters or numbers do they use a specific code?  I have found one based on numbers (for ID numbers) but I cant find on one based on letters.

 

I found this but it is quite complicated and looks very different to the guide I found on YouTube.  so is there an industry standard which blocks people using any other code than numbers or letters?

 

http://bobby-tables.com/php.html

 

I was also wondering is there are anyother security measures I need to be aware of when using PHP?

Link to comment
Share on other sites

There's lots of different ways to sanitize user input.

 

For your specific examples, look at the ctype functions to check if the user enters the correct data. For example, ctype_alpha will return false with anything but letters, while ctype_alnum lets you use letters and numbers (and not things like symbols).

For numbers, is_numeric would be a good test, or you could simply type cast it as an (int).

 

ctype_alpha

ctype_alnum

is_numeric

Integer type casting

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.