<!DOCTYPE
html PUBLIC
"-//W3C//
DTD XHTML 1.0
Transitional//E
N"
"http://w
ww.w3.org/TR/xh
tml1/DTD/xhtml1
-transitional.d
td">
<html
xmlns="ht
tp://www.w3.org
/1999/xhtml&qu
ot;>
<head>
<meta
http-equiv=&qu
ot;Content-Type
"
content="
text/html;
charset=iso-885
9-1"
/>
<title>De
lete
News</title&
gt;
</head>
<body>
<?
include("
../site/site.in
c.php"

;
db_login();
// generate and
execute query
$query =
"DELETE
FROM news WHERE
id =
'$id'";
$result =
mysql_query($qu
ery) or die
("Error
in query:
$query. "
.
mysql_error());
// print result
echo
"<font
size=-1>Dele
tion
successful.
<a
href=index.php&
gt;Go back to
the main
menu</a>.
</font>&
quot;;
require_once(&
quot;temp/foot.
php"

;
?>
<?
include("
../site/site.in
c.php"

;
db_login();
// generate and
execute query
$query =
"DELETE
FROM news WHERE
id =
'$id'";
$result =
mysql_query($qu
ery) or die
("Error
in query:
$query. "
.
mysql_error());
// print result
echo
"<font
size=-1>Dele
tion
successful.
<a
href=index.php&
gt;Go back to
the main
menu</a>.
</font>&
quot;;
require_once(&
quot;temp/foot.
php"

;
?>
</body>
</html>
div>
ed.php code:
Code:
<!DOCTYPE
html PUBLIC
"-//W3C//
DTD XHTML 1.0
Transitional//E
N"
"http://w
ww.w3.org/TR/xh
tml1/DTD/xhtml1
-transitional.d
td">
<html
xmlns="ht
tp://www.w3.org
/1999/xhtml&qu
ot;>
<head>
<meta
http-equiv=&qu
ot;Content-Type
"
content="
text/html;
charset=iso-885
9-1"
/>
<title>Un
titled
Document</ti
tle>
</head>
<body>
<?
include("
../site/site.in
c.php"

;
// form not yet
submitted
// display
initial form
with values
pre-filled
if (!$submit)
{
db_login();
// generate
and execute
query
$query =
"SELECT *
FROM news WHERE
id =
'$id'";
$result =
mysql_query($qu
ery) or die
("Error
in query:
$query. "
.
mysql_error());
// if a result
is returned
if
(mysql_num_rows
($result) >
0)
{
// turn it
into an object
$send =
mysql_fetch_obj
ect($result);
// print form
with values
pre-filled
?>
Edit News Post
<form
action="&
lt;? echo
$PHP_SELF;
?>"
method="P
OST">
<input
type="hid
den"
name="id
"
value="&l
t;? echo
$send->id;
?>">
;
Title:<br
/>
<input
size="50
"
maxlength=&quo
t;250"
type="tex
t"
name="tit
le"
value="&l
t;? echo
$send->title
;
?>">
;<br />
Content:<br
/>
<textarea
name="con
tent"
cols="40
"
rows="10
"><?
echo
$send->conte
nt;
?></texta
rea><br
/>
Author:<br
/>
<input
size="50
"
maxlength=&quo
t;250"
type="tex
t"
name="aut
hor"
value="&l
t;? echo
$send->autho
r;
?>">
;<br />
<input
type="Sub
mit"
name="sub
mit"
value="Up
date">
</form>
<?
}
// no result
returned
else {
echo
"<font
size=-1>That
post does not
exist.</font
>";
}
}
// form
submitted
// start
processing it
else
{
// set up error
list array
$errorList =
array();
$count = 0;
// validate
text input
fields
if (!$title) {
$errorList[$cou
nt] =
"Invalid
entry:
title";
$count++; }
if (!$content)
{
$errorList[$cou
nt] =
"Invalid
entry:
content";
$count++; }
if
(!$author) {
$errorList[$cou
nt] =
"Invalid
entry:
author";
$count++; }
if
(sizeof($errorL
ist) == 0) {
db_login();
// generate
and execute
query
$query =
"UPDATE
news SET title
= '$title',
content =
'$content',
author =
'$author'
WHERE id =
'$id'";
$result =
mysql_query($qu
ery) or die
("Error
in query:
$query. "
.
mysql_error());
// print
result
echo
"<font
size=-1>Upda
te successful.
<a
href=index.php&
gt;Go back to
the main
menu</a>.
</font>&
quot;;
} else {
// errors
occurred
// print as
list
echo
"<font
size=-1>The
following
errors were
encountered:
<br>&quo
t;;
echo
"<ul&g
t;";
for ($x=0;
$x<sizeof($e
rrorList);
$x++)
{
echo
"<li&g
t;$errorList[$x
]";
}
echo
"</ul&
gt;</font>
;";
}
}
?>
</body>
</html>
list.php code:
Code:
<!DOCTYPE
html PUBLIC
"-//W3C//
DTD XHTML 1.0
Transitional//E
N"
"http://w
ww.w3.org/TR/xh
tml1/DTD/xhtml1
-transitional.d
td">
<html
xmlns="ht
tp://www.w3.org
/1999/xhtml&qu
ot;>
<head>
<meta
http-equiv=&qu
ot;Content-Type
"
content="
text/html;
charset=iso-885
9-1"
/>
<title>Li
st
News</title&
gt;
</head>
<body>
<?
include("
../site/site.in
c.php"

;
db_login();
//Generate
the query so we
can retrieve
all titles in
the DB in
descending ID
order
$query =
"SELECT
id, title FROM
news ORDER BY
id DESC";
$result =
mysql_query($qu
ery) or die
("Error
in query:
$query. "
.
mysql_error());
// if
records are
present
if
(mysql_num_rows
($result) >
0) {
while($send
=
mysql_fetch_obj
ect($result)) {
echo"
$send->title
- <a
href='ed.php?i
d=$send->id
'>Edit
this</a>
- <a
href='del.php?
id=$send->id
'>Delete
this</a>&
lt;br
/><br
/>";
}
}
?>
</body>
</html>
div>
del.php error:
Explor
er
said...N
otice:
Undefined
variable: id in
c:\programas\
easyphp1-8\www
\admin\del.ph
p on line 16
Deletion
successful. Go
back to the
main menu.
Warning:
main(temp/foot.
php): failed to
open stream: No
such file or
directory in
c:\programas\
easyphp1-8\www
\admin\del.ph
p on line 22
Fatal error:
main(): Failed
opening
required
'temp/foot.php
'
(include_path=
'.;C:/Programas
/EasyPHP1-8\ph
p\pear\') in
c:\programas\
easyphp1-8\www
\admin\del.ph
p on line 22
ed.php error:
Explor
er
said...N
otice:
Undefined
variable:
submit in
c:\programas\
easyphp1-8\www
\admin\ed.php
on line 15
Notice:
Undefined
variable: id in
c:\programas\
easyphp1-8\www
\admin\ed.php
on line 20
That post does
not exist.
Thats quite
it... The
del.php one
just made it to
work but it
gives the same
error... Oh
well... =( Any
help?