Log In Form and Log In Query Code

<div id=”login” class=”tiny reveal-modal” data-reveal>
<form action=”php/login.php” method=”post”>
<label for=”Username”>Username/Email Address</label>
<input type=”text” name=”username” id=”Username”>
<label for=”Password”>Password</label>
<input type=”password” name=”password” id=”Password”/>
<input type=”submit” value=”Log In” name=”Log In”/>
</form>
</div>

<?php
session_start();
require_once(‘../connectpage.php’);
$username = $_POST[‘username’];
$password = $_POST[‘password’];

$query = mysqli_query($db_server, “select * from users where email=’$username’ AND password=’$password'”);
$rows = mysqli_num_rows($query);
if ($rows == 1) {
$_SESSION[‘session’]=$username; // calling session username and starting it
header(“location: ../maphomepage.php”); // redirect to home page after logged in
} else {
$error = “Please enter correct username or password”;
echo $error;
}

Advertisements
This entry was posted in Code. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s