-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy patheditStudentValidate.php
59 lines (50 loc) · 1.39 KB
/
editStudentValidate.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 "config.php";
$oldID = $_GET['oldID'];
$newID = $_POST['id'];
$name = $_POST['name'];
$age = $_POST['age'];
$address = $_POST['address'];
$image = $_FILES['image'];
$imgname = $_FILES['image']['name'];
$targetDir = 'img/profile/';
$extention = pathinfo($imgname , PATHINFO_EXTENSION);
$rand_val = date('YMDHIS') . rand(11111, 99999);
$targetFile = $targetDir.md5($rand_val).'.'.$extention;
if (isset($_FILES['image']))
{
if(move_uploaded_file($_FILES['image']['tmp_name'] , $targetFile))
{
echo 'pass image';
}
else
{
echo 'fail image';
$fail = true;
}
}
else
{
echo 'upload failed';
}
echo $targetFile;
if($fail)
{
$sql = "UPDATE student SET studentID = '$newID' , studentName = '$name' , studentAge = '$age' , studentAddress = '$address' WHERE studentID = '$oldID'";
}
else
{
$sql = "UPDATE student SET studentID = '$newID' , studentName = '$name' , studentAge = '$age' , studentAddress = '$address' , imgLoc = '$targetFile' WHERE studentID = '$oldID'";
}
if($conn->query($sql))
{
echo "done";
header("Location:index.php?status=pass");
}
else
{
echo "Error";
header("Location:index.php?status=fail");
}
$conn->$close();
?>