PDA

View Full Version : DW template contact form


dw_gurl
11-19-2012, 09:05 AM
Hi,

I recently bought a template and cant make the contact form work. To be honest, I have only been learning dreamweaver in the past couple of months and its all been self taught so Im a bit of an idiot still...

Anyway, the code that came with the template is copied below. Whats happening at the moment is that as soon as the page loads all of the error and empty messages are showing... and I cant even make it send the email to the gmail address...

Thanks everyone for your help!
xxx

<div id="main">
<div id="content" role="main" class="page-contact">
<h1 class="entry-title">Get in touch!</h1>
<div class="entry-content">
<div id="contact_colleft">
<p class="entry-meta">Please note that we do not take bookings through this form, but you are welcome to fill it in and we will call you to confirm your booking.</p>
<div class="entry-content">
<div id="contact_colleft">
<form id="contact-form">
<div class="success"> Contact form submitted!<br> <strong>We will be in touch soon.</strong></div>
<fieldset>
<label class="name">
<input type="text" value="Your Name">
<span class="error">*This is not a valid name.</span>
<span class="empty">*This field is required.</span>
<span class="clear"></span>
</label>
<label class="email">
<input type="text" value="Your Email">
<span class="error">*This is not a valid email address.</span>
<span class="empty">*This field is required.</span>
<span class="clear"></span>
</label>
<label class="state">
<input type="text" value="Your Pets Name">
<span class="error">*This is not a valid name.</span>
<span class="empty">*This field is required.</span>
<span class="clear"></span>
</label>
<label class="message">
<textarea>Your Message</textarea>
<span class="error">*The message is too short.</span>
<span class="empty">*This field is required.</span>
<span class="clear"></span>
</label>
<div class="buttons"><span><a class="button" data-type="submit">Send Message</a></span></div>
</fieldset>
</form>
</div></div></div>
<div id="contact_colright">
<div id="maps">
<div class="maps_inner">
<iframe src="https://maps.google.co.uk/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q=larkholme+ken nels,+hereford&amp;aq=&amp;sll=53.800651,-4.064941&amp;sspn=7.361165,21.643066&amp;ie=UTF8&amp;hq=larkho lme+kennels,&amp;hnear=Hereford,+United+Kingdom&amp;ll=52. 079974,-2.624806&amp;spn=0.051867,0.20057&amp;t=m&amp;output=embed"" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" width="418" height="243"></iframe>
</div>
</div>
<div id="contact_info">
<div class="contact_info_left">
<p>We are situated amongst quiet and beautiful countryside just outside Hereford on the A1403. </p>
</div>
<div class="contact_info_right">
<div class="contact_info_point point_addess">
<p>Whitestone<br /> Hereford
<br /> HR1 3SG</p>
</div>
<div class="contact_info_point point_phone"> 01432 850 317 </div><div class="contact_info_point point_email"><a href="larkholme.info@gmail.com">larkholme.info@gmail.com</a></div>
</div>
</div>
</div>
</div>
</div>
</div>

Corrosive
11-19-2012, 09:37 AM
A contact form won't fork by HTML alone. You need a form processing script (usually PHP) on your server to do the magic.

dw_gurl
11-19-2012, 09:47 AM
Hi,

Thanks for your reply. I apologize in advance for all of the stupid questions Im going to ask! :S

I have a folder called js_contact with several js files, the only .php dpc I seem to have is this:

<?php
/*
This file is a wrapper, for use in PHP environments, which serves PIE.htc using the
correct content-type, so that IE will recognize it as a behavior. Simply specify the
behavior property to fetch this .php file instead of the .htc directly:

.myElement {
[ ...css3 properties... ]
behavior: url(PIE.php);
}

This is only necessary when the web server is not configured to serve .htc files with
the text/x-component content-type, and cannot easily be configured to do so (as is the
case with some shared hosting providers).
*/

header( 'Content-type: text/x-component' );
include( 'PIE.htc' );
?>

Corrosive
11-19-2012, 10:56 AM
Nope that won't do it. That is just serving PIE CSS3 effects for older/shit browsers.

dw_gurl
11-19-2012, 11:00 AM
oh, I found another 2. Copied below:

MailHandler.php:

<?php
$owner_email = $_POST["owner_email"];
$headers = 'From:' . $_POST["email"];
$subject = 'A message from your site visitor ' . $_POST["name"];
$messageBody = "";

if($_POST['name']!='nope'){
$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['email']!='nope'){
$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}else{
$headers = '';
}
if($_POST['state']!='nope'){
$messageBody .= '<p>Website: ' . $_POST['state'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['phone']!='nope'){
$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['fax']!='nope'){
$messageBody .= '<p>Fax Number: ' . $_POST['fax'] . '</p>' . "\n";
$messageBody .= '<br>' . "\n";
}
if($_POST['message']!='nope'){
$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
}

if($_POST["stripHTML"] == 'true'){
$messageBody = strip_tags($messageBody);
}

try{
if(!mail($owner_email, $subject, $messageBody, $headers)){
throw new Exception('mail failed');
}else{
echo 'mail sent';
}
}catch(Exception $e){
echo $e->getMessage() ."\n";
}
?>


Newsletter.php: (i would assume this one is not for the contact form but ill copy it anyway)

<?php
$email = $_POST[youremailaddress];
$headers = 'From:'. $email.'' . "\r\n" .
'Reply-To: '. $email.'' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$msg = 'Email Newsletter: ';
$msg .= $_POST[youremailaddress];
$to = 'arrowcoder@gmail.com';
$subject = 'A email submit Newsletter';
mail( $to, $subject,$msg, $headers);
echo("Success!<script type='text/javascript'>location.href='../index.html'</script>");
?>

Corrosive
11-19-2012, 11:20 AM
Yes, that's the one :) You'll probably just need to configure stuff like the email address to send to and you should be good to go. Check if there is a 'read me' file with your template download that goes through it. I'd be amazed of there wasn't.

dw_gurl
11-19-2012, 12:38 PM
Cool, thats a step closer then. Theres no read me file... I did try that as a first option and I also posted on the template creators page but no help! :S

Ok so this is going to sound even worse, but which bits am I meant to replace on the php?

I promise to teach myself all about contact forms after this but really need to get this one done.

Thanks again