I have a page that retrieves a single record from the MySQL database based on a URL string query, assigns a variable to each field, and displays the results of each variable and this works:
PHP Code:
<?php
include 'config.php';
include 'opendb.php';
$query = "SELECT id, name, email, message FROM guestbook WHERE id = '$searchid'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = ("{$row['id']}");
$name = ("{$row['name']}");
$email = ("{$row['email']}");
$message = ("{$row['message']}");
}
echo "$id<BR>";
echo "$name<BR>";
echo "$message<BR>";
echo "$email<BR>";
include 'closedb.php';
?>
BUT... if I add anything else to it, like the part of a form, it doesn't retain the variable information....only what was in the original querystring....
<?php
include 'config.php';
include 'opendb.php';
$query = "SELECT id, name, email, message FROM guestbook WHERE id = '$searchid'";
$result = mysql_query($query);
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$id = ("{$row['id']}");
$name = ("{$row['name']}");
$email = ("{$row['email']}");
$message = ("{$row['message']}");
print("<h2>Send an e-mail to ");
echo ("$name</h2>");
echo ("<form name=\"form1\" method=\"POST\" action=\"contactmesent_old.php\">");
echo ("<input type=\"hidden\" name=\"searchid\" value=\"$searchid");
blah blah blah more form info.....
include 'closedb.php';
}
?>
and contactmesent_old.php would contain the mail command, along with the information from this form, which I haven't even gotten to, but the idea is to have an email submit form where the email address is hidden from the user.
Am doing this totally wrong or what? Any help or pointing in the right direction would be sooo much appreciated!