on the topic of php mail - I was wondering whether someone could help. I am trying to piece together info from a book by Luke Welling and Laura Thomson (PHP and MySQL Web Development), many hours of following a few on-line tutorials and a doggedness to learn php and need some help with the php mail() function. The user arrives at a form which has a value passed to it using <?php echo(urlencode($id)); ?> to bring the value along to the form. The user is prompted to fill out their details and click 'submit' which should (1) retrieve the email address for the value $id, and (2) send an email to that address with the contents of the form and (3) print a short thank you note. I am using the code below (which makes sense to my pea-brain) but when I test it I get a blank white page returned to the browser and no email sent. My immediate fear is that I have to (somehow) use '/usr/sbin/sendmail -f', but I dont know where or how. I also dont know whether this is the only problem. Here's the code.
<?php
// Connect to the database server
$dbcnx = @mysql_connect("hostname", "username", "password");
if (!$dbcnx)
{
echo( "<P>Unable to connect to the database server at this time.</P>" );
exit();
}
// Select the BTS database
if (! @mysql_select_db ("database_name") )
{
echo( "<P>Unable to connect to the user database at this time.</P>" );
exit();
}
//Find the name and surname of the person who's ibo number has been used
$result = mysql_query(
"SELECT FirstName, SurName, EMail FROM bts_01 WHERE $id=ID");
if (!$result)return false; //not changed
while ($member = mysql_fetch_array ($result))
{
$name = $member["FirstName"];
$surname = $member["SurName"];
$email = $member["EMail"];
$mesg = "Hello, $name $surname.<P>".
"$vname visited your site and requested that you make contact".
"with him/her - $time2call.<P>".
"His/her contact details are as follows:".
"Telephone - $vtel<br>".
"Mobile - $vmob<br>".
"Email - $vemail<br>".
"Address - $vaddress<br>".
"We hope that your training needs can be met by $vname.<BR>".
"The BTS Team.";
}
if (mail($email, "You had a visitor", $mesg))
return true;
else
return false;
?>
<?php echo( "<B>$vname,</B><P>");
?>
</p>
<p class="btsblockfont">Thank you for completing the form.</p>
<p class="btsblockfont">It has been mailed to us.</p>
<p class="btsblockfont">We shall be in touch shortly.