-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathedit_adventure_form.php
More file actions
65 lines (39 loc) · 1.82 KB
/
Copy pathedit_adventure_form.php
File metadata and controls
65 lines (39 loc) · 1.82 KB
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
<?php
session_start();
if(!isset($_SESSION['user'])){
header('Location: ./index.php');
}
include('conn.php');
//Array ( [InputAdventureTitle] => kaghan [InputAdventureCountry] => 162 [InputMessage] => khanan a beauty [apic] => Array ( [1] => sump_transparent.png [2] => shop.png ) [apic_default] => 1 [submit] => Signup )
$error = 0;
if(isset($_POST['InputAdventureTitle']) and isset($_POST['InputAdventureCountry']) and isset($_POST['InputMessage']) ){
$title = addslashes($_POST['InputAdventureTitle']);
$country = addslashes($_POST['InputAdventureCountry']);
$description =addslashes( $_POST['InputMessage']);
$by = $_SESSION['user']['id'];
$id = $_POST['id'];
$tags = addslashes($_POST['InputAdventureTags']);
echo $sql = "UPDATE adventure set title='$title', description='$description', country='$country',tags = '$tags', by_id='$by' WHERE id= $id ";
if(mysqli_query($con,$sql)){
$last_adventure_id =$id;
$destination_image="./uploads/";
foreach($_FILES['apic']['name'] as $imgid=>$imgname){
if($_FILES['apic']['error'][$imgid]==4) continue;
$random_number_name = rand().$_FILES['apic']['name'] [$imgid];
$destination_ran= $destination_image.$random_number_name;
$upload_files= copy($_FILES['apic']['tmp_name'] [$imgid],$destination_ran);
if($upload_files){
$product_default=0;
if(isset($_POST['apic_default']) and $_POST['apic_default']==$imgid){
$product_default=1;
}
$product_qury="INSERT INTO uploads SET name='".$random_number_name."', adventure_id='".$last_adventure_id."', default_pic='".$product_default."' ";
$product_exe = mysqli_query($con,$product_qury);
}
}
header('Location:my_adventures.php?message=edited_success');
}
}else{
header('Location:edit_adventure.php?error=1');
}
?>