-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathAddHeader.php
More file actions
52 lines (47 loc) · 1.41 KB
/
AddHeader.php
File metadata and controls
52 lines (47 loc) · 1.41 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
<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
$event_id=(int)$_GET["EventName"];
/*$event_id=$_GET["EventName"];
$event_name=$_GET["event_name"];
if($event_name=="")
echo $event_id;
else
echo $event_name;
*/
$count=(int)$_GET['i'];
$con=mysqli_connect("127.0.0.1","root","","project_test");
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sqll = "SELECT EventID, HeaderTitle, HeaderNo FROM eventheader WHERE EventID =$event_id";
$result_select = mysqli_query($con,$sqll) or die(mysql_error());
for($i=1;$i<=$count;$i++)
{
$row = mysqli_fetch_array($result_select);
$CheckHeaderTitle = $row["HeaderTitle"];
$CheckHeaderNo = $row["HeaderNo"];
$col = "Column".$i;
$column = $_GET[$col];
if($CheckHeaderTitle == $column && $CheckHeaderNo==$i)
{}
else if("$column" === "")
echo"Can't insert Column $i. Column is empty.\n";
else{
if($CheckHeaderTitle != $column && $CheckHeaderNo==$i){
$sql = "UPDATE eventheader SET HeaderTitle = $column WHERE HeaderNo =$i";
}
else{
$sql = "INSERT INTO eventheader (EventID,HeaderTitle,HeaderNo) VALUES ($event_id,'$column',$i)";
}
if ($con->query($sql) === TRUE) {
echo "Column $i created successfully\n";
}
else {
echo "Error: " . $sql . "<br/>" . $con->error;
}
}
}
$con->close();
header( "Refresh:3; url=http://127.0.0.1/project/form3.html", true, 303);
?>