dazz_club Posted October 27, 2006 Share Posted October 27, 2006 sign up formswhat would the command/s or sql look like for sign up form for inserting new members into a database (mysql)?i want to create one so i can learn how to do it?any help would be greatcheers Link to comment Share on other sites More sharing options...
aspnetguy Posted October 27, 2006 Share Posted October 27, 2006 INSERT INTO tablname (column1,column2,...)VALUES('value1','value2',...) Link to comment Share on other sites More sharing options...
dazz_club Posted October 27, 2006 Author Share Posted October 27, 2006 sorry my mistake, i wasnt clear.On most websites, they have a sign up form. my question is how do they use php and sql to insert it into a database, such as their name, age, address, etccheerssorry for not being clear Link to comment Share on other sites More sharing options...
aspnetguy Posted October 27, 2006 Share Posted October 27, 2006 <?php$db = mysql_connect('server','username','password');if(!$db) die('Could not connect to database server! ' . mysql_error());mysql_select_db('dbname') or die('Could not connect ot database! ' . mysql_error());mysql_query("INSERT INTO........");mysql_close($db);?> does that help? Link to comment Share on other sites More sharing options...
jblack Posted October 27, 2006 Share Posted October 27, 2006 here's a little better example...Use this to create your table: CREATE TABLE `members` (`id` INT( 5 ) NOT NULL AUTO_INCREMENT ,`username` VARCHAR( 20 ) NOT NULL ,`password` VARCHAR( 20 ) NOT NULL ,PRIMARY KEY ( `id` ) ) TYPE = MYISAM; Here's the registration code: <?php// Made by Jeremy Black. Put my name in this if you use it.$mysql_user = 'user';$mysql_pass = 'pass';$mysql_host = 'host';$connect = mysql_connect($mysql_host,$mysql_user,$mysql_pass) or die("Could not connect. " . mysql_error());$db_select = mysql_db_select($mysql_user, $connect) or die("Could not select database. " . mysql_error());$page = $_POST['page'];if($page != 1) {?><html> <head> <title>Registration</title> </head> <body> <table align="center" width='50%'> <th><center><b>Register</b></center></th> <tr> <td> <pre><form method="POST">Username: <input type="text" name="username">Password: <input type="password" name="password">Verify Password: <input type="password" name="vpassword"></form><input type="hidden" name="page" value="1"> </pre><?php}else {?><html> <head> <title>Registration</title> </head> <body> <table align="center" width='50%'> <th><center><b>Register</b></center></th> <tr> <td><?php$username = $_POST['username'];$password = $_POST['password'];$vpassword = $_POST['vpassword'];if($username == '' || $password == '' || $vpassword == '') { echo "All fields are required!"; echo " <a href=java script:history.go(-1)>Click Here</a> to go back.";}if($password != $vpassword) { echo "Passwords do not match!"; echo " <a href=java script:history.go(-1)>Click Here</a> to go back.";}else { $query = "INSERT into members id,username,password VALUES ('','$username','$password'); $result = mysql_query($query) or die("Could not run query. " . mysql_error()); echo "You have successfully registered! <a href='login.php'>Click here</a> to login.";}?> </td> </tr> </table> </body></html> Link to comment Share on other sites More sharing options...
mikemanx2 Posted December 7, 2006 Share Posted December 7, 2006 Thx Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now