PDA

View Full Version : Problems with contact form


cornerstones
10-11-2009, 11:46 AM
HI

I am trying to add a contact page to my website where the customer completes the details clicks on the submit button this is then sent to my e-mail address cornerstones@live.co.uk The code below is as far as I have got but it isnt working can anyone please have a look at the code and see what I am doing wrong I would really appreciate it?


<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p><h3>&nbsp;</h3>
<div class="contactForm mainContent">
<form name="reg_form" action="/contact.php" method="post">
<p>Please use the form below to fill in your details and one of our representatives will contact you</p>
<p class="formLine">
<em>Name</em>
<input name="name_str" value="" type="text" />
</p>
<p class="formLine">
<em>E-mail</em>
<input name="email_str" value="" type="text" />
</p>
<p class="formLine">
<em>Telephone</em>
<input name="tel_str" value="" type="text" />
</p>
<p class="formLine">
<em>Address</em>
<textarea name="address_str" rows="4" cols="32"></textarea>
</p>
<p class="formLine">
<em>Message</em>
<textarea name="message_str" rows="7" cols="32"></textarea>
</p>
<p class="formLine"><input type="submit" class="formButton" value="emailto:cornerstones@live.co.uk"/></p>
</form>
</div><!-- end contactForm -->&nbsp;</p>
</body>
</html>

blanchard
10-11-2009, 12:21 PM
Hello there, you'll need to create a
sendresults.php
file and upload it to your webspace, this will have the details of where to send the form information to and where to re-direct to.

see below for the sendresults.php you can copy the code into notepad or dreamweaver and replace the parts you need.

you will need to change the following text in the code:

Returning Email Subject Field -
$subject = 'Replace this text with what you want people to see in the subject field of the returned email';

The email address you want the file sent to
$emailadd = 'email address';

Where you want the page to re-direct to after form has been submitted
$url = 'the homepage of the website or a thankyou page';

---------------Copy the code below this line----------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>sendresults</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body>
<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Replace this text with what you want people to see in the subject field of the returned email';

// Your email address. This is where the form information will be sent.
$emailadd = 'email address';

// Where to redirect after form is processed.
$url = 'the homepage of the website or a thankyou page';

// 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 = '0';

// --------------------------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.'">';
?>
</body>
</html>

cornerstones
10-12-2009, 06:11 PM
Hi many thanks for your reply I do appreciate it, I have put the code in regarding the return e-mail can you please tell me where I put the code your have marked as "do not edit below this line" I am sorry to be so cheeky but I do appreciate your help

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<p><h3>&nbsp;</h3>
<div class="contactForm mainContent">
<form name="reg_form" action="/contact.php" method="post">
<p>Please use the form below to fill in your details and one of our representatives will contact you</p>
<p class="formLine">
<em>Name</em>
<input name="name_str" value="" type="text" />
</p>
<p class="formLine">
<em>E-mail</em>
<input name="email_str" value="" type="text" />
</p>
<p class="formLine">
<em>Telephone</em>
<input name="tel_str" value="" type="text" />
</p>
<p class="formLine">
<em>Address</em>
<textarea name="address_str" rows="4" cols="32"></textarea>
</p>
<p class="formLine">
<em>Message</em>
<textarea name="message_str" rows="7" cols="32"></textarea>
</p>
</body>
</html>
$subject = Cornerstones response;
$emailadd = cornerstones@live.co.uk;
$url = http://www.cornerstonesresidentiallettings.com;
</form>
</div><!-- end contactForm -->&nbsp;</p>
</body>
</html>

edbr
10-13-2009, 01:42 AM
Hello there, you'll need to create a
sendresults.php
file and upload it to your webspace,


there you go alreay answered by blanchard

cornerstones
10-13-2009, 04:02 PM
Thanks very much for your time it is appreciated