I started a thread a couple of months ago about the contact forms on my client's website. Basically he wants me to overhaul the SEO on his site. However, there were problems with the PHP contact forms and I had to try to rectify them.
I have no experience in PHP coding so I turned to this forum for advice on fixing the problem. A few of the members kindly helped me out and I managed to fix the problem and get the contact forms to work. Here is the thread if anyone is interested:
http://www.phpfreaks.com/forums/index.php/topic,271795.msg1283238.html#msg1283238
Since then the hosting company has made changes to their system "to prevent spammer mass mailing." These changes mean that enquiries are being blocked if the user has a certain email address. Namely Yahoo, Hotmail, Google, AOL or FSnet. There may be more but those are the five I'm aware of.
The hosting company say an extra variable has to be added in the code to rectify this. They provided the following example on their website:
QuotePHP send mail scripts - Update. Possibly one of the most popular ways to send a form submission is the use of the PHP mail function. Due to a recent server update customers who choose to use this method will need to include an extra variable in their code.
What needs to be included is;
1. A variable that tells the script where the email is being sent from; For example; $SendEmail ="enquire@domainname.com";
2. Adding this variable onto the end of the mail() function. Below is a very basic php script, I have included the extra entries in italic.
$nameField = $_POST['name'];
$emailField = $_POST['email'];
$SendEmail ="enquiry@domainname.com";
$body = <<< EOD
Name: $nameField
Email: $emailField
EOD;
$headers = "From: $emailFieldrn";
$headers .= "Content-type: text/htmlrn";
$sucess = mail($webMaster, $emailSubject, $headers, $body, '-f'.$SendEmail);
The important part here is the '-f'.$SendEmail at the end of the mail() function. The '-f' although not a php command is a sendmail parameter that is telling our mailserver the mail is being sent from the $SendEmail address and nowhere else.
This is the relevant code from one of the contact forms on my client's site:
Code: <?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$mobphone = $_POST['mobphone'];
$town = $_POST['town'];
$county = $_POST['county'];
$voucher = $_POST['voucher'];
$propertyvalue = $_POST['propertyvalue'];
$mortgagetype = $_POST['mortgagetype'];
$hours1 = $_POST['hours1'];
$minutes1 = $_POST['minutes1'];
$date1 = $_POST['date1'];
$hours2 = $_POST['hours2'];
$minutes2 = $_POST['minutes2'];
$date2 = $_POST['date2'];
$info = $_POST['info'];
$sendemail = "Name: $name
Email address: $email
Phone number: $phone
Mobile number: $mobphone
Town: $town
County: $county
Voucher: $voucher
Purchase price / Property value: £$propertyvalue
Mortgage type: $mortgagetype
Callback 1: $hours1:$minutes1 - $date1
Callback 2: $hours2:$minutes2 - $date2
Extra info:
$info";
$subject = "Mortgage call back request from company x";
$mailheaders = "From:$emailn";
$mailheaders .= "Reply-To:$emailn";
$message="".stripslashes($message);
$subject=stripslashes($subject);
mail("info@companyx.co.uk",$subject,$sendemail,$mailheaders);
$status = "<span style="color:red;"><strong>Your call back request has been sent successfully.</strong><br />Thank you for contacting us. We aim to get back to you as you have specified.</span>";
}
?>
<h1>Company X Mortgages</h1>
<div class="maincont">
<? if ($status) { print "$status<br /><br /><br />n"; } ?>
<h2><strong>Local advice - It's never been so important.</strong></h2>
Speak to a qualified financial adviser in North Norfolk, South Norfolk, West Norfolk or North Suffolk.
Save money - Find the mortgage deal that's best for you.
Free Advice - Leaving you to choose your mortgage lender.
<h2>Request a Call Back</h2>
Please request a time you would like an adviser to call. We aim to return calls within one hour.
<script language="javascript" type="text/javascript">
function checkform() {
if (document.callback.hours1.value == '') { alert('Please enter a call back time'); return false; }
else if (document.callback.minutes1.value == '') { alert('Please enter a call back time'); return false; }
else if (document.callback.date1.value == '') { alert('Please enter a call back date'); return false; }
else if (document.callback.email.value == '') { alert('Please enter your email address'); return false; }
else if (document.callback.phone.value == '') { alert('Please enter your phone number'); return false; }
return true;
}
</script>
<form id="callback" name="callback" method="post" action="mortgages.php" style="display:inline;" onSubmit="return checkform()">
Your first choice:
<script language="javascript" type="text/javascript" src="datetimepicker.js"></script>
<select name="hours1" id="hours1">
<option value="" selected>--</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
</select>:<select name="minutes1" id="minutes1">
<option value="" selected>--</option>
<option value="00">00</option>
<option value="05">05</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
<option value="55">55</option>
</select>
<input name="date1" type="text" id="date1" size="10" />
<a href="javascript:NewCal('date1','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a> *
Your second choice:<br />
<select name="hours2" id="hours2">
<option value="--" selected>--</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
</select>:<select name="minutes2" id="minutes2">
<option value="--" selected>--</option>
<option value="00">00</option>
<option value="05">05</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
<option value="25">25</option>
<option value="30">30</option>
<option value="35">35</option>
<option value="40">40</option>
<option value="45">45</option>
<option value="50">50</option>
<option value="55">55</option>
</select>
<input name="date2" type="text" id="date2" size="10" />
<a href="javascript:NewCal('date2','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
Your name:
<input name="name" type="text" id="name" size="30" />
Your email address:
<input name="email" type="text" id="email" size="30" /> *
Your home phone number:
<input name="phone" type="text" id="phone" size="30" /> *
Your mobile phone number:
<input name="mobphone" type="text" id="mobphone" size="30" />
Your town:
<input name="town" type="text" id="town" size="30" />
Your county:
<input name="county" type="text" id="county" size="30" />
Voucher Code:
<input name="voucher" type="text" id="voucher" size="30" />
Mortgage amount:
£ <input name="propertyvalue" type="text" id="propertyvalue" size="25" />
Type of mortgage required:
<select name="mortgagetype" id="mortgagetype">
<option selected>Select One</option>
<option>-------------</option>
<option value="Remortgage">Remortgage</option>
<option value="Repayment">Repayment</option>
<option value="First time buyer">First time buyer</option>
<option value="Sert cert">Self cert</option>
<option value="Buy to Let">Buy to Let</option>
<option value="Interest Only">Interest Only</option>
<option value="Commercial">Commercial</option>
<option value="Let to Buy">Let to Buy</option>
<option value="Fast Track">Fast Track</option>
<option value="Holiday Let">Holiday Let</option>
<option value="Self Build">Self Build</option>
<option value="Renovation">Renovation</option>
<option value="Property Conversion">Property Conversion</option>
</select>
Different requirements:
<span style="font-size:12px;">If the service your require is not on the drop down list above, please describe it in the box below:</span>
<textarea name="info" cols="50" rows="5" id="info"></textarea>
<input type="submit" name="button" id="button" value="Confirm Call Back" />
</form>
Required fields are marked with a *</div>
Is there any way this code can be slightly tweaked to include the extra variable mentioned by the hosting company?
As I mentioned, I don't have any PHP experience so I don't want to try and create contact forms from scratch or significantly alter the existing forms.
Any help would be greatly appreciated.
Regards
help connecting a form to php and then emailing the form
Ok. So, I made a form, and I need help to where when submitted, I get an email with the submitted details. I have attached all the files you might need. The email should look like the 'Email.html'
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result
what is wrong with this Code: [Select]<?phpif ($_SERVER['HTTP_REFERER']){ if($_GET['id']) { $con = mysql_connect("","",""); if (!$con) {
form submit at godaddy?
Trying to test form submission at GoDaddy and it does not seem to work. Here's the page...http://brinsterinc.com/tireclick/test.phpHere's the source...Code:
Code doesn't print what i wanted it too. Please help!
Hi there,I wrote this code to mae it so that in the form before it that the user said their username and then on this page it matches up the username with the username on the database and then uses
Doubles are giving me problems
Ok so, first of all i made a double = 0.05, but when running the debugger it shows up as 0.04999. I know this has something to do with how doubles store but its causing problems for me. Anyway, in the
Inserting a check in checkbox from array value
Hello all,I have a bit of code that works for a select option box, but does not work for my checkboxes. I need multiple selections on this code and I really don't like the look of multiple select
Dynamically allocating the number of rows in a table based on a variable value
Hi, I have situation here which i cannot resolve, I have a variable temp which stores the number of rows in a array for example temp=5 which is calculated based on other values in my table( so temp
I need desperate help with this php code integrated with flash please
Can someone please help me with this php code which I have been stuck on for weeks . I am trying to send mail from a flash movie to an email address using php but the mail does not appear at the
Hyperlink is adding an extra gap to variable
Hi, here's my problem..I have a php generated page with a hyperlink which opens in a new windowecho "<tr><td><a
Need help PLEASE
ok i have this warning showing upWarning: in_array() [function.in-array]: Wrong datatype for second argument in /home/lalala/public_html/attack.php on line 72the code i use Code: [Select]//same ip