registration script

Page 1 of 1

5 Replies - 2073 Views - Last Post: 29 March 2015 - 08:55 PM

#1 jamillion  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 83
  • Joined: 23-July 08

registration script

Posted 01 November 2008 - 11:00 PM

Description: you will need mySQL and will need to create a table to store the users information:

CREATE TABLE users (
	id int NOT NULL AUTO_INCREMENT,
	username varchar(250),
	password varchar(50),
	PRIMARY KEY(id)
);

a simple registration script. To make it better add CAPTCHA email verification and anything else.
<?php
	if($_POST) {
		$password = $_POST['password'];
		$confirm = $_POST['confirm'];	
		if($password != $confirm) { ?>
<span style='color:red'>Error: Passwords do not match!</span>		
<?php	} else {
			$dbhost = 'localhost';
			$dbuser = 'user';
			$dbpass = 'pass';
			$dbname = 'name';
			$conn = mysql_connect($dbhost,$dbuser,$dbpass)
				or die ('Error connecting to mysql');
			mysql_select_db($dbname);
			$query = sprintf("SELECT COUNT(id) FROM users WHERE UPPER(username) = UPPER('%s')",
				mysql_real_escape_string($_POST['username']));
			$result = mysql_query($query);
			list($count) = mysql_fetch_row($result);
			if($count >= 1) { ?>
<span style='color:red'>Error: that username is taken.</span>
<?php		} else {
				$query = sprintf("INSERT INTO users(username,password) VALUES ('%s','%s');",
					mysql_real_escape_string($_POST['username']),
					mysql_real_escape_string(md5($password)));
				mysql_query($query);
			?>
<span style='color:green'>Congratulations, you registered successfully!</span>
<?php
			}	
		}
	}
?>
<form method='post' action='register.php'>Username: <input type='text' name='username' />

Password: <input type='password' name='password' />

Confirm Password: <input type='password' name='confirm' />

<input type='submit' value='Register!' />
</form>

This post has been edited by Dormilich: 03 June 2015 - 08:29 AM


Is This A Good Question/Topic? 0
  • +

Replies To: registration script

#2 jamillion  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 83
  • Joined: 23-July 08

Re: registration script

Posted 01 November 2008 - 11:01 PM

Well heres my first snippit i will add a simple login script and a simple logout script later! I hope this helps someone
Was This Post Helpful? 0
  • +
  • -

#3 teemy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 20-November 09

Re: registration script

Posted 20 November 2009 - 04:42 AM

beautifully written
Was This Post Helpful? 0
  • +
  • -

#4 Angelsmadream  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 0
  • Joined: 20-January 11

Re: registration script

Posted 24 January 2011 - 05:32 AM

thanks for sharing.....
Was This Post Helpful? 0
  • +
  • -

#5 phpmyway  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-January 12

Re: registration script

Posted 31 January 2012 - 04:12 AM

looking for similar scripts...
Was This Post Helpful? 0
  • +
  • -

#6 benanamen  Icon User is offline

  • D.I.C Head

Reputation: 13
  • View blog
  • Posts: 119
  • Joined: 28-March 15

Re: registration script

Posted 29 March 2015 - 08:55 PM

This code is obsolete. No one should be using it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1