Posted: Sun Jul 31, 2005 12:13 pm
OK, This chunk of code works for me. I've stripedd off everything above the $form_block= line, you'll want to tack that back on.
Fixed problems include:
1. An extra space after "END_FORM;". HEREDOC syntax is sensitive to white space on its label.
2. Removal of spance between $_POST and [ inside your if statements, addition of curly braces there as well.
3. Addition of quotes around op inside your ifs to avoid undefined constant warnings.
There's still a fair number of notices/warnings generated because some of the form variables aren't being cleansed/initialized prior to use, but lets get this much working first.
Code: Select all
<?php
$form_block=<<<END_FORM
<form method="POST" action="$PHP_SELF" class="info_request">
<fieldset>
<legend title="additional information request">Additional Information Request</legend>
<table id="info_request">
<tr>
<td>
<label for="firstname"><span class="red">*</span> First Name: </label></td>
<td>
<input id="firstname" name="firstname" type="text" value="{$_POST['firstname']}" />
</td>
</tr>
<tr>
<td>
<label for="lastname"><span class="red">*</span> Last Name:</label></td>
<td>
<input id="lastname" name="lastname" type="text" value="{$_POST['lastname']}" />
</td>
</tr>
<tr>
<td>
<label for="company"><span class="red">*</span> Company: </label></td>
<td>
<input id="company" name="company" type="text" value="{$_POST['company']}" /></td>
</tr>
<tr>
<td>
<label for="phone"><span class="red">*</span> Phone: </label></td>
<td>
<input id="phone" name="phone" type="text" value="{$_POST['phone']}" /></td>
</tr>
<tr>
<td>
<label for="email"><span class="red">*</span> e-mail: </label></td>
<td>
<input id="email" name="email" type="text" value="{$_POST['email']}" /></td>
</tr>
<tr>
<td>
<label for="email2"><span class="red">*</span> re-enter e-mail: </label></td>
<td>
<input id="email2" name="email2" type="text" value="{$_POST['email2']}" />
</td>
</tr>
<tr>
<td>
<label for="URL"> URL:</label></td>
<td>
<input id="URL" type="text" name="URL" /> </td>
</tr>
<tr>
<td>
<label for="Contact_Preference"> Best way to reach:</label></td>
<td>
<input id="Contact_Preference" name="Contact_Preference" type="text" value="{$_POST['Contact_Preference']}" /></td>
</tr>
<tr>
<td>
<label for="Contact_Time"> Best time to contact:</label></td>
<td>
<input id="Contact_Time" name="Contact_Time" type="text" value="{$_POST['Contact_Time']}" />
</td>
</tr>
<tr>
<td valign="top">
<label for="message" id="message"> message:</label></td>
<td>
<textarea name="Textarea" rows="25" cols="50">Send me a detailed message specifying what you wish to accomplish with your web site.</textarea>
<input class="submit" src="/images/submit.gif" alt="Submit" type="image" name="submit" />
</td>
</tr>
</table>
</fieldset>
</form>
END_FORM;
if ($_POST["op"] !="ds") {
// they need to see the form
echo "$form_block";
} else if ($_POST["op"] == "ds") {
// check value of $_POST['firstname']
if ($_POST['firstname'] == " ") {
$name_err = '<span class="red">Please enter your first name!</span>< /br>';
$send = "no" ;
}
// check value of $POST['email']
if ($_POST ['email'] == " ") {
$email_err ='<span class="red">Please enter your email address!</span><br />';
$send="no";
}
if ($send != "no") {
//it's ok to send, so build the mail
$msg = "E-mail sent from www site\n";
$msg .="Sender's first name: {$_POST['firstname']}\n";
$msg .="Sender's last name: {$_POST['lastname']}\n";
$msg .="Company name: {$_POST['company']}\n";
$msg .="Senders Phone number: {$_POST['phone']}\n";
$msg .="Senders email address: {$_POST['email']}\n";
$msg .="Senders email address (re-typed): {$_POST['email2']}\n";
$msg .="URL : {$_POST['URL']}\n";
$msg .="Contact_Preference: {$_POST['Contact_Preference']}\n";
$msg .="Contact_Time {$_POST['Contact_Time']}\n";
$msg .="Message: {$_POST['message']}\n\n";
$to ="webguync@gmail.com";
$subject ="There has been a disturbance in the force";
$mailheaders .="From: My Web Site
<http://www.inspired-evolution.com>\n";
$mailheaders .="Reply-To: {$_POST['email']}\n";
//send the mail
mail ($to, $subject, $msg, $mailheaders);
//display information to user
echo "<p>Hola, <strong>$firstname</strong>!.<br /><br />
We have received your request for additional information, and will respond shortly.<br />
Thanks for visiting inspired-evolution.com and have a wonderful day!<br /><br />
Regards,<br /><br />
<strong>Inspired Evolution</strong></p>";
} else if ($send =="no") {
//print error messages
echo "$name_err";
echo "$email_err";
echo "$message_err";
echo "$form_block";
}
}
?>
<p><span class="red">*</span> indicates a required field.</p>
<p></p>
<p></p>
<?php require('includes/bottom_links.inc'); ?></div>
<!-- begin footer -->
<div id="footer">
<p class="footertag">Inspired-Evolution - Web Site: Design, Development, Marketing for Raleigh/Durham, Chapel Hill, Cary North Carolina.</p>
<?php require('includes/footer.inc'); ?>
<span class="date"><?
$last_modified = filemtime("index.php");
print("Last Modified ");
print(date("m/j/y h:i", $last_modified));
?></span>
</div>
</div>
</div>
</body>
</html>1. An extra space after "END_FORM;". HEREDOC syntax is sensitive to white space on its label.
2. Removal of spance between $_POST and [ inside your if statements, addition of curly braces there as well.
3. Addition of quotes around op inside your ifs to avoid undefined constant warnings.
There's still a fair number of notices/warnings generated because some of the form variables aren't being cleansed/initialized prior to use, but lets get this much working first.