-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathedit.php
64 lines (64 loc) · 1.82 KB
/
edit.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
60
61
62
63
64
<?php
require 'config.php';
$con = mysql_connect($host, $db_user, $db_password);
if (!$con) {
die('Could not connect: ' . mysql_error());
}
$db = mysql_select_db($db_name, $con);
if ($_POST['new']){
$sql="SELECT MAX(ID) FROM articles;";
$result=mysql_query($sql,$con);
if($row=mysql_fetch_array($result)){
$id=(int)$row['MAX(ID)']+1;
}else {
$id=1;
}
$sql="INSERT INTO articles (ID) VALUES (".$id.");";
print $sql;
$query=mysql_query($sql,$con);
if(!$query){
die("Error adding values to table.");
}
$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
$extra = 'edit.php';
header("Location: http://$host$uri/$extra?id=$id");
}
?>
<html>
<head>
<title>
Edit page...
</title>
</head>
<body>
<?php
/* A content manager for tathva '11*/
$id=$_GET['id'];
if(!$id){
$id=0;
}
$sql = "SELECT * FROM articles WHERE ID = '".$id."';";
$result = mysql_query($sql,$con);
if($row = mysql_fetch_array($result)) {
?>
<form name='edit' action='post.php' method='POST'>
<fieldset>
<legend>Article Details</legend>
ID : <input type="hidden" name="article_id" value="<?php echo $id; ?>"/> <?php echo $id; ?> <br/>
Type: <input type="text" name="article_type" value="<?php echo $row['article_type']; ?>"/> <br/>
Author: <?php echo $row['article_author']; ?> <br/>
Created: <?php echo $row['article_created'];?> <br/>
Title: <input type="text" name="article_title" value="<?php echo $row['article_title'];?>"/> <br/>
Hash Tag: <input type="text" name="article_hash" value="<?php echo $row['article_hash'];?>"/> <br/>
Content: <textarea name="article_content" col=100 row=100><?php echo $row['article_content']; ?></textarea><br/>
<input type="submit" name="submit" value="Submit"/>
<input type="submit" name="preview" value="Preview"/>
</fieldset>
</form>
<? } else {
echo "Invalid Article ID.";
}
?>
</body>
</html>