-
Notifications
You must be signed in to change notification settings - Fork 1
/
add.php
53 lines (37 loc) · 1008 Bytes
/
add.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
<html>
<?php
include 'db.php';
function make_comic($title, $url, $author){
//add a comic to database
$comic = new comicDbHandler(SERVER, DB, USR, PWD);
//generate webpage for comic
$filename = "data/index.php";
$fp = fopen($filename, "r");
//$contents = fread($handle, filesize("usr.txt"));
$contents = file($filename);
fclose($fp);
//echo $contents;
$id = $comic->add_comic($title, $url, $author);
$contents[3] = "\$id = ".$id.";";
$filename = 'data/'.$id.".php";
$fp_w = fopen($filename, "w+");
//file_put_contents("test.txt",implode(",",$contents));
foreach($contents as $key => $value){
fwrite($fp_w,$value."\t");
}
fclose($fp_w);
//print_r($contents);
}
if ($_POST["title"] !=''&&$_POST["url"]!= '' && $_POST["author"] != ''){
make_comic($_POST["title"], $_POST["url"], $_POST["author"]);
?>
<h1> Comic Added</h1>
<a href= "admin.php">back</a>
<?php
}
else{
?>
<h1> Comic Not added </h1>
<a href= "admin.php">back</a>
<?php }?>
</html>