fm1 Posted January 4, 2008 Share Posted January 4, 2008 hi guys im noobie and very new to php, im trying to learn php on my own seeing that I dont have the funds to attend any lessons. I need to create a webform, but firstly i need to create a table in mysql, im struggling for 2days now, how do i do this what i done so far, 1. logged into mysql(obv) 2.created the database called members what i need is a table called dbUsers with the following fields: username password verify password email address mobile from there i need to access this database using a php script(dont know what to do here) so that users can access the webform and fill in the details any help on this guys Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/ Share on other sites More sharing options...
Ken2k7 Posted January 4, 2008 Share Posted January 4, 2008 wow...that's a lot of stuff. To create a table, you just run this: <?php // change data below mysql_connect("host_name","database_username","database_password"); mysql_select_db("database_name"); // you don't need verify_password to be honest $tbl = "CREATE TABLE dbUsers( username varchar(255) NOT NULL default '', password varchar(32) default NULL, verify_password varchar(32) default NULL, email varchar(150) NOT NULL default '', mobile varchar(11) default NULL )"; mysql_query($tbl) or die(mysql_error()); ?> I don't know what you mean by accessing the database. What kind of webform? Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430211 Share on other sites More sharing options...
fm1 Posted January 4, 2008 Author Share Posted January 4, 2008 that was a quick reply you see, i need to able to open the form in a web browser, but obv in order to do that you need to compile a php script, what should my script look like Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430212 Share on other sites More sharing options...
nezbo Posted January 4, 2008 Share Posted January 4, 2008 probably the easyest way to edit a database is using myphpadmin it is a free download, and it is a good admin thing. Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430213 Share on other sites More sharing options...
fm1 Posted January 4, 2008 Author Share Posted January 4, 2008 probably the easyest way to edit a database is using myphpadmin it is a free download, and it is a good admin thing. i have phpmyadmin but why would i need to edit the database if it was already created with the above table statement, all I need now is to publish this database in a php script so that it can be used Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430220 Share on other sites More sharing options...
Ken2k7 Posted January 4, 2008 Share Posted January 4, 2008 that was a quick reply you see, i need to able to open the form in a web browser, but obv in order to do that you need to compile a php script, what should my script look like Well the server compiles a php script. ??? Um, just tell me what the form should do. For php files, you have to open it with <?php and close with ?>. The filename needs the extension .php And what do you mean publish it? Example please Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430221 Share on other sites More sharing options...
fm1 Posted January 4, 2008 Author Share Posted January 4, 2008 okay basically what i mean is , now that I got the databse created with the tables,the sql part is done, now i want to create a new php script, and when i open up that script in my browser the follwing script i created should open with the following fields to fill in and submit username: password: verifypassword: email address: mobile: then the visitor should type in their details and click submit, then those details should go to the admins email address, in other words its a web form whereby the data should be retrieved, stored,updated and editted by the mysql database members that I created earlier. is this info im giving sounding dumb, if yes can you guys offer a better solution to the problem Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430231 Share on other sites More sharing options...
Ken2k7 Posted January 4, 2008 Share Posted January 4, 2008 okay basically what i mean is , now that I got the databse created with the tables,the sql part is done, now i want to create a new php script, and when i open up that script in my browser the follwing script i created should open with the following fields to fill in and submit username: password: verifypassword: email address: mobile: then the visitor should type in their details and click submit, then those details should go to the admins email address, in other words its a web form whereby the data should be retrieved, stored,updated and editted by the mysql database members that I created earlier. is this info im giving sounding dumb, if yes can you guys offer a better solution to the problem Kinda a lot to ask but try this: <?php if (isset($_POST['submit'])){ $uname = mysql_escape_string($_POST['uname']); $pass = mysql_escape_string($_POST['pass']); $ver_pass = mysql_escape_string($_POST['vpass']); $email = mysql_escape_string($_POST['email']); $mobile = mysql_escape_string($_POST['mobile']); if ($pass == $ver_pass){ // need help here. What should the message be? $msg = ""; // edit in admin email mail("admin_email", "subject", $msg); }} <form method='post'> <input type='text' name='uname' /><br /> <input type='password' name='pass' /><br /> <input type='password' name='ver_pass' /><br /> <input type='text' name='email' /><br /> <input type='text' name='mobile' /><br /> <input type='submit' name='submit' value='submit' /> </form> ?> Something like that? Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430238 Share on other sites More sharing options...
fm1 Posted January 4, 2008 Author Share Posted January 4, 2008 I see where you coming at but is this script somhow connected to the mysql database "members" ,this is the original project details if it might help, you script looks like a standlone form,am i wrong Code an php web form . The form must accept and store a user's details. It must then retrieve/update/edit those details from the SQL DB and display it. Some of the fields will include: username password verify password email address mobile Please note: Validation is required on all fields Access must be through stored procedures No SQL allowed in code Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430248 Share on other sites More sharing options...
Ken2k7 Posted January 4, 2008 Share Posted January 4, 2008 I see where you coming at but is this script somhow connected to the mysql database "members" ,this is the original project details if it might help, you script looks like a standlone form,am i wrong Code an php web form . The form must accept and store a user's details. It must then retrieve/update/edit those details from the SQL DB and display it. Some of the fields will include: username password verify password email address mobile Please note: Validation is required on all fields Access must be through stored procedures No SQL allowed in code Dude, unless you haven't noticed, this forum is for support. We don't write stuff for you. Read the guidelines. You can start something and ask for help, but asking us to write an entire system to your liking is against the rules. I'm sorry, I didn't make the guidelines. 2. Don't ask someone to write or re-write a script for you, unless you are posting a message to the PHPFreelancing Forum. The forums are not the place to request XYZ script. This is a community of people learning PHP, and not a script location service. Try searching sourceforge, phpclasses, hotscripts, or Google. http://www.phpfreaks.com/forums/index.php/topic,6264.0.html Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430264 Share on other sites More sharing options...
fm1 Posted January 4, 2008 Author Share Posted January 4, 2008 I dont need you to write the whole script,i need guid lines,u didnt know what i meant so I posted what im trying to do,how do i recall the information from an sql databse i created so that its displayed as a form in the web webrowser, Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430318 Share on other sites More sharing options...
fm1 Posted January 4, 2008 Author Share Posted January 4, 2008 okay basically what i mean is , now that I got the databse created with the tables,the sql part is done, now i want to create a new php script, and when i open up that script in my browser the follwing script i created should open with the following fields to fill in and submit username: password: verifypassword: email address: mobile: then the visitor should type in their details and click submit, then those details should go to the admins email address, in other words its a web form whereby the data should be retrieved, stored,updated and editted by the mysql database members that I created earlier. is this info im giving sounding dumb, if yes can you guys offer a better solution to the problem Kinda a lot to ask but try this: <?php if (isset($_POST['submit'])){ $uname = mysql_escape_string($_POST['uname']); $pass = mysql_escape_string($_POST['pass']); $ver_pass = mysql_escape_string($_POST['vpass']); $email = mysql_escape_string($_POST['email']); $mobile = mysql_escape_string($_POST['mobile']); if ($pass == $ver_pass){ // need help here. What should the message be? $msg = ""; // edit in admin email mail("admin_email", "subject", $msg); }} <form method='post'> <input type='text' name='uname' /><br /> <input type='password' name='pass' /><br /> <input type='password' name='ver_pass' /><br /> <input type='text' name='email' /><br /> <input type='text' name='mobile' /><br /> <input type='submit' name='submit' value='submit' /> </form> ?> Something like that? with the above script results return syntax error in line 17 Quote Link to comment https://forums.phpfreaks.com/topic/84450-php-mysql/#findComment-430343 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.