This repository has been archived by the owner on Jul 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
submit.php
56 lines (47 loc) · 1.86 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
require_once('connect.php');
ini_set('display_errors', 1);
if(!(isset($_POST['name']) &&
isset($_POST['guard_name']) &&
isset($_POST['email']) &&
isset($_POST['class']) &&
isset($_POST['phno'])) )
{
header('location:error.php?code=3');
}
$name = $con->real_escape_string($_POST['name']);
$guard_name = $con->real_escape_string($_POST['guard_name']);
$email = $con->real_escape_string($_POST['email']);
$class = $con->real_escape_string($_POST['class']);
$phone_no = $con->real_escape_string($_POST['phno']);
$postal_addr = $con->real_escape_string($_POST['post_addr']);
$medium = $con->real_escape_string($_POST['medium']);
$school_addr = $con->real_escape_string($_POST['school_addr']);
$venue = $con->real_escape_string($_POST['venue']);
$primer = $con->real_escape_string($_POST['primer']);
//echo $name, $guard_name, $email, $class, $phone_no, $postal_addr, $medium, $school_addr, $venue;
$table_name = $venue . "_" . $class;
$test_query = 'SELECT * from ' . $table_name . ' WHERE name = "' .$name.'" AND email = "' . $email .'"';
$res = $con->query($test_query);
if($res->num_rows > 0)
{
//$con->close();
header('location: error.php?code=1&name='.$name.'&email='.$email);
}
else{
$insert_query = 'insert into ' . $table_name . '(name, GUARD_NAME, email, PHONE_NO, POSTAL_ADDR, LANG_MED, SCHOOL_ADDR, PRIMER)'.
' VALUES (\'' . $name . "','" . $guard_name . "','" . $email . "','" . $phone_no . "','" . $postal_addr .
"','" . $medium . "','" . $school_addr . "','" . $primer . "');";
//echo $query;
if ($con->query($insert_query) === TRUE) {
$id = $con->insert_id;
$id_str = sprintf("%'.04d\n", $id);
$roll_no = 'MTRP19/'. $venue .'/'.$class.'/'.$id_str;
header('location: payment.php?id='.$roll_no);
}
else {
echo "Error: <br>" . $con->error;
}
$con->close();
}
?>