Log in

View Full Version : Creating a Registration form



arsenalbates
01-25-2011, 06:07 PM
Hi, I have a simple login and logout system but I want the users to be able to register themselves onto the database.

I have looked at some code to do this but none of it works as im fairly new to PHP.

I am getting error "Column count doesn't match value count at row 1"



This is the action php code



<?PHP
// register2.php
include("config.inc");
$errors = "";
if (!isset($_POST['username']))
$errors .= "Please provide a username. <br/>";
if (!isset($_POST['password']))
$errors .= "Please provide a password. <br/>";
if ($errors == "") {
mysql_query("INSERT INTO user_list VALUES(
'',
'".addslashes($_POST['username'])."',
'".md5($_POST['password'])."',
'".time()."'
)") or die(mysql_error());
echo "Registration Successful!";
} else {
echo $errors."Please go back and try again.";
}
?>


and this is the user interface code




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>

<!-- Register Page -->
<form method="post" action="reg2.2.php">
Username<br/><input type="text" name="username" maxlength="20" /><br/>
Password<br/><input type="password" name="password" /><br/>
<input type ="submit" />
</form>


</body>
</html>

prasanthmj
01-26-2011, 04:05 PM
The tutorials below will be useful
Making a login form using PHP (http://www.html-form-guide.com/php-form/php-login-form.html)


registration form using PHP (http://www.html-form-guide.com/php-form/php-registration-form.html)

mehran
01-28-2011, 05:46 AM
i thing you follow the w3school website which give you the step by step form geration or dani web solutions