Jump to content

Anonymous data entry to mysql table via PHP


xilllly

Recommended Posts

Hi,

I've made a php webform which works fine. I've put that into my website so members can add their details to be become a member of my club. Again that works fine. Only issue is that when members get to the membership page (member_add.php) on my website, members are asked to login as a user. I use a Mysql database on a linux server.

 

How do I set it up (correct php code to use) so members can add their details without having to login or be a guest, or setup a username, i.e. they just put in their details into the webform and it is added to the 'member' table automatically. No login required.

 

Members only have access to member_add.php. After entering their details and pressing "Submit", members are sent to a thank you webpage. Only I have access to the full database.

 

This automatic option is only needed for members to add data to the 'member' table as any other table and associated php page has a login for security reasons. Please note this question is in regard to a internet user, not a lan user.

 

Also I need this to be a secure link to the Mysql database.

 

Hopefully there is an answer to this? Thanks  :confused:

Rather than that, why don't I break my question down to its bare bones.

 

What is the best way to use php to allow internet users to add data to a Mysql database table? Bearing in mind that the internet user shouldn't have to login or click on a guest button to do so. They just click a submit button after having filled in a form on a webpage and info is added to the database.

 

Thanks...

Yes that is true, however whenever I do that, I am asked by Mysql for a database user name and password before the form data is allowed to pass to the database. How can I avoid that request happening, i.e. the form data being added without any login request by Mysql?

 

Thanks

So I just need to delete this part below from the code?

 

// check if logged in

if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Add"))

{

$_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

header("Location: login.php?message=expired");

return;

}

 

  • 2 weeks later...

After much trial & error plus a lot of research, the solution to my problem was to tell the php code to ignore the code that was calling for a database login. I tried deleting that part of the code but the php just won't work then. So by adding /* at the start of the code I wanted to be ignored and */ at the end worked like a dream. Hope this helps someone else.... Xilllly

 

//  check if logged in

 

/*

if(!@$_SESSION["UserID"] || !CheckSecurity(@$_SESSION["_".$strTableName."_OwnerID"],"Add"))

{

  $_SESSION["MyURL"]=$_SERVER["SCRIPT_NAME"]."?".$_SERVER["QUERY_STRING"];

  header("Location: login.php?message=expired");

  return;

}

*/

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.