Jump to content

Recommended Posts

Almost all of my php pages include many instances where a sql connection is needed. To keep myself from having to keep coding the SQL stuff I run the connection within the header of the page and close the connect at the footer. By doing this am I opening up myself to a security problem. In my mind I am not, but the books I have seem to close the sql connect before HTML begins. My problem is that inside the HTML I need a database connection to pull information from the database. Just wondering I guess.

Link to comment
https://forums.phpfreaks.com/topic/82146-solved-quick-security-question/
Share on other sites

I don't think there's a security problem there.  Just make sure you sanitize any user provided data that goes into database queries.  There's no need to close the connection early for security (though it's often good for performance reasons).

Thanks, that is all I needed to know. The only information that goes into the database that is user supplied are when they register, leave comments, or modify their account settings. Which in that case it goes through very tight processing to make sure the data supplied isn't dangerous in any way.

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.