-
Notifications
You must be signed in to change notification settings - Fork 0
/
register_submit.php
34 lines (22 loc) · 1002 Bytes
/
register_submit.php
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
<?php
require("includes/common.php");
$name = $_POST['name'];
$name = mysqli_real_escape_string($con, $name);
$email = $_POST['email'];
$email = mysqli_real_escape_string($con, $email);
$password = $_POST['pwd'];
$password = mysqli_real_escape_string($con, $password);
$password = MD5($password);
// Query checks if the email and password are present in the database.
$query = "SELECT email FROM users WHERE email='" . $email . "'";
$result = mysqli_query($con, $query)or die($mysqli_error($con));
$num = mysqli_num_rows($result);
if ($num == 0) {
$query = "INSERT INTO users(name, email, password)VALUES('" . $name . "','" . $email . "', '" . $password ."')";
mysqli_query($con, $query) or die(mysqli_error($con));
header('location: login.php'); //rediect to the login page
} else {
$error = "<span style='color: red;'>Already a registered User !</span>";
header('location: register.php?error=' . $error);
}
?>