Hello all, I am relatively new to all of this and especially php. I have built my site using a template and I am having massive difficulties getting the contact form to work. I have tried dozens of php scripts, and even a dreamweaver extension, and nothing seems to work. The current version that has at least gotten me emails is below, but it is not passing me any info, it is just showing "Results from form:" in the email and that is it, no form data at all. Any suggestions what is wrong? I am guessing since I am actually getting an email of some sort that it is not on the hosting side.
Here is the HTML code for the form:
HTML Code:
<form action="contact.php" method="post" id="form1">
<div class="form">
<label>Enter your name</label>
<input type="text" id="Name" />
</div>
<div class="form">
<label>Enter your e-mail</label>
<input type="text" id="email" />
</div>
<div class="form">
<label>Enter your phone number</label>
<input type="text" id="phone" />
</div>
<div>
<label>Enter your message</label>
<textarea cols="1" rows="1" id="comments"></textarea>
</div>
<div class="link1"><a href="#" onclick="document.getElementById('form1').reset()"><em><b>Clear</b></em></a> <a href="#" onclick="document.getElementById('form1').submit()"><em><b>Send</b></em></a></div>
</form>
And this is the php code in the contact.php file:
PHP Code:
<?php //--------------------------Set these paramaters-------------------------- // Subject of email sent to you. $subject = 'Results from Contact form'; // Your email address. This is where the form information will be sent. $emailadd = 'info@lightingbydesignfl.com'; // Where to redirect after form is processed. $url = 'http://www.lightingbydesignfl.com/index-6.html'; // Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty. $req = '1'; // --------------------------Do not edit below this line-------------------------- $text = "Results from form:\n\n"; $space = ' '; $line = ' '; foreach ($_POST as $key => $value) { if ($req == '1') { if ($value == '') {echo "$key is empty";die;} } $j = strlen($key); if ($j >= 20) {echo "Name of form element $key cannot be longer than 20 characters";die;} $j = 20 - $j; for ($i = 1; $i <= $j; $i++) {$space .= ' ';} $value = str_replace('\n', "$line", $value); $conc = "{$key}:$space{$value}$line"; $text .= $conc; $space = ' '; } mail($emailadd, $subject, $text, 'From: '.$emailadd.''); echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'; ?>
Any thoughts would be most appreciated.
|