Hey, could someone help me with login script ? I've got registration script.
It contains 3 files:
reg.php
<?php
require_once 'database.php';
?>
<h1><strong>Register</strong></h1>
<form name="register" method="post" action="regcheck.php">
<label>
<input type="text" name="user" id="user"> Username<br />
</label>
<br />
<label>
<input type="password" name="pass" id="pass"> Password<br />
</label>
<br />
<label>
<input type="text" name="email" id="email"> Email<br />
</label>
<label>
<input type="submit" name="reg" id="reg" value="Register">
</label>
</form>
regcheck.php
<?php
$email = $_POST['email'];
if(
isset( $_POST['user'] ) &&
isset( $_POST['pass'] ) &&
isset( $_POST['email'] )
)
{
if( strlen( $_POST['user'] ) < 4 )
{
echo "Username is too short";
}
elseif( strlen( $_POST['pass'] ) < 4 )
{
echo "Password is too short";
}
elseif(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
echo "Bad email address";
}
elseif( $_POST['pass'] == $_POST['user'] )
{
echo"Username and password can't be the same";
}
else
{
include( 'database.php' );
$username = mysql_real_escape_string( $_POST['user'] );
$password = mysql_real_escape_string( $_POST['pass'] );
$email = mysql_real_escape_string( $_POST['email'] );
$sqlCheckForDuplicateN = "SELECT username FROM user WHERE username = '". $username ."'";
$sqlCheckForDuplicateE = "SELECT email FROM user WHERE email = '". $email ."'";
if( mysql_num_rows( mysql_query( $sqlCheckForDuplicateE ) ) == 0 && mysql_num_rows( mysql_query( $sqlCheckForDuplicateN ) ) == 0 )
{
$sqlRegUser = "INSERT INTO
user( username, password, email )
VALUES(
'". $username ."',
'". $password ."',
'". $email ."'
)";
if( !mysql_query( $sqlRegUser ) )
{
echo "You Could Not Register Because Of An Unexpected Error.";
}
else
{
echo "You Are Registered And Can Now Login";
}
}
elseif( !(mysql_num_rows( mysql_query( $sqlCheckForDuplicateE ) ) == 0))
{
echo "The Email You Have Entered Is Already Being Used. Please Try Another One.";
}
elseif( !(mysql_num_rows( mysql_query( $sqlCheckForDuplicateN ) ) == 0))
{
echo "The Username You Have Entered Is Already Being Used. Please Try Another One.";
}
elseif( !(mysql_num_rows( mysql_query( $sqlCheckForDuplicateE ) ) == 0) && !(mysql_num_rows( mysql_query( $sqlCheckForDuplicateN ) ) == 0))
{
echo "The Email and Username You Have Entered Is Already Being Used. Please Try Another One.";
}
}
}
else
{
echo "You Could Not Be Registered Because Of Missing Data.";
}
?>
database.php
<?
$con = mysql_connect('host','username','password');
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db('dbname');
?>
So could someone help me with login ???