Revert "restructuring"
This reverts commit 804d7ce98b
.
Conflicts:
index.php
This commit is contained in:
parent
613cc9bc3c
commit
137ce0be7e
3
db.php
3
db.php
|
@ -6,8 +6,7 @@ $db_password = 'password';
|
|||
$db = 'webshopdb';
|
||||
$db_port = '3306';
|
||||
|
||||
$db_connection = mysqli_connect("$db_server","$db_user","$db_password",
|
||||
"$db","$db_port");
|
||||
$con = mysqli_connect("$db_server","$db_user","$db_password","$db","$db_port");
|
||||
// Check connection
|
||||
if (mysqli_connect_errno()) {
|
||||
echo "Failed to connect to MySQL: " . mysqli_connect_error();
|
||||
|
|
27
login.php
Normal file
27
login.php
Normal file
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
require('db.php');
|
||||
session_start();
|
||||
// If form submitted, insert values into the database.
|
||||
if (isset($_POST['username'])) {
|
||||
// removes backslashes
|
||||
$username = stripslashes($_REQUEST['username']);
|
||||
//escapes special characters in a string
|
||||
$username = mysqli_real_escape_string($con,$username);
|
||||
$password = stripslashes($_REQUEST['password']);
|
||||
$password = mysqli_real_escape_string($con,$password);
|
||||
//Checking is user existing in the database or not
|
||||
$query = "SELECT * FROM `users` WHERE username='$username'
|
||||
and password='".md5($password)."'";
|
||||
$result = mysqli_query($con,$query) or die(mysql_error());
|
||||
$rows = mysqli_num_rows($result);
|
||||
if ($rows==1) {
|
||||
$_SESSION['username'] = $username;
|
||||
// Redirect user to home.php
|
||||
header("Location: home.php");
|
||||
} else {
|
||||
echo "<div class='form'>
|
||||
<h3>Username/password is incorrect.</h3>
|
||||
<br/>Click here to <a href='login.php'>Login</a></div>";
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1,16 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<!-- enable utf-8 encoding for umlauts etc.-->
|
||||
<meta charset="utf-8">
|
||||
<!-- Description of what this dose -->
|
||||
<meta name ="viewport" content="width=device-width, initial-scale=1">
|
||||
<!-- link to the default css file -->
|
||||
<link rel="stylesheet" href="css/stylesheet.css"/>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h3>Login failed!</h3>
|
||||
</body>
|
||||
</html>
|
|
@ -1,5 +1,7 @@
|
|||
<ul>
|
||||
<?php
|
||||
echo '<ul>
|
||||
<li><a href="ticket.php">Ticket</a></li>
|
||||
<li><a href="board.php">Board</a></li>
|
||||
<li><a class="active" href="home.php">Home</a></li>
|
||||
</ul>
|
||||
</ul>'
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user