i have a user login page and php script to check the login credentials with data stored in a database. Everything works fine, i just tried adding a msg box styled with CSS containing the text "wrong email" if login details didn't match the data in the database and it will automatically return to login page.
Unfortunately, the msg is not being echoed and it is returning to login page..
my php code goes like this..
<style>
.alert {
padding: 20px;
background-color: #f44336;
color: white;
}
.closebtn {
margin-left: 15px;
color: white;
font-weight: bold;
float: right;
font-size: 22px;
line-height: 20px;
cursor: pointer;
transition: 0.3s;
}
.closebtn:hover {
color: black;
}
</style
<?php
//15 2 2015
session_start();
$Cser = mysqli_connect("localhost","root","*****","database") or die("Server connection failed : ".mysqli_error($Cser));
$email = $_REQUEST["email"];
$password = $_REQUEST["password"];
$s = "select * from fuser where email='".$email."' and password = '".$password."'";
$result = mysqli_query($Cser,$s);
$count = mysqli_num_rows($result);
if($count>0)
{
$_SESSION["username"] = $username;
$_SESSION["login"]="1";
header("location:../home.php");
}
else
{
echo '<div class="alert">';
echo '<span class="closebtn" onclick="this.parentElement.style.display="none";">×</span>';
echo '<strong>Danger!</strong> wrong email id';
echo '</div>';
header("location:sign.php");
}
?>
My sign.php code as follows::
<!DOCTYPE html>
<html >
<?php
$servername = "localhost";
$username = "root";
$password = "*******";
$dbname = "database";
$conn = new mysqli($servername, $username, $password, $dbname);
?>
<head>
<meta charset="UTF-8">
<title>title</title>
<script src="http://s.codepen.io/assets/libs/modernizr.js" type="text/javascript"></script>
<link href='http://fonts.googleapis.com/css?family=PT+Sans:400,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/148866/reset.css">
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header role="banner">
<nav class="main-nav">
<ul>
<!-- inser more links here -->
<li><a class="cd-signin" href="#0">Sign In</a></li>
<li><a class="cd-signup" href="#0">Sign Up</a></li>
</ul>
</nav>
</header>
<label class="thought">
<p> find your passion, <br><br> make it as your profession </p>
</label>
<div class="cd-user-modal"> <!-- this is the entire modal form, including the background -->
<div class="cd-user-modal-container"> <!-- this is the container wrapper -->
<ul class="cd-switcher">
<li><a href="#0">Sign In</a></li>
<li><a href="#0">Sign Up</a></li>
</ul>
<div id="cd-login"> <!-- log in form -->
<form class="cd-form" action="logincheck.php" method="post">
<p class="fieldset">
<label class="image-replace cd-email" for="signin-email">E-mail</label>
<input class="full-width has-padding has-border" name="email" id="signin-email" type="text" placeholder="E-mail" required autocomplete="off">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-password" for="signin-password">Password</label>
<input class="full-width has-padding has-border" name="password" id="signin-password" type="text" placeholder="Password" required autocomplete="off">
<a href="#0" class="hide-password">Hide</a>
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="remember-me">
<label for="remember-me">Remember me</label>
</p>
<button class="button button-block" type="submit" > Sign In </button>
</form>
<p class="cd-form-bottom-message"><a href="#0">Forgot your password?</a></p>
<!-- <a href="#0" class="cd-close-form">Close</a> -->
</div> <!-- cd-login -->
<div id="cd-signup"> <!-- sign up form -->
<form class="cd-form" action="register.php" method="post" >
<p class="fieldset">
<label class="image-replace cd-username" for="signup-username">Profile Name</label>
<input class="full-width has-padding has-border" name="name" id="signup-username" type="text" placeholder="Type your Name" required autocomplete="off">
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<label class="image-replace cd-email" for="signup-email">E-mail</label>
<input class="full-width has-padding has-border" name="email" id="email" type="text" placeholder="example@mail.com"required autocomplete="off" onkeyup="checkemail();">
<span class="cd-error-message" id="result"></span>
</p>
<label id="title" class="dropdown"><font face="verdana"> Select any three streams that your skills suits the best: </font><br><br>
<select id="job" name="category1" required>
<option value="Engineering"><font face="verdana">Engineering</font></option>
<option value="Medical"><font face="verdana">Medical</font></option>
<option value="Programming"><font face="verdana">Programming</font></option>
<option value="Business"><font face="verdana">Business</font></option>
<option value="Admin"><font face="verdana">Admin</font></option>
<option value="Other"><font face="verdana">Other</font></option>
</select>
<select id="job" name="category2" required>
<option value="Engineering"><font face="verdana">Engineering</font></option>
<option value="Medical"><font face="verdana">Medical</font></option>
<option value="Programming"><font face="verdana">Programming</font></option>
<option value="Business"><font face="verdana">Business</font></option>
<option value="Admin"><font face="verdana">Admin</font></option>
<option value="Other"><font face="verdana">Other</font></option>
</select>
<select id="job" name="category3" required>
<option value="Engineering"><font face="verdana">Engineering</font></option>
<option value="Medical"><font face="verdana">Medical</font></option>
<option value="Programming"><font face="verdana">Programming</font></option>
<option value="Business"><font face="verdana">Business</font></option>
<option value="Admin"><font face="verdana">Admin</font></option>
<option value="Other"><font face="verdana">Other</font></option>
</select>
</label>
<p class="fieldset">
<label class="image-replace cd-password" for="signup-password">Password</label>
<input class="full-width has-padding has-border" name="password" id="signup-password" type="text" placeholder="Password" required autocomplete="off">
<a href="#0" class="hide-password">Hide</a>
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input type="checkbox" id="accept-terms" required>
<label for="accept-terms">I agree to the <a href="#">Terms</a></label>
</p>
<button class="button button-block" type="submit" > Create an Account </button>
</form>
<!-- <a href="#0" class="cd-close-form">Close</a> -->
</div> <!-- cd-signup -->
<div id="cd-reset-password"> <!-- reset password form -->
<p class="cd-form-message">Lost your password? Please enter your email address. You will receive a link to create a new password.</p>
<form class="cd-form">
<p class="fieldset">
<label class="image-replace cd-email" for="reset-email">E-mail</label>
<input class="full-width has-padding has-border" id="reset-email" type="email" placeholder="E-mail" autocomplete="off" required>
<span class="cd-error-message">Error message here!</span>
</p>
<p class="fieldset">
<input class="full-width has-padding" type="submit" value="Reset password">
</p>
</form>
<p class="cd-form-bottom-message"><a href="#">Back to log-in</a></p>
</div> <!-- cd-reset-password -->
<a href="#" class="cd-close-form">Close</a>
</div> <!-- cd-user-modal-container -->
</div> <!-- cd-user-modal -->
<script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src="js/index.js"></script>
</body>
</html>
Any help is greatly appreciated..