Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
some form data not being posted to db
Old 10-11-2010, 09:29 PM some form data not being posted to db
Junior Talker

Posts: 1
Name: robert
Trades: 0
Hi,
I'm pretty new to this, so please bear with me if this is a completely niave question. I have set up a webspace which requires users to first register and login prior to entering or downloading from a mysql database. I have it set up in sessions, using the $_POST method for transferring the data from the form to the database.

Anytime I have posted data, or tested the system, it works fine. Occasionally, a blank record shows up in the database though and I don't know where these come from. I thought it had to do with the user not accepting cookies, but if I turn cookies off, I am unable to login and therefore unable to access the data entry forms. There are pre-filled fields that cannot be blanked out, so all the data is being lost somewhere between the entry and the post, but I can't figure out where. Has anyone run into this before? Any suggestions on where i might have a hole in my code? any thoughts at all would be appreciated. Right now I can't even track the user to see who posted the blank record, so can't troubleshoot it properly. HELP :-?
Thanks in advance,
Skraf
skrafner is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-12-2010, 07:34 AM Re: some form data not being posted to db
Novice Talker

Posts: 8
Name: Massimo
Trades: 0
You should always check and make safe the POST variables before submitting into DB, and do that always in PHP, the first rule is to never trust users.

This is a good function you can use:

function MakeSafe($unsafestring) {
if (!
get_magic_quotes_gpc())
{
return
mysql_escape_string($unsafestring);
}
return
htmlentities($unsafestring);
}


usage:

$myvariable=MakeSafe ($_POST['nameofvariable']);

then, you should check if is empty:

if ($myvariable!='') {

...here you can insert into your DB

}
__________________
Start a
Please login or register to view this content. Registration is FREE
at Logo Arena! Get your custom logo designed by
Please login or register to view this content. Registration is FREE
maxi-72 is offline
Reply With Quote
View Public Profile Visit maxi-72's homepage!
 
Old 10-12-2010, 07:40 AM Re: some form data not being posted to db
Novice Talker

Posts: 8
Name: Massimo
Trades: 0
actually, the form sanitize is a bit more complex you should make some google searches if you want to get better results
I use also htmlpurifier
__________________
Start a
Please login or register to view this content. Registration is FREE
at Logo Arena! Get your custom logo designed by
Please login or register to view this content. Registration is FREE
maxi-72 is offline
Reply With Quote
View Public Profile Visit maxi-72's homepage!
 
Reply     « Reply to some form data not being posted to db
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.17685 seconds with 12 queries