Dear friends
I am creating a php login/register form to register and authenticate users.My problem is that the form does not submit the data in the form to the database.Please see the code below:
<?Php
session_start();
/****************/
//original Amaina......slowly coming of age//
include 'dayta.php';
//connect
$link = mysql_connect($database_host, $database_user, $database_password);
mysql_select_db($database_name,$link);
//
if (isset($_POST['submit'])) {
//
$username = $_POST["username"];
$password = $_POST["password"];
$password2 = $_POST["password2"];
$passwordhash = md5($password);
$encoded_username = urlencode($username);
//ogopa sql injection...the thought of sql injection sends a brrrr down my spine
$encoded_username= stripslashes($encoded_username);
$passwordhash = stripslashes($passwordhash);
$encoded_username = mysql_real_escape_string($encoded_username);
$passwordhash = mysql_real_escape_string ($passwordhash);
//
if (empty($encoded_username) || empty($password) || empty($password2)){
die ('You have to enter all details');
}
//Check for duplicate usernames
if (!get_magic_quotes_gpc()) {
$_POST['username'] = addslashes($_POST['username']);
}
$usercheck = $_POST['$encoded_username'];
$check = mysql_query("SELECT username FROM users WHERE username = '$usercheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//
if ((strstr($encoded_username, "%") && !strstr($encoded_username, "%40")) || strstr($encoded_username, "+")
|| !strstr($encoded_username, "%40")) {
die ('<H>Invalid email address!</H>');
}
//
$query ="SELECT username FROM users where username ='$username' LIMIT 1";
$result1 = mysql_query($query,$link) or die(mysql_error());
$rows = mysql_num_rows($result1);
//
if ($rows ==0){
('Sorry!Email address has been used by another person');
$query1 = "INSERT INTO users(username,Password) VALUES('$username','$passwordhash')";
$result = mysql_query($query1,$link) or die(mysql_error());
echo 'Welcome to E-ris';
echo 'gg';
}
//if ($rows ==1){
//echo 'username already in use';
//}
?>
<?php
}
else {
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br>
Email:<div><input type="text" size="20" maxlength="40" name="username"></div>
Password:<div> <input type="password" size="20" maxlength="10" name="password"></div>
Confirm Password:<div><input type = "Password" size "10" maxlength = "10" name = "password2"></div><P></P><br>
<input type="submit" value="Register">
</form
<?Php
}
?>
Please help
:?:
Amaina