Jump to content

Security Functions


shanejones

Recommended Posts

Ok so I have these 2 functions set up to secure some things

make_safe()

is used before putting anything in the database. the

make_viewable()

function is used to display the data that was made safe.

 

function make_safe($string) { // used before adding to db
return addslashes($string);
}

function make_viewable($string) { // used before displaying anywhere
return stripslashes($string);	
}

 

is this enough or is there anything else to make this secure.

 

Thanks

 

Shane

Link to comment
Share on other sites

for input, if magic quotes is turned on, you'll want to stripslashes() on the input, not add them. then use mysql_real_escape_string() to prepare the value for insertion into the database.

 

for output, you should not be storing extra slashes in your data, so stripslashes() would be incorrect as that would remove slashes that should actually be there.

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.