-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert1.php
57 lines (57 loc) · 1.79 KB
/
insert1.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
<?php
session_start();
$fname=$_POST['fname'];
$lname=$_POST['lname'];
$college=$_POST['college'];
$email=$_POST['email'];
$password=$_POST['password1'];
$cpassword=$_POST['password2'];
$dob=$_POST['dob'];
$gender=$_POST['gender'];
// $con = mysqli_connect('localhost','root','','library');
include("connection.php");
$query="INSERT INTO `teachers`(`first_name`, `last_name`, `college`, `birthday`, `email`, `password`, `gender`) VALUES ('$fname','$lname','$college','$dob','$email','$password','$gender')";
$run=mysqli_query($con,$query);
if($run==TRUE)
{
$query1="SELECT * FROM `teachers` WHERE email='$email';";
$run1=mysqli_query($con,$query1);
$data=mysqli_fetch_assoc($run1);
$str=strval($data['id']);
$str1="ti".$fname."".$str;
$str="t".$fname."".$str;
$sql = "CREATE TABLE $str (
id INT(50) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
bookno VARCHAR(30) NOT NULL,
name VARCHAR(30) NOT NULL,
roll VARCHAR(30),
email VARCHAR(30),
request_type VARCHAR(30),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
$sql1 = "CREATE TABLE $str1 (
id INT(50) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
bookno VARCHAR(30) NOT NULL,
name VARCHAR(30) NOT NULL,
roll VARCHAR(30),
email VARCHAR(30),
reg_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)";
if ($con->query($sql) === TRUE && $con->query($sql1) === TRUE) {
echo "Table MyGuests created successfully";
} else {
echo "Error creating table: " . $con->error;
}
?>
<script type="text/javascript">alert("Registered successfully");
window.location.href="index.php";</script>
<?php
}
else
{
?>
<script type="text/javascript">alert("Registration has failed.");
window.location.href="index.php";</script>
<?php
}
?>