-
Notifications
You must be signed in to change notification settings - Fork 0
/
add.php
59 lines (45 loc) · 1.16 KB
/
add.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
include('include/config.php');
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
//Syntax:
//"SELECT * FROM tablename WHERE user_input = primary";
$sql = "SELECT * FROM records WHERE email='$email'";
$result = mysqli_query($con, $sql);
$row = mysqli_fetch_array($result);
//check if the user already exist
if($row['email']==$email){
// echo 'Email Already Exist';
?>
<!-- JavaScript -->
<script>
alert('Student Already Exist');
window.location = 'index.php';
</script>
<?php
}
else{
$data = "INSERT INTO records(name,email,phone)VALUES('$name','$email','$phone')";
if(mysqli_query($con,$data)){
// echo 'New User Added Successfully';
?>
<!-- JavaScript -->
<script>
alert('New Student Added Successfully');
window.location = 'index.php';
</script>
<?php
}
else{
// echo 'User Not Added';
?>
<!-- JavaScript -->
<script>
alert('Student Not Added');
window.location = 'index.php';
</script>
<?php
}
}
?>