Hi, this will be my first message and I hope it to be clear and helpful.
First of all, I would change your if condition, because you want your visitors to send you their name and their telephone number or email. So the condition is obvious:
if ( !isset($realname) && ( !isset($telephone) || !isset($email) ) )
About your problem with the variables... I suppose you mean that after sending the form to confirm.php, if you go back, the ones that were set don't appear on the screen. I don't really know what the problem is, but it may be that navigators don't "remember" the text of the forms. I use many forms in my web page. I've been improving them since I like coding and now I have really flexible and dynamic forms. I'm going to modify your code:
<html>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff>
<?php
if (!isset($submit)) //if submit isn't set it means that form hasn't been sent yet
{
include('form.txt'); //form.txt contains all html code of the form
}
else
{
if (!isset($realname) && (!isset($telephone) || !isset($email)))
{
echo "Please Enter a Contact Name and either a Telephone Number or an
Email address for Contact purpose's.
Thank You <br>";
echo "<FORM action=/confirm.php method=post> \n";
echo "<DIV align=center> \n";
echo "<TABLE border=0 cellPadding=0 cellSpacing=0 width='100%'> \n";
echo "<TBODY> \n";
echo "<TR> \n";
echo "<TD height=71> \n";
echo "<DIV align=center><FONT color=#eabb00 size=6><B><FONT color=#333399><FONT color=#eabb00>Customer Enquiry Form:</FONT></FONT></B></FONT> \n";
echo "</DIV></TD></TR></TBODY></TABLE> \n";
echo "<HR SIZE=3 width='95%'> \n";
echo "<DIV align=center><INPUT name=recipient type=hidden> <INPUT name=subject type=hidden value='Web Enquiry'> <INPUT name=redirect type=hidden value='a web address of your choice'> </DIV></DIV> \n";
echo "<DIV align=center> \n";
echo "<TABLE align=center border=0 cellPadding=5 cellSpacing=5 class=FormCSS height=608 width='51%'> \n";
echo "<TBODY> \n";
echo "<TR> \n";
echo "<TD width='33%'> \n";
echo "<DIV align=left><FONT color=#eabb00><B><FONT face='Times New Roman, Times, serif' size=3>Name:</FONT></B></FONT></DIV></TD> \n";
echo "<TD width='67%'><INPUT maxLength=50 name=realname size=50 value=$realname> </TD></TR> \n";
echo "<TR> \n";
echo "<TD width='33%'> \n";
echo "<DIV align=left><FONT color=#eabb00><B><FONT face='Times New Roman, Times, serif' size=3>Organization:</FONT></B></FONT></DIV></TD> \n";
echo "<TD width='67%'><INPUT maxLength=50 name=organisation size=50 value=$organisation> </TD></TR> \n";
echo "<TR> \n";
echo "<TD width='33%'> \n";
echo "<DIV align=left><FONT color=#eabb00 face='Times New Roman, Times, serif' size=3><B>Address:</B></FONT> </DIV></TD>\n";
echo "<TD width='67%'><TEXTAREA cols=50 name=address_line_1 rows=5>.'$address_line_1.'</TEXTAREA> \n";
(etc...)
echo "<INPUT name="submit" type=submit value="Submit Enquiry">\n"; //when sending the form, variable 'submit' will be set
}
else
{
$message="Name: $realname\n\n"."Organisation:
$organisation\n\n"."Address:\n$address_line_1\n\n"."Post Code: $postcode\n\n"."Telephone:
$telephone\n\n"."Fax: $fax\n\n"."Email: $email\n\n".
"Message: \n".$text;
mail("zurron@vesta.tmf.bg.ac.yu","$subject","$message","From:Form.$email\r\nReply-to:$email");
echo "<p>Thank you for completing our contact form. Your details have been forwarded and
we will be in contact within 2 working days.</p>";
echo "<p>From: $email</P>";
echo "<p>Subject: $subject</p>";
echo "<p>Message: </p>";
echo "<p>";
echo $text;
echo "</p><a href='/index.html'><b>Return to the Index Page</b></a>";
}
}
?>
</BODY></HTML>
As you can see, I have included both scripts (php and html) into only one page. The file must have the same name as the 'action' file of the form (it's a "self-calling"). I also included the php variables into the form. This code works in this way:
-An user opens this page and sees the form (because submit isn't set)
-When the user sends the form (submit is set)
+If it has all the information needed, it's sent to you and a message to the user is shown
+If it doesn't, the form is shown again with an error message and all the fields completed before keep their value
I hope my message is clear enough and easy to understand. Send me an email for any doubt/problem.
Greetings from Spain!
PD:Sorry for my mistakes in english....