This repository has been archived by the owner on Jun 11, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_ins.php
73 lines (57 loc) · 1.68 KB
/
add_ins.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
require_once 'dbconfig.php';
session_start();
//auto-gen pwd
function random_password( $length = 8 ) {
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
$password = substr( str_shuffle( $chars ), 0, $length );
return $password;
}
$password = random_password(8);
$insName=$_POST['inst_name'];
$username = 'inst_'.str_replace(' ', '', $insName); //campus table name
$sql="INSERT INTO institute (instituteName,instituteUsername,institutePassword)
VALUES ('$insName','$username','$password');";
$res=mysqli_query($conn,$sql);
////////////////////////////////////////////////////////////////////////////////////
//instituteId
$uname=$_SESSION['uname'];
$sql=sprintf("SELECT instituteId FROM institute WHERE instituteUsername='$username' ");
$res=mysqli_query($conn,$sql);
$row=mysqli_fetch_row($res);
$insId=$row[0];
//Find the campus ID
$sql="SELECT campusID from campus where campusUsername='$username'";
$res=mysqli_query($conn,$sql);
$row=mysqli_fetch_row($res);
$campId=$row[0];
//Campus Table Name
$campTable='campus_'.$insId.$campId;
//Create Campus Table
$sql="CREATE TABLE $campTable (
campusId int(5) ,
instituteId int(5) ,
instituteName varchar(100) ,
schoolName varchar(100) ,
area varchar(100) ,
pincode varchar(10) ,
district varchar(100) ,
state varchar(100),
country varchar(100),
phone1 varchar(100),
phone2 varchar(100),
fax varchar(100),
emailId varchar(255),
website varchar(100),
serviceinfo varchar(500),
designation varchar(100),
desgName varchar(100),
PRIMARY KEY (campusId)
)";
$res=mysqli_query($conn,$sql);
if($res){
echo "<script type='text/javascript'>location.href='create_institute.php';</script>";
}
else{
}
?>