Forums
This topic is locked
User Authentication forms
Posted 15 Feb 2005 08:25:50
1
has voted
15 Feb 2005 08:25:50 alghameh alghameh posted:
Hello FirendsI have problem about this codes
The problem is that ,When I fill blnks in register form,and then press enter information,It does not return to login,why?
Thanks
<?
include 'db.php';
// Define post fields into simple variables
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_address = $_POST['email_address'];
$username = $_POST['username'];
$password=$_POST['password'];
/* Let's strip some slashes in case the user entered
any escaped characters. */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$email_address = stripslashes($email_address);
$username = stripslashes($username);
$password=stripslashes($password);
/* Do some error checking on the form posted fields */
if((!$first_name) || (!$last_name) || (!$email_address) ||(!$password)|| (!$username)){
echo 'You did not submit the following required information! <br />';
if(!$first_name){
echo "First Name is a required field. Please enter it below.<br />";
if(!$last_name){
echo "Last Name is a required field. Please enter it below.<br />";
}
if(!$email_address){
echo "Email Address is a required field. Please enter it below.<br />";
}
if(!$username){
echo "Desired Username is a required field. Please enter it below.<br />";
}
if ($password){echo "Desired Username is a required field. Please enter it below.<br />";
}
include 'register.html'; // Show the form again!
/* End the error checking and if everything is ok, we'll move on to
creating the user account */
exit(); // the error checking has failed, we'll exit the script!
}
$sql_email_check = mysql_query("SELECT email_address FROM A
WHERE email_address='$email_address'"
$sql_username_check = mysql_query("SELECT username FROM A
WHERE username='$username'"
$email_check = mysql_num_rows($sql_email_check);
$username_check = mysql_num_rows($sql_username_check);
if(($email_check > 0) || ($username_check > 0)){
echo "Please fix the following errors: <br />";
if($email_check > 0){
echo "<strong>Your email address has already been used by another member
in our database. Please submit a different Email address!<br />";
unset($email_address);
}
if($username_check > 0){
echo "The username you have selected has already been used by another member
in our database. Please choose a different Username!<br />";
unset($username);
}
include 'register.html'; // Show the form again!
exit(); // exit the script so that we do not create this account!
}
mysql_selcet_db("A"
$test="INSERT INTO A (first_name, last_name,
email_address, username, password)
VALUES('$first_name', '$last_name', '$email_address',
'$username', '$password')";
$sql=mysql_query($test);
if(!$sql){
echo 'There has been an error creating your account. Please contact the webmaster.';}
else{include 'login.html';
exit();}
}
<HTML><style type="text/css">
<!--
body {
background-color: #3399FF;
}
-->
</style>
<div align="center">
<h1>login<h1>
</div>
<form method=post action="loginend.php" >
<div align="center">
<table bgcolor="#009933">
<tr>
<td>username</td>
<td><input type=text name=username></td>
</tr>
<tr>
<td>password</td>
<td><input type=password name=password></td>
</tr>
<tr>
<td colspan=2 align=center> <input type=submit value=Enter></td>
</tr>
</table>
</div>
</form>
</HTML>
<html>
<style type="text/css">
<!--
body{background-color: #3399ff;}
-->
</style>
<div align="center">
<h1><font color="#ff9900">registern</font></h1>
</div>
<center><form method="post" action="register.php" id="fo">
<table bgcolor="#00FF00">
<tr>
<td>username</td>
<td><input type="text" name="username" id="id"></td>
</tr>
<tr>
<td> first_name</td>
<td><input type="text" name="first_name"></td>
</tr>
<tr>
<td>last_name</td>
<td><input type="text" name="last_name"></td>
</tr>
<tr>
<td>password</td>
<td><input type="text" name="password"></td>
</tr>
<tr>
<td>email</td>
<td><input type="text" name="email_address"></td>
</tr>
<tr>
<td></td>
<td align=center><input type="submit" name="submit" value="Enter Information"></td>
</tr>
</table></form> </center>
</html>
Edited by - abalfazl on 15 Feb 2005 13:37:53