PDA

View Full Version : Help with php contact form please


kearnsy
08-03-2010, 06:43 PM
Evening all

A friend has asked me to put together a site for him, nothing to complex just 3 pages and a contact form

I'm having major problems getting the contact form to work

I created the form in dreamweaver, then took some code from the web that said would enable the contact form to work as long as i changed the variables and things to match my form, that i've done but i keep getting error messages, and the form just won't work

Would any be so kind as to point me in the right direction as to what i'm doing wrong, as i'm a total php newbie, and have limited knowledge of dreamweaver.

Here is the test site http://domain2703182.sites.streamlinedns.co.uk/

and here is the code of the contact form....

<!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>
<title>About Us - www.reactionclaims.co.uk - Accident Claims Management In Liverpool &amp; Merseyside</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<!-- Save for Web Styles (contact us REACTION LEAFLET copy.jpg) -->
<style type="text/css">
<!--

#Table_01 {
position:relative;
left:0px;
top:0px;
width:900px;
height:1273px;
margin-right: auto;
margin-left: auto;
font-family: Arial, Helvetica, sans-serif;
color: #FFF;
}

#contact2-01_ {
position:absolute;
left:0px;
top:0px;
width:900px;
height:182px;
}

#contact2-02_ {
position:absolute;
left:0px;
top:182px;
width:900px;
height:33px;
background-image: url(Slices/images/contact2_02.gif);
font-family: Arial, Helvetica, sans-serif;
color: #FFF;
text-align: center;
}

#contact2-03_ {
position:absolute;
left:0px;
top:215px;
width:29px;
height:1058px;
}

#contact2-04_ {
position:absolute;
left:29px;
top:215px;
width:844px;
height:1031px;
}

#contact2-05_ {
position:absolute;
left:873px;
top:215px;
width:27px;
height:1058px;
}

#contact2-06_ {
position:absolute;
left:29px;
top:1246px;
width:844px;
height:27px;
}
#apDiv1 {
visibility:visible;
left:117px;
top:907px;
width:808px;
height:312px;
z-index:1;
margin-right: auto;
margin-left: auto;
position: absolute;
}
label {
font-family: Arial, Helvetica, sans-serif;
font-size: 18px;
color: #FFF;
margin-left: 375px;
}
a {
color: #FFF;
font-family: Arial, Helvetica, sans-serif;
padding: 10px;
}
#firstname {
}
#lastname {
}
#email {
margin-left: 35px;
}
#phone {
margin-left: 33px;
}
#mobile {
margin-left: 32px;
}
#comments {
margin-left: -5px;
}
#submit {
margin-left: 125px;
}
body {
background-image: url(Images/BG.jpg);
background-repeat: repeat-x;
}

-->
</style>
<!-- End Save for Web Styles -->
</head>
<body style="background-color:#FFFFFF;">
<!-- Save for Web Slices (contact us REACTION LEAFLET copy.jpg) -->
<div id="Table_01">
<div id="contact2-01_">
<img src="Slices/images/contact2_01.gif" alt="" width="900" height="182" border="0" usemap="#contact2_01Map" id="contact2_01" />
<map name="contact2_01Map" id="contact2_01Map">
<area shape="rect" coords="345,11,876,146" href="index.html" />
</map>
</div>
<div id="contact2-02_"><a href="index.html">Home </a>| <a href="aboutus.html">About Us</a> | <a href="ourpromise.html">Our Promise</a> | <a href="contact2.html">Contact Us</a></div>
<div id="contact2-03_">
<img id="contact2_03" src="Slices/images/contact2_03.gif" width="29" height="1058" alt="" />
</div>
<div id="contact2-04_">
<img id="contact2_04" src="Slices/images/contact2_04.gif" width="844" height="1031" alt="" />
</div>
<div id="contact2-05_">
<img id="contact2_05" src="Slices/images/contact2_05.gif" width="27" height="1058" alt="" />
</div>
<div id="contact2-06_">
<img id="contact2_06" src="Slices/images/contact2_06.gif" width="844" height="27" alt="" />
</div>
</div>
<!-- End Save for Web Slices -->
<div id="apDiv1">
<form id="form1" name="form1" method="post" action="contactformprocess.php">
<p>
<label for="firstname">First Name:</label>
<input type="text" name="firstname" id="firstname" />
</p>
<p>
<label for="lastname">Last Name:</label>
<input type="text" name="lastname" id="lastname" />
</p>
<p>
<label for="email">E-Mail:</label>
<input type="text" name="email" id="email" />
</p>
<p>
<label for="phone">Phone:</label>
<input type="text" name="phone" id="phone" />
</p>
<p>
<label for="mobile">Mobile:</label>
<input type="text" name="mobile" id="mobile" />
</p>
<p>
<label for="comments"></label>
<textarea name="comments" id="comments" cols="50" rows="3">Please enter a brief description of your accident...</textarea>
</p>
<p>
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" />
</p>
</form>
</div>
</body>
</html>and finaly the php contact form code.....

<?php

/*
* @Web Contact Page PHP Script
* @author helpvid@ymail.com - http://www.helpvid.net
* @version 1.0.0
* @date January 05, 2010
* @category Helpvid PHP Script for Contact page
* @copyright (c) 2010 @helpvid.net (www.helpvid.net)
* @Creative Commons Attribution-No Derivative Works 2.0 UK: England & Wales License.
* @Creative Commons Attribution-No Derivative Works 2.5 UK: SCOTLAND License.
* @Creative Commons Attribution-No Derivative Works 3.0 United States License.
*/


/* Email Variables */
$emailSubject = 'contactformprocess!'; /*Make sure this matches the name of your file*/
$webMaster = 'stephen.redhead81@googlemail.com';

/*design by Mark Leroy @ http://www.helpvid.net*/

/* Data Variables */
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$mobile = $_POST['mobile'];
$comments = $_POST['comments'];



$body = <<<EOD
<br><hr><br>
Name: $name <br>
Email: $email <br>
Comments: $comments <br>
EOD;
$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body,
$headers);


/* Results rendered as HTML */
$theResults = <<<EOD
<html>
<head>
<title>sent message</title>
<meta http-equiv="refresh" content="3;URL=http://www.reactionclaims.co.uk/contact2.html">
<style type="text/css">
<!--
body {
background-color: #444; /* You can edit this CSS to match your website*/
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 20px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #fec001;
text-decoration: none;
padding-top: 200px;
margin-left: 150px;
width: 800px;
}
-->
</style>
</head>
<div align="center">Thank you for contacting Reaction Claims, we will be in contact a.s.a.p.</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>Thanks for any help offered folks

I've been scouting around on google for a couple of days hoping i could work it out for myself

If you click on the contact us page then try and send something from the form, you'll see what the error message is

I'm not sure if the problem is from my end or from the servers end, more than likely mine '0)

if it's any help the hosting company is streamline.net

Corrosive
08-03-2010, 07:06 PM
Yep, it's not liking that is it...

The message is;

Notice: Undefined variable: name in E:\domains\r\reactionclaims.co.uk\user\htdocs\cont actformprocess.php on line 35

Warning: mail() [function.mail]: SMTP server response: 554 <stephen.redhead81@googlemail.com>: Recipient address rejected: Relay access denied in E:\domains\r\reactionclaims.co.uk\user\htdocs\cont actformprocess.php on line 41
Thank you for contacting Reaction Claims, we will be in contact a.s.a.p.

Not sure why it would be rejecting the address. Might be worth contacting the hosts.

kearnsy
08-03-2010, 09:32 PM
Thanks Corrosive

So by the look of things, it seems ok at my end?

edbr
08-04-2010, 02:23 AM
it maybe the server
server:Microsoft-IIS/6.0 x-powered-by:ASP.NET these servers seem to sometimes throw errors even though they claim to process php

kearnsy
08-05-2010, 11:37 AM
Hi Folks, i've contacted the server and spoke to support, and they seem reluctant to help me

Being unfamiliar with php i've not really got a clue what i'm going on about

I've tried two contact.php scripts now, and they both haven't worked

Any ideas on what to do next

Thanks

kearnsy
08-05-2010, 11:43 AM
Or failing that, does anyone know of a working script that i'll be able to use

Thanks folks

edbr
08-06-2010, 02:37 AM
the problem is not the script butfrom your server info
server:Microsoft-IIS/6.0 x-powered-by:ASP.NET

this may claim to process php but it is flawed as this has come up before
your optiions are
1. use a script tht your server has(if perhaps a perl script)
2 .use an asp script
3 . (my preference)change to a hosting that has an apache server and use the php script withiout any problem

kearnsy
08-09-2010, 01:51 PM
Thanks edbr, i scrapped the whole php thing and went with a simpler option

Thanks for all your input folks, much appreciated