xilllly Posted June 17, 2011 Share Posted June 17, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/ Share on other sites More sharing options...
trq Posted June 17, 2011 Share Posted June 17, 2011 How exactly do you plan on identifying members without them logging in? Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1230884 Share on other sites More sharing options...
xilllly Posted June 17, 2011 Author Share Posted June 17, 2011 Members don't need to log in again. The webform only serves as a membership form. For my records I'll have their name and address and a membership number that is generated when members join. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1230901 Share on other sites More sharing options...
trq Posted June 17, 2011 Share Posted June 17, 2011 Sorry but your not making allot of sense. You'll need to explain in more detail. Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1230932 Share on other sites More sharing options...
xilllly Posted June 18, 2011 Author Share Posted June 18, 2011 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... Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231313 Share on other sites More sharing options...
trq Posted June 18, 2011 Share Posted June 18, 2011 Simply put a form on a page that submits to a PHP script which then adds the form data to a database. Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231316 Share on other sites More sharing options...
xilllly Posted June 18, 2011 Author Share Posted June 18, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231322 Share on other sites More sharing options...
trq Posted June 18, 2011 Share Posted June 18, 2011 No where will you be asked for a password by Mysql except in your code where you call mysql_connect. Your going to need to post your code as you are obviously way off track somewhere. Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231330 Share on other sites More sharing options...
xilllly Posted June 18, 2011 Author Share Posted June 18, 2011 I had to attach code as it was over the maximum length allowed for a post of 40,000 characters apparently. Please find attached code for customer_add.php Thanks. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231349 Share on other sites More sharing options...
trq Posted June 18, 2011 Share Posted June 18, 2011 Right near the top of that script you are checking to see if the user is logged in. Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231351 Share on other sites More sharing options...
xilllly Posted June 18, 2011 Author Share Posted June 18, 2011 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; } Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231374 Share on other sites More sharing options...
trq Posted June 18, 2011 Share Posted June 18, 2011 There might be a little more to it than that, ie some other parts of the script might relie on you being logged in, but yeah, I'd start there. Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231388 Share on other sites More sharing options...
xilllly Posted June 19, 2011 Author Share Posted June 19, 2011 Ok, Many thanks for you help... I'll see how I go... Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1231615 Share on other sites More sharing options...
xilllly Posted July 2, 2011 Author Share Posted July 2, 2011 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; } */ Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1237555 Share on other sites More sharing options...
trq Posted July 2, 2011 Share Posted July 2, 2011 That has exactly the same effect as removing the code. Quote Link to comment https://forums.phpfreaks.com/topic/239611-anonymous-data-entry-to-mysql-table-via-php/#findComment-1237770 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.