-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddStudentValidate.php
44 lines (39 loc) · 1007 Bytes
/
addStudentValidate.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
<?php
include "config.php";
$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';
}
}
else
{
echo 'upload failed';
}
$sql = "INSERT INTO student VALUES ('' , '$name' , '$age' , '$address' , '$targetFile')";
if($conn->query($sql))
{
echo "done";
header("Location:index.php?status=pass");
}
else
{
echo "Error";
header("Location:index.php?status=fail");
}
$conn->$close();
?>