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_header1.php
71 lines (53 loc) · 1.93 KB
/
add_header1.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
<?php
include("dbconfig.php");
session_start();
if(isset($_POST['submit'])){
$username=$_SESSION['uname'];
//Find the campus ID and institute ID
$sql="SELECT campusID,instituteId from campus where campusUsername='$username'";
$res=mysqli_query($conn,$sql);
$row=mysqli_fetch_row($res);
$campId=$row[0];
$instId=$row[1];
//GET values from form
$area = $_POST['area'];
$pincode = $_POST['pincode'];
$district = $_POST['district'];
$state = $_POST['state'];
$country = $_POST['country'];
$phone1 = $_POST['phone1'];
$phone2 = $_POST['phone2'];
$fax = $_POST['fax'];
$emailId = $_POST['emailId'];
$website = $_POST['website'];
$serviceinfo = $_POST['serviceinfo'];
$designation = $_POST['designation'];
$desgName = $_POST['desgname'];
//Insert
$sql="INSERT INTO institute (INSERT INTO `campus_$instId`(`campusId`, `instituteId`, `area`, `pincode`, `district`, `state`, `country`, `phone1`, `phone2`, `mobile`, `fax`, `emailId`, `website`, `serviceinfo`, `designation`, `desgName`, `image`) VALUES (`$campId`,`$instId`,`$area`, `$pincode`, `$district`, `$state`, `$country`, `$phone1`, `$phone2`, `$fax`, `$emailId`, `$website`, `$serviceinfo`, `$designation`, `$desgName`)";
$res=mysqli_query($conn,$sql);
$name = $_FILES['campLogo']['name'];
$target_dir = "img/";
$target_file = $target_dir . basename($name);
// Select file type
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
// Valid file extensions
$extensions_arr = array("jpg","jpeg","png","gif");
// Check extension
if( in_array($imageFileType,$extensions_arr) ){
// Convert to base64
$image_base64 = base64_encode(file_get_contents($_FILES['campLogo']['tmp_name']) );
$image = 'data:image/'.$imageFileType.';base64,'.$image_base64;
// Insert record
$query = "insert into campus_$instId(image) values(`$image`)";
$res = mysqli_query($conn,$query);
if($res){
echo 'success';
}
else{
echo $query;
echo 'fail';
}
}
}
?>