.PHP

  • Thread starter Thread starter MASSEY
  • Start date Start date
M

MASSEY

The head section is below

<?php

// This function checks for empty fields, email address format and strips out dodgy characters
function VerifyForm(&$values, &$errors)
{
if($values['gender'] != ''){die();}
$values['name'] = ereg_replace('[^A-Za-z0-9 ,.]', '', $values['name']);
$values['requests'] = ereg_replace('[^A-Za-z0-9 ,.?]', '', $values['requests']);

if(empty($values['name']))
$errors['name'] = 'Please enter your name';

if(preg_match( "/[^0-9 -+()]/", $values['telephone']))
$errors['telephone'] = 'Please check your telephone number';

if(empty($values['telephone']))
$errors['telephone'] = 'Please enter a telephone number';

if (!preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i", $values['email']) )
$errors['email'] = 'Please enter a valid Email address';

if($values['sums']<>9)
$errors['sums'] = 'Try again';

return (count($errors) == 0);
}

// This function displays the contact form.
// After the 'send' button has been pressed, errors are checked and the fields that need correcting indicated.
function DisplayForm($values, $errors)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="description" content="Electricians in Birmingham with over 20 years experience. For a proper legally certified installation contact our Birmingham Electricians on 0121 429 1586"/>
<meta name="keywords" content="Birmingham Electrician,Electrician Birmingham,Electrical Contractors Birmingham,Birmingham Electrical Contractors,Electrician,Birmingham,Electrician Solihull"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Birmingham Electrician | Electrician in Birmingham | Full and Partial House Rewires</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
 
<body>
<div id="wrapper">
<div id="banner">
<div id="logo">
<p id="l-title">C&amp;N Property Solutions Ltd</p>
</div><!-- logo -->
<div id="phone">
<p id="p-title">Give us a call today:</p>
<p class="tel">0121 429 1586</p>
<p class="tel">0794 427 8294</p>
<br/>
</div><!-- phone -->
</div><!-- banner -->
<div id="nav-menu">
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians-Birmingham.html">About us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="#">Recent News</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="#">References</a></li>
<li><a href="#">Links</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<img src="Electrician-Bham.png" alt="For Quality Electricians Birmingham Please Call 0121 429 1586" title="Birmingham Electrician" />
</div>
<h1>Contact Form</h1>
<?php
if (count($errors) > 0)
echo "<p>Please correct the errors highlighted below in red.</p>";
else
echo "<p>Please fill out the form below and if neccessary we will get back to you as soon as possible.</p>";
?>
<form action="<?= $_SERVER['PHP_SELF'] ?>" method="POST">
<table>
<tr>
<td>
<p>Your Name:</p>
<p class="error">
<?= $errors['name'] ?>
</p>
<p>
<input type="text" size="30" name="name" value="<?= htmlentities($values['name']) ?>"/>
</p>
</td>
</tr>
<tr>
<td>
<p>Email:</p>
<p class="error">
<?= $errors['email'] ?>
</p>
<p>
<input type="text" size="30" name="email" value="<?= htmlentities($values['email']) ?>"/>
</p>
</td>
</tr>
<tr>
<td>
<p>Telephone:</p>
<p class="error">
<?= $errors['telephone'] ?>
</p>
<p>
<input type="text" size="20" name="telephone" value="<?= htmlentities($values['telephone']) ?>"/>
</p>
</td>
</tr>
<tr>
<td>
<p>Message:</p>
<p>
<textarea name="requests" rows="5" cols="40"></textarea>
</p>
</td>
</tr>
<td>
<p>What is 5 + 4?</p>
<p class="error">
<?= $errors['sums'] ?>
</p>
<p>
<input type="text" size="5" name="sums" value="<?= htmlentities($values['sums']) ?>"/>
Just making sure you aren't a robot</p>
</td>
</tr>
<tr class="label3">
<td>
<p>Gender</p>
<p>
<input type="text" name="gender" value="<?= htmlentities($values['gender']) ?>"/>
</p>
</td>
</tr>
<tr>
<td>
<p>
<input type="submit" value="Send Message">
</p>
</td>
</tr>
</table>
</form>
<p>
<center>
<ul id="body-logo">
<li><img src="Electricians-In-Birmingham.jpg" alt="NICEIC The Regulatory Bodies for Electricians Birmingham And The UK" title="NICEIC Birmingham Electricians" /></li>
<li><img src="part-logo.jpg" alt="Part P Is A System Our Birmingham Electrician Services Adhere To" title="Part P Birmigham Electricians" /></li>
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians.html">About Us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div><!-- col-left -->
<div id="col-right">
<h4>Common Questions</h4>
<ul>
<li><a href="What-Is-An-RCD-Birmingham.html">What is an RCD?</a></li>
<li><a href="#">Why Does My Electric Keep Cutting Out?</a></li>
<li><a href="What-Is-The-Earthing-System-Birmingham.html">What Is Earthing?</a></li>
<li><a href="How-Much-Is-A-House-Rewire-Birmingham.html">How Much Is A House Rewire?</a></li>
<li><a href="#">Read More questions...</a></li>
</ul>
<br/>
<br/>
</div><!-- col-right -->
</div><!-- content -->
<div id="footer">
<p>&copy;2009-2010 C&amp;N Property Solutions Ltd | Great Barr, Birmingham Electricians | Registered in England &amp; Wales No. 06864828 | All Rights Reserved</p>
<p><a href="#">Terms And Conditions</a></p>
</div>
</div><!-- wrapper -->
</body>
</html>
 
Upvote 0
<?php
}
// This function processes the email form.
// The message is formatted as a table and sent to your email address.
function ProcessForm($values)
{
$subject = "Enquiry from {$values['name']}";
$headers = "From: {$values['name']}<{$values['email']}>\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message = "<html><h2>Enquiry from {$values['name']}</h2><table border=\"1\" width=\"60%\">";
$message .= "<tr><td width='50px'>Email:</td><td>{$values['email']}</td></tr>";
$message .= "<tr><td width='50px'>Telephone:</td><td>{$values['telephone']}</td></tr>";
$message .= "<tr><td width='50px'>Message:</td><td>{$values['requests']}</td></tr>";
$message .= "</table></html>";

// Change this to your email address
mail('[email protected]', $subject, $message, $headers);

// This bit of the function displays the thank you message.

echo"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="description" content="Electricians in Birmingham with over 20 years experience. For a proper legally certified installation contact our Birmingham Electricians on 0121 429 1586"/>
<meta name="keywords" content="Birmingham Electrician,Electrician Birmingham,Electrical Contractors Birmingham,Birmingham Electrical Contractors,Electrician,Birmingham,Electrician Solihull"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Birmingham Electrician | Electrician in Birmingham | Full and Partial House Rewires</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="wrapper">
<div id="banner">
<div id="logo">
<p id="l-title">C&amp;N Property Solutions Ltd</p>
</div><!-- logo -->
<div id="phone">
<p id="p-title">Give us a call today:</p>
<p class="tel">0121 429 1586</p>
<p class="tel">0794 427 8294</p>
<br/>
</div><!-- phone -->
</div><!-- banner -->
<div id="nav-menu">
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians-Birmingham.html">About us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="#">Recent News</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="#">References</a></li>
<li><a href="#">Links</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<div id="content">
<div id="col-left">
<h1>Your Message Has Been Sent</h1>
<p>Thank you for your enquiry, {$values['name']}.</p>
<p>Your email address is: {$values['email']}.</p>
<p>Your telephone number is: {$values['telephone']}.</p>
<p>We will be in contact soon</p>
<p>
<center><ul id="body-logo">
<li><img src="Electricians-In-Birmingham.jpg" alt="NICEIC The Regulatory Bodies for Electricians Birmingham And The UK" title="NICEIC Birmingham Electricians" /></li>
<li><img src="part-logo.jpg" alt="Part P Is A System Our Birmingham Electrician Services Adhere To" title="Part P Birmigham Electricians" /></li>
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians.html">About Us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div><!-- col-left -->
<div id="col-right">
<h4>Common Questions</h4>
<ul>
<li><a href="What-Is-An-RCD-Birmingham.html">What is an RCD?</a></li>
<li><a href="#">Why Does My Electric Keep Cutting Out?</a></li>
<li><a href="What-Is-The-Earthing-System-Birmingham.html">What Is Earthing?</a></li>
<li><a href="How-Much-Is-A-House-Rewire-Birmingham.html">How Much Is A House Rewire?</a></li>
<li><a href="#">Read More questions...</a></li>
</ul>
<br/>
<br/>
</div><!-- col-right -->
</div><!-- content -->
<div id="footer">
<p>&copy;2009-2010 C&amp;N Property Solutions Ltd | Great Barr, Birmingham Electricians | Registered in England &amp; Wales No. 06864828 | All Rights Reserved</p>
<p><a href="#">Terms And Conditions</a></p>
</div>
</div><!-- wrapper -->
</body>
</html>";
}
// This is the bit that does all the work.
// It displays the form, calls the error checker and if all OK processes and sends the email.
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();

if (!VerifyForm($formValues, $formErrors))
DisplayForm($formValues, $formErrors);
else
ProcessForm($formValues);
}
else
DisplayForm(null, null);
?>
 
Upvote 0
Have a look at the page you are validating mate:
http://www.electrician-birmingham.com/contact.php

There is an error. The validation error is with the code PHP is throwing out. Fix that and validate it. Reason you are getting that is because you are echoing with " around it and you code contains " so your php does not know where the start and end are. If you have " inside the echo, you would need to put \".

Example:

echo "<a href=\"some link\">text</a>"
echo '<a href="some link">text</a>'

Same applies to apostrophes when you have them in your Javascript.

Best thing would be to take out the echo and end the PHP.

Hope thats helpful.
 
  • Like
Reactions: MASSEY
Upvote 0
So you think i should remove line 213


echo"<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

Jus wanna double check :)
 
Upvote 0
No.

Try the following for the last bit (I think from 211):

// This bit of the function displays the thank you message.

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="description" content="Electricians in Birmingham with over 20 years experience. For a proper legally certified installation contact our Birmingham Electricians on 0121 429 1586"/>
<meta name="keywords" content="Birmingham Electrician,Electrician Birmingham,Electrical Contractors Birmingham,Birmingham Electrical Contractors,Electrician,Birmingham,Electrician Solihull"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Birmingham Electrician | Electrician in Birmingham | Full and Partial House Rewires</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="wrapper">
<div id="banner">
<div id="logo">
<p id="l-title">C&amp;N Property Solutions Ltd</p>
</div><!-- logo -->
<div id="phone">
<p id="p-title">Give us a call today:</p>
<p class="tel">0121 429 1586</p>
<p class="tel">0794 427 8294</p>
<br/>
</div><!-- phone -->
</div><!-- banner -->
<div id="nav-menu">
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians-Birmingham.html">About us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="#">Recent News</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="#">References</a></li>
<li><a href="#">Links</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<div id="content">
<div id="col-left">
<h1>Your Message Has Been Sent</h1>
<p>Thank you for your enquiry, {$values['name']}.</p>
<p>Your email address is: {$values['email']}.</p>
<p>Your telephone number is: {$values['telephone']}.</p>
<p>We will be in contact soon</p>
<p>
<center><ul id="body-logo">
<li><img src="Electricians-In-Birmingham.jpg" alt="NICEIC The Regulatory Bodies for Electricians Birmingham And The UK" title="NICEIC Birmingham Electricians" /></li>
<li><img src="part-logo.jpg" alt="Part P Is A System Our Birmingham Electrician Services Adhere To" title="Part P Birmigham Electricians" /></li>
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians.html">About Us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div><!-- col-left -->
<div id="col-right">
<h4>Common Questions</h4>
<ul>
<li><a href="What-Is-An-RCD-Birmingham.html">What is an RCD?</a></li>
<li><a href="#">Why Does My Electric Keep Cutting Out?</a></li>
<li><a href="What-Is-The-Earthing-System-Birmingham.html">What Is Earthing?</a></li>
<li><a href="How-Much-Is-A-House-Rewire-Birmingham.html">How Much Is A House Rewire?</a></li>
<li><a href="#">Read More questions...</a></li>
</ul>
<br/>
<br/>
</div><!-- col-right -->
</div><!-- content -->
<div id="footer">
<p>&copy;2009-2010 C&amp;N Property Solutions Ltd | Great Barr, Birmingham Electricians | Registered in England &amp; Wales No. 06864828 | All Rights Reserved</p>
<p><a href="#">Terms And Conditions</a></p>
</div>
</div><!-- wrapper -->
</body>
</html>
<?php }
// This is the bit that does all the work.
// It displays the form, calls the error checker and if all OK processes and sends the email.
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();

if (!VerifyForm($formValues, $formErrors))
DisplayForm($formValues, $formErrors);
else
ProcessForm($formValues);
}
else
DisplayForm(null, null);
?>
 
Last edited:
  • Like
Reactions: MASSEY
Upvote 0
Thats got it to come up now :D,

Ive cocked up somewhere, but i was doing it at 2am,

Sanj if you submit on the form when you go to the success page it reveals code where there should be words do you know why that is, if you just type randon stuff into the form and hit send you will see it,

thanks for your help pal
 
Upvote 0
Sorry try:

// This bit of the function displays the thank you message.

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta name="description" content="Electricians in Birmingham with over 20 years experience. For a proper legally certified installation contact our Birmingham Electricians on 0121 429 1586"/>
<meta name="keywords" content="Birmingham Electrician,Electrician Birmingham,Electrical Contractors Birmingham,Birmingham Electrical Contractors,Electrician,Birmingham,Electrician Solihull"/>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1" />
<title>Birmingham Electrician | Electrician in Birmingham | Full and Partial House Rewires</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="http://cloud.github.com/downloads/malsup/cycle/jquery.cycle.all.2.74.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.slideshow').cycle({
fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div id="wrapper">
<div id="banner">
<div id="logo">
<p id="l-title">C&amp;N Property Solutions Ltd</p>
</div><!-- logo -->
<div id="phone">
<p id="p-title">Give us a call today:</p>
<p class="tel">0121 429 1586</p>
<p class="tel">0794 427 8294</p>
<br/>
</div><!-- phone -->
</div><!-- banner -->
<div id="nav-menu">
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians-Birmingham.html">About us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="#">Recent News</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="#">References</a></li>
<li><a href="#">Links</a></li>
<li><a href="contact.php">Contact us</a></li>
</ul>
</div>
<div id="content">
<div id="col-left">
<h1>Your Message Has Been Sent</h1>
<p>Thank you for your enquiry, <?= $values['name'] ?>.</p>
<p>Your email address is: <?= $values['email'] ?>.</p>
<p>Your telephone number is: <?= $values['telephone'] ?>.</p>
<p>We will be in contact soon</p>
<p>
<center><ul id="body-logo">
<li><img src="Electricians-In-Birmingham.jpg" alt="NICEIC The Regulatory Bodies for Electricians Birmingham And The UK" title="NICEIC Birmingham Electricians" /></li>
<li><img src="part-logo.jpg" alt="Part P Is A System Our Birmingham Electrician Services Adhere To" title="Part P Birmigham Electricians" /></li>
<ul>
<li><a href="Index.html">Home</a></li>
<li><a href="About-Us-Electricians.html">About Us</a></li>
<li><a href="Rewiring-Birmingham-Electrician.html">Rewiring</a></li>
<li><a href="Electrical-Testing-Birmingham.html">Testing</a></li>
<li><a href="Areas-Covered-Birmingham.html">Areas Covered</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div><!-- col-left -->
<div id="col-right">
<h4>Common Questions</h4>
<ul>
<li><a href="What-Is-An-RCD-Birmingham.html">What is an RCD?</a></li>
<li><a href="#">Why Does My Electric Keep Cutting Out?</a></li>
<li><a href="What-Is-The-Earthing-System-Birmingham.html">What Is Earthing?</a></li>
<li><a href="How-Much-Is-A-House-Rewire-Birmingham.html">How Much Is A House Rewire?</a></li>
<li><a href="#">Read More questions...</a></li>
</ul>
<br/>
<br/>
</div><!-- col-right -->
</div><!-- content -->
<div id="footer">
<p>&copy;2009-2010 C&amp;N Property Solutions Ltd | Great Barr, Birmingham Electricians | Registered in England &amp; Wales No. 06864828 | All Rights Reserved</p>
<p><a href="#">Terms And Conditions</a></p>
</div>
</div><!-- wrapper -->
</body>
</html>
<?php }
// This is the bit that does all the work.
// It displays the form, calls the error checker and if all OK processes and sends the email.
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
$formValues = $_POST;
$formErrors = array();

if (!VerifyForm($formValues, $formErrors))
DisplayForm($formValues, $formErrors);
else
ProcessForm($formValues);
}
else
DisplayForm(null, null);
?>
 
Last edited:
  • Like
Reactions: MASSEY
Upvote 0
Fellas

Just a quick tip - not on the code, but on posting on the forum, if you are posting code in a thread, click on the # button on the tool bar:

picture.php


it allows you to insert code into your post like this:

Code:
<?php
 
 // This function checks for empty fields, email address format and strips out dodgy characters
 function VerifyForm(&$values, &$errors)
  {
  if($values['gender'] != ''){die();}
  $values['name'] = ereg_replace('[^A-Za-z0-9 ,.]', '', $values['name']);
  $values['requests'] = ereg_replace('[^A-Za-z0-9 ,.?]', '', $values['requests']);
  
  if(empty($values['name']))
         $errors['name'] = 'Please enter your name';
   
  if(preg_match( "/[^0-9 -+()]/", $values['telephone']))
   $errors['telephone'] = 'Please check your telephone number';
   
  if(empty($values['telephone']))
         $errors['telephone'] = 'Please enter a telephone number';
 
  if (!preg_match("/^[a-z0-9]+([_\\.-][a-z0-9]+)*@([a-z0-9]+([\.-][a-z0-9]+)*)+\\.[a-z]{2,}$/i", $values['email']) )
   $errors['email'] = 'Please enter a valid Email address';
   
  if($values['sums']<>9)
         $errors['sums'] = 'Try again';
   
     return (count($errors) == 0);
  }
Hope that helps

Jeff
 
  • Like
Reactions: MASSEY and sanjiv
Upvote 0
Sorry sanj i didnt see you had posted again , that works fine!,

Jus gotta sort the distortion out now and fix my errors ;-(

Cheers you saved me a lot of time ,
 
Upvote 0
doh, don't use a table for a form!

Use a field set, also use labels for your inputs otherwise you will fail WAI requirements
Using a strict doctype is not very forgiving, feex thee err0rs :)

Instead of hard-coding 2010 you can do
Code:
<?php echo date("Y"); ?>
The footer should also be in an include file so you can reuse code across the site.
 
Upvote 0
I know there is something wrong because the sucess page for the form submission looks different, I deleted stuff to try get the form where it needed to go,

is it the original code that's in a table? I'm gOnna have to mess with this tonite :(
 
Upvote 0
The distortion is because the whole form should be in <div id="content">

Also your what is 5 + 4 won't stop robots as it is not dynamic.
 
Upvote 0
Also your what is 5 + 4 won't stop robots as it is not dynamic.
Always looking to improve my filtering - how do you make something like this dynamic?
 
Upvote 0
Always looking to improve my filtering - how do you make something like this dynamic?

Do you agree it won't stop robots fisicx?

I suppose an extra would be to input the email into the form with the code for each letter,
 
Upvote 0
The distortion is because the whole form should be in <div id="content">

Also your what is 5 + 4 won't stop robots as it is not dynamic.

I'm gonna input the code you gave me yesterday around tha page code again I messed it up somewhere lol
 
Upvote 0
Upvote 0
The way to make it dynamic is to introduce a session id, salted hidden pwd built up from sessionid, date, word & time so that you know it will expire, pretty much like a nonce.
It won't completely stop bots but it's a good preventative.
You can also look at denying some bots via htaccess file for the contact page if it gets really bad.
 
Upvote 0
Ooooo, nice. Thanks Sanjiv

A bit of a fiddle integrating the php into the existing error checking but I like it.
 
  • Like
Reactions: sanjiv
Upvote 0
You guys lose me with all this wizz tech chat:redface:
Don't worry it's all a bluff!

What the thingy does is generate a sum for the contact form. It's an image so the robots can't scan it and all the visitor has to do is work out the answer. It's not all weirdy writing like most captchas is is dead easy to use (as long as you can do simple maffs).

Gonna put it on my test form to play with then send you a copy as promised.
 
  • Like
Reactions: MASSEY
Upvote 0
Don't worry it's all a bluff!

What the thingy does is generate a sum for the contact form. It's an image so the robots can't scan it and all the visitor has to do is work out the answer. It's not all weirdy writing like most captchas is is dead easy to use (as long as you can do simple maffs).

Gonna put it on my test form to play with then send you a copy as promised.


Thanks that would be helpful, got so much to do, I don't think I'm ever gonna get round to my plumbing site :rolleyes: This weekend I'm gonna put some hours in.
 
Upvote 0

Latest Articles