...

View Full Version : Contact form issue...



bos.the.golfer
12-16-2010, 08:32 PM
I am new to php and am building my own website. I have read a couple of books searched online and can't see what I did wrong if anything. The form is not mailing anything and when the submit button is clicked it just takes me to to a blank white page. I am checking with the host of the site to see if they have an answer for me as well. I would really appreciate it if you could take a look at my script to see if you notice what the issue might be. I really appreciate all your help and reply's.

Here is the url to my site to see the problem in action.

http://matthewbosick.com/contact.htm

Html script for the form :


<div id="content">
</br>
<form action="contactform.php" method="post" name="contactform" id="contactform">
<table width="100%" border="0" cellpadding="0">
<tr>
<td width="5%" align="right" valign="top">*</td>
<td width="6%" align="right">Name:</td>
<td width="89%" align="left"><input name="name" type="text" id="name3" size="35" maxlength="50" /></td>
</tr>
<tr>
<td align="right" valign="top">*</td>
<td align="right">Phone:</td>
<td align="left"><input name="phone" type="text" id="phone" size="35" maxlength="12" /></td>
</tr>
<tr>
<td align="right" valign="top">*</td>
<td align="right">Email:</td>
<td align="left"><input name="email" type="text" id="email" size="35" maxlength="60" /></td>
</tr>
<tr>
<td align="right" valign="top">&nbsp;</td>
<td align="right">I am:</td>
<td align="left"><p>
<label>
<input type="radio" name="type" value="Purchasing" id="type_0" />
Purchasing</label>
<br />
<label>
<input type="radio" name="type" value="Selling" id="type_1" />
Selling</label>
<br />
</p></td>
</tr>
<tr>
<td colspan="2" align="right" valign="top">&nbsp;</td>
<td align="left"><input name="financing" type="checkbox" id="financing" value="Yes" />
<label for="financing">I need help with my loan options.</label></td>
</tr>
<tr>
<td colspan="2" align="right" valign="top">&nbsp;</td>
<td align="left"><input name="first_time" type="checkbox" id="first_time" value="Yes" />
<label for="first_time">I am a first time home buyer.</label></td>
</tr>
<tr>
<td align="right" valign="top">*</td>
<td align="right" valign="top">Message:</td>
<td align="left" valign="top"><textarea name="message" id="message" cols="30" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="right" valign="top">&nbsp;</td>
<td align="left"><input name="submit" type="submit" id="submit" onclick="MM_validateForm('name3','','R','phone','','R','email','','RisEmail','message','','R');return document.MM_returnValue" value="Submit" /></td>
</tr>
<tr>
<td colspan="2" align="right" valign="top">&nbsp;</td>
<td align="left">&nbsp;</td>
</tr>
<tr>
<td colspan="2" align="right" valign="top">&nbsp;</td>
<td align="left">(*Required)</td>
</tr>
</table>
</form>

Php script for the form:


<?php

$emailSubject = 'contactform';
$webMaster = 'mbosick@selectmtg.net';

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$type = $_POST['type'];
$financing = $_POST['financing'];
$first_time = $_POST['first_time'];
$message = $_POST['message'];

$body=<<<EOD
<br><hr><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
I am: $type <br>
Need help with financing: $financing <br>
First home: $first_time <br>
Message: $message
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

$theResults=<<<EOD
<html>
<head>
<titlet>sent message</title>
<meta http-equiv="refresh" content="4;URL=http//matthewbosick.com/index.html">
<style type="text/css">
<!--
body{
background-color: #cccccc;
font-style: normal;
line-height: normal;
font-family: Arial, Helvetica, sans-serif;
font-size: 25 px;
font-color: #000;
padding-top: 300px;
}
-->
</style>
</head>
<div align="center">Thank you for your interest, your message has been sent and will be answered as soon as possible</div>
</body>
</html>
EOD;
echo "$theResults";
?>

mlseim
12-16-2010, 10:55 PM
The blank white page means you have a PHP script error,
and your error reporting is turned off. Turn it on using your
webhost control panel or try this at the top of your script ...

<?php
// Show all errors
error_reporting(E_ALL);




.

jmace
12-16-2010, 10:57 PM
At a glance:
The reason you are getting a blank page is probably because you have a fatal error and error reporting turned off on your server. Thus, it can't run and it also can show you the errors. If you turn error reporting on or check your php error log, you will be able to see a message telling you the problem.

One way you can turn on error reporting is to add this to top of your PHP file:

error_reporting(-1);

Try starting there and see what you get.

EDIT: Woah! You beat me to it. :-p

bos.the.golfer
12-17-2010, 04:53 PM
I appreciate the help. I did what you suggested and got the following errors:

20101217T113530: www.matthewbosick.com/contactform.php
PHP Notice: Undefined variable: headers in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 31

PHP Notice: Undefined variable: headers in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 32

PHP Notice: Undefined variable: success in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 33

PHP Notice: Undefined variable: body in /hermes/bosweb/web193/b1935/ipg.matthewbosickcom/contactform.php on line 33

PHP Notice: Undefined variable

I thought I had defined the variables. If you could give me some help to understand what is wrong with them it would be great.

Thanks again.:)

mlseim
12-17-2010, 05:11 PM
I normally don't use heredocs and nowdocs ....

Try this instead:


<?php

$emailSubject = 'contactform';
$webMaster = 'mbosick@selectmtg.net';

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$type = $_POST['type'];
$financing = $_POST['financing'];
$first_time = $_POST['first_time'];
$message = $_POST['message'];

$body="
<br><hr><br>
Name: $name <br>
Phone: $phone <br>
Email: $email <br>
I am: $type <br>
Need help with financing: $financing <br>
First home: $first_time <br>
Message: $message
";

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

$theResults="
<html>
<head>
<titlet>sent message</title>
<meta http-equiv='refresh' content='4;URL=http//matthewbosick.com/index.html'>
<style type='text/css'>
<!--
body{
background-color: #cccccc;
font-style: normal;
line-height: normal;
font-family: Arial, Helvetica, sans-serif;
font-size: 25 px;
font-color: #000;
padding-top: 300px;
}
-->
</style>
</head>
<div align='center'>Thank you for your interest, your message has been sent and will be answered as soon as possible</div>
</body>
</html>
";
echo "$theResults";
?>

bos.the.golfer
12-17-2010, 06:47 PM
That did it! :thumbsup: Thank you all for your help and time.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum