|
Login
<form method="post" action="../include/loginsession.php" name="saveform">
<div>
Username or Email <br /><input type="text" name="emailadd" size="25" value="" />
Password<br /><input type="password" name="userpassword" size="25" value=""/>
<center><br /><input name="userlogin" type="button" value="LOGIN"/></center>
</div>
/////////////////////loginsession.php//////////////////////////
<?php
ob_start();
session_start();
//check that the user is calling the page from the login form and not accessing it directly
if (!isset($emailadd) || !isset($userpassword))
{
header( "Location: ../index.php" );
}
//check that the form fields are not empty, and redirect back to the login page if they are
elseif (empty($emailadd) || empty($userpassword))
{
header( "Location: ../index.php" );
}
else
{
//convert the field values to simple variables
$emailadd = addslashes($_POST['emailadd']);
$pass =addslashes($_POST['userpassword']);
//set the database connection,, connection is working fine
include("connection.php");
$result=mysql_query("select * from userregisteration where email='$emailadd' AND password='$pass'", $connection);
//check that at least one row was returned
$rowCheck = mysql_num_rows($result);
if($rowCheck > 0)
{
//while($row = mysql_fetch_array($result))
{
//start the session and register a variable
session_register('emailadd');
//successful login code will go here...s
header( "Location: ../discoverquestion/discoverquestion.php" );
}
}
else {
//if nothing is returned by the query, unsuccessful login code
//echo 'Incorrect login name or password. Please try again.';
header( "Location: ../index.php" );
}
}
?>
|