-
Notifications
You must be signed in to change notification settings - Fork 2
/
uploadevent_validation.php
42 lines (34 loc) · 1.37 KB
/
uploadevent_validation.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
35
36
37
38
39
40
41
42
<?php
$emailErr=$passwordErr="";
$email=$password="";
$ferror="";
$conn = new mysqli("localhost", "root", "", "nitrutsav");
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
$val=$_POST["email"];
$data=$conn->query("SELECT email FROM register WHERE email='".$val."'");
if (empty($_POST["email"])) { $emailErr = "Email is required";}
else if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { $emailErr = "Invalid email format";}
else if ($data->num_rows==0) { $emailErr = "This email is not registered";}
else{ $email = test($_POST["email"]); }
$pass=md5($_POST["password"]);
$cod=$conn->query("SELECT * FROM register WHERE email='".$val."' AND password='".$pass."'");
if(empty($_POST["password"])) { $passwordErr="password required"; }
else if ($cod->num_rows==0) { $passwordErr= "Invalid email-password combination"; }
else
{
$adm=$conn->query("SELECT admin FROM register WHERE email='".$val."' AND password='".$pass."'AND admin=1");
if($adm->num_rows==1)
header("location:eventuploader.php");
else
$ferror="You are not allowed to the admin pannel";
}
}
function test($data)
{
$data=trim($data);
$data=stripcslashes($data);
$data=htmlspecialchars($data);
return $data;
}
?>