-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathserver2.php
More file actions
35 lines (31 loc) · 1.02 KB
/
server2.php
File metadata and controls
35 lines (31 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
session_start();
// initializing variables
$username = "";
$email = "";
$errors = array();
// connect to the database
$db = mysqli_connect("remotemysql.com", "GUpZhDMMKw", "tGJ1mPizWn", "GUpZhDMMKw");
if (isset($_POST['login'])) {
$username = mysqli_real_escape_string($db, $_POST['username']);
$password = mysqli_real_escape_string($db, $_POST['password']);
if (empty($username)) {
array_push($errors, "Username is required");
}
if (empty($password)) {
array_push($errors, "Password is required");
}
if (count($errors) == 0) {
$password = md5($password);
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$results = mysqli_query($db, $query);
if (mysqli_num_rows($results) == 1) {
$_SESSION['username'] = $username;
$_SESSION['success'] = "";
header('location: index.php');
}else {
array_push($errors, "Wrong username/password combination");
}
}
}
?>