Jump to content

registration form / sign up form


dazz_club

Recommended Posts

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

<?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

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

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...