-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmit.php
More file actions
37 lines (35 loc) · 890 Bytes
/
Copy pathsubmit.php
File metadata and controls
37 lines (35 loc) · 890 Bytes
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
<?php
include_once("lib/connection.php");
if(!empty($_REQUEST['mode']))
{
$first_name = cleanData($_POST['firstName']);
$last_name = cleanData($_POST['lastName']);
$email = cleanData($_POST['email']);
$sql_check = $mysqli->query("SELECT id FROM users WHERE email='$email'");
$finalcount= $sql_check->num_rows;
if($finalcount == '0')
{
$query = "INSERT INTO users SET
`first_name`='$first_name',
`last_name`='$last_name',
`email`='$email';";
$res= $mysqli->query($query);
if(!$res)
echo $mysqli->error;
else
{
header("Location: index.php?msg=User added");
}
}
else
header("Location: index.php?msg=User exists");
}
function cleanData($data)
{
$data=trim($data);
$data=stripcslashes($data);
$data=htmlspecialchars($data);
$data=strip_tags($data);
return $data;
}
?>