Hi,
I am trying to get the following working. I try to make a guestbook using a input form. No problem so far. Now i want to have a admin page where i can have a field where i can search on e.g. lastname or something. When i press a button i want to have a form collecting all data out of the db. But I can't seem to get the data out the database on a form. Can someone help me with this problem.
here is the sourcecode of the page:
<HEAD>
<TITLE>EDIT PAGE</TITLE>
</HEAD>
<BODY>
<?php
if(!IsSet($stage))
{
?>
<Form method="post" action="<?php print("$PHP_SELF"); ?>">
name of entry you wish to edit: <input type=text name="wijzignaam" size=40><BR>
<input type=hidden name="stage" value=1>
<input type=submit>
</FORM>
<?php
}
elseif($stage == 1)
{
include("dbconnect.php");
$query = "select id,comments from guestbook where name = '$wijzignaam'";
$result = mysql_query($query);
$commentrow = mysql_fetch_array($result);
$commentid = $commentrow[0];
$commenttext = stripslashes($commentrow[1]);
?>
<form method="post" action="<?php print ("$php_self"); ?>">
name of this entry: <input type=text name="name" size=40 value="<?php print($wijzignaam); ?>"><BR>
entry text: <textarea name="comments" cols=40 rows=4><?php print($comments); ?></textarea><BR>
<input type=hidden name="commentid" value="<?php echo $commentid; ?>">
<input type=hidden name="stage" value=2>
<input type=submit>
</form>
<?php
}
elseif($stage == 2)
{
include("dbconnect.php");
$query ="update guestbook set name= '$name',comments='$comments' where id=$commentid";
$result = mysql_query($query);
if ($result ==0)
print ("we have a problem.\n");
else
print ("edit complete.\n");
?>
<form method="post" action="<?php print ("$php_self"); ?>">
want to edit another entry? enter the name here:
<input type=text name="name" size=40><BR>
<input type=hidden name="stage" value=1>
<input type=submit>
</form>
<?php
}
?>
</body>