-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsign_process.php
More file actions
66 lines (63 loc) · 1.99 KB
/
sign_process.php
File metadata and controls
66 lines (63 loc) · 1.99 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
include("conn.php");
session_start();
$email = $pass = $conf_pass = $fname = $lname = $dob = $area = $city = $gender = $blood_grp = $rh = "";
$hno = $phno = 0;
$emailErr = $passErr = "";
if($_SERVER["REQUEST_METHOD"] == "POST")
{
//$sql='select email from donor where email=?';
$stmt = $conn->prepare('select email from blood.donor where email=:email');
$stmt->bindParam(":email", $email);
$email = test_input($_POST["email"]);
$stmt->execute();
if($stmt->rowCount()!=0)
{
$_SESSION["emailErr"] = "Email address already exists.";
}
$pass = md5($_POST["pass"]);
$conf_pass = md5($_POST["conf_pass"]);
if(strcmp($pass,$conf_pass)!=0)
{
$_SESSION["passErr"] = "Passwords do not match.";
}
if(strlen($emailErr)==0 && strlen($passErr)==0)
{
$sql_add = "insert into blood.donor(email,password,first_name,last_name,gender,house_no,area,city,DOB,ABO,rhesus,phone_no) values(?,?,?,?,?,?,?,?,?,?,?,?)";
$fname = test_input($_POST["fname"]);
$lname = test_input($_POST["lname"]);
$dob1 = new DateTime(sanitize(($_POST["dob"])));
$dob = $dob1->format('Y-m-d');
$hno = test_input($_POST["hno"]);
$area = test_input($_POST["area"]);
$city = test_input($_POST["city"]);
$gender = test_input($_POST["gender"]);
$blood_grp = test_input($_POST["blood_grp"]);
$rh = test_input($_POST["rh"]);
$phno = test_input($_POST["phno"]);
$stmt2 = $conn->prepare($sql_add);
$stmt2->execute(array($email,$pass,$fname,$lname,$gender,$hno,$area,$city,$dob,$blood_grp,$rh,$phno));
if($stmt2->rowCount()==1)
{
echo "registered successfully.";
}
}
else
{
header("Location:Donor.php");
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
function sanitize($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>