 |
|
|
|
|
Junior Member
|
|
Posts: 23
Join Date: Mar 2012
|
|
|
Contact Form Validation -
08-19-2012, 01:33 AM
OK! G'day Programmers,
I am of a rather recent learner of php and still have difficulty with my programming.
I'll begin by saying this was a contact form and validation which i developed for my own personal site:
http://www.angelpoetry.org/contact.php
This original code goes like this:
contact.php
Code:
<!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=utf-8" />
<meta name="robots" content="noindex, nofollow"/>
<title>Angel Poetry | Contact</title>
<link rel="stylesheet" href="style.css" type="text/css" charset="utf-8" />
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-31344719-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
<div id="fb-root"></div>
<script type="text/javascript">(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<div id="wrapper">
<div id="body">
<div id="body-top">
<div id="body-bot">
<div id="header">
<h1><img src="images/logo.gif" width="259" height="107" alt="Angel Poetry" /></h1>
<br />
<br />
<ul>
<li><a href="http://www.angelpoetry.org/index.html">Home</a></li>
<li><a href="http://www.angelpoetry.org/bio.html">Biography</a></li>
<li><a href="http://www.angelpoetry.org/poetry_date.html">Poetry</a></li>
<li><a href="http://www.angelpoetry.org/prose.html">Prose Ficton</a></li>
<li><a href="http://www.angelpoetry.org/novel.html">Novels</a></li>
<li><a href="http://www.angelpoetry.org/graphic.html">Graphics</a></li>
<li><a href="http://www.angelpoetry.org/contact.php">Contact</a></li>
</ul>
<!-- <div id="allpoetrylistcontainer">
<a href="https://www.facebook.com/pages/Jock-IT/138436612894341" target="_blank"><img src="website_under_construction_jock_it.png" alt="Under Construction" width="512px" /></a>
</div>
-->
<?php include('includes/contact_form.php'); ?>
<br />
<br />
<div class="clear"></div>
<ul>
<li><a href="http://www.angelpoetry.org/index.html">Home</a></li>
<li><a href="http://www.angelpoetry.org/bio.html">Biography</a></li>
<li><a href="http://www.angelpoetry.org/poetry_date.html">Poetry</a></li>
<li><a href="http://www.angelpoetry.org/prose.html">Prose Ficton</a></li>
<li><a href="http://www.angelpoetry.org/novel.html">Novels</a></li>
<li><a href="http://www.angelpoetry.org/graphic.html">Graphics</a></li>
<li><a href="http://www.angelpoetry.org/contact.php">Contact</a></li>
</ul>
</div>
<div id="tray">
<div class="fb-like" data-href="http://angelpoetry.org/prose.html" data-send="true" data-width="450" data-show-faces="true" data-colorscheme="dark" data-font="arial"></div>
<div class="fb-comments" data-href="http://angelpoetry.org/prose.html" data-num-posts="2" data-width="512" data-colorscheme="dark"></div>
<div class="clear"></div>
</div>
<div id="footer">
<div id="footer-right">
copyright Jock Engelman. All rights reserved.
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
includes/contact_form.php
Code:
<div id="contact_form_wrap">
<span class="message"><?php echo $message_text; ?></span>
<?php echo $errors; ?>
<?php if(isset($_GET['sent'])): ?><h2>Your message has been sent</h2><?php endif; ?>
<form id="contact_form" method="post" action="includes/contact_form_send.php">
<p><label>Name:<br />
<input type="text" name="name" class="textfield" value="<?php echo htmlentities($name); ?>" />
</label><br /><span class="errors"><?php echo $nameErr; ?></span></p>
<p><label>Email: <br />
<input type="text" name="email" class="textfield" value="<?php echo htmlentities($email); ?>" />
</label><br /><span class="errors"><?php echo $emailErr ?></span></p>
<p><label>Message: <br />
<textarea name="message" class="textarea" cols="45" rows="5"><?php echo htmlentities($message); ?></textarea>
</label><br /><span class="errors"><?php echo $messageErr ?></span></p>
<p><input type="submit" name="submit" class="button" value="Submit" /></p>
</form>
</div>
includes/contact_form_send.php
Code:
<?php
define("EMAIL", "webenquiry@angelpoetry.org");
if(isset($_POST['submit'])) {
include('validate.class.php');
//assign post data to variables
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$message = trim($_POST['message']);
//start validating our form
$v = new validate();
$v->validateStr($name, "name", 3, 75);
$v->validateEmail($email, "email");
$v->validateStr($message, "message", 5, 1000);
if(!$v->hasErrors()) {
$header = "From: $email\n" . "Reply-To: $email\n";
$subject = "Contact Form Subject";
$email_to = EMAIL;
$emailMessage = "Name: " . $name . "\n";
$emailMessage .= "Email: " . $email . "\n\n";
$emailMessage .= $message;
//use php's mail function to send the email
@mail($email_to, $subject ,$emailMessage ,$header );
//grab the current url, append ?sent=yes to it and then redirect to that url
$url = "http". ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
header('Location: '.$url."?sent=yes");
} else {
//set the number of errors message
$message_text = $v->errorNumMessage();
//store the errors list in a variable
$errors = $v->displayErrors();
//get the individual error messages
$nameErr = $v->getError("name");
$emailErr = $v->getError("email");
$messageErr = $v->getError("message");
}//end error check
}// end isset
?>
<script language="javascript" type="text/javascript">
// Print a message
alert('Thank you for the message. We will contact you shortly.');
// Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com
window.location = '../contact.php';
</script>
|
|
Junior Member
|
|
Posts: 23
Join Date: Mar 2012
|
|
|

08-19-2012, 01:35 AM
I ran out of space for the question:
includes/validate.class.php
Code:
<?php
class validate {
// ---------------------------------------------------------------------------
// paramaters
// ---------------------------------------------------------------------------
/**
* Array to hold the errors
*
* @access public
* @var array
*/
public $errors = array();
// ---------------------------------------------------------------------------
// validation methods
// ---------------------------------------------------------------------------
/**
* Validates a string
*
* @access public
* @param $postVal - the value of the $_POST request
* @param $postName - the name of the form element being validated
* @param $min - minimum string length
* @param $max - maximum string length
* @return void
*/
public function validateStr($postVal, $postName, $min = 5, $max = 500) {
if(strlen($postVal) < intval($min)) {
$this->setError($postName, ucfirst($postName)." must be at least {$min} characters long.");
} else if(strlen($postVal) > intval($max)) {
$this->setError($postName, ucfirst($postName)." must be less than {$max} characters long.");
}
}// end validateStr
/**
* Validates an email address
*
* @access public
* @param $emailVal - the value of the $_POST request
* @param $emailName - the name of the email form element being validated
* @return void
*/
public function validateEmail($emailVal, $emailName) {
if(strlen($emailVal) <= 0) {
$this->setError($emailName, "Please enter an Email Address");
} else if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $emailVal)) {
$this->setError($emailName, "Please enter a Valid Email Address");
}
}// end validateEmail
// ---------------------------------------------------------------------------
// error handling methods
// ---------------------------------------------------------------------------
/**
* sets an error message for a form element
*
* @access private
* @param string $element - name of the form element
* @param string $message - error message to be displayed
* @return void
*/
private function setError($element, $message) {
$this->errors[$element] = $message;
}// end logError
/**
* returns the error of a single form element
*
* @access public
* @param string $elementName - name of the form element
* @return string
*/
public function getError($elementName) {
if($this->errors[$elementName]) {
return $this->errors[$elementName];
} else {
return false;
}
}// end getError
/**
* displays the errors as an html un-ordered list
*
* @access public
* @return string: A html list of the forms errors
*/
public function displayErrors() {
$errorsList = "<ul class=\"errors\">\n";
foreach($this->errors as $value) {
$errorsList .= "<li>". $value . "</li>\n";
}
$errorsList .= "</ul>\n";
return $errorsList;
}// end displayErrors
/**
* returns whether the form has errors
*
* @access public
* @return boolean
*/
public function hasErrors() {
if(count($this->errors) > 0) {
return true;
} else {
return false;
}
}// end hasErrors
/**
* returns a string stating how many errors there were
*
* @access public
* @return void
*/
public function errorNumMessage() {
if(count($this->errors) > 1) {
$message = "There were " . count($this->errors) . " errors sending your message!\n";
} else {
$message = "There was an error sending your message!\n";
}
return $message;
}// end hasErrors
}// end class
The reason why i show you this code is to show you what i have when it is working.
|
|
Junior Member
|
|
Posts: 23
Join Date: Mar 2012
|
|
|

08-19-2012, 01:36 AM
But this is a website i am developing for a family friend:
http://www.cutmoreproperty.com/contact.php
and here is the code: (same file structure)
contact.php
Code:
<!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" xml:lang="en" lang="en">
<head>
<?php include('includes/meta.php'); ?>
<?php include('includes/styles.php'); ?>
<?php include('styles.php'); ?>
<title>Jock It PHP Template | Home</title>
<!-- jQuery -->
<script src="image_slider/ajax/libs/jquery/1.7/jquery.min.js"></script>
<!-- Anything Slider optional plugins -->
<script src="image_slider/js/jquery.easing.1.2.js"></script>
<!-- Anything Slider -->
<link href="image_slider/css/anythingslider.css" rel="stylesheet">
<script src="image_slider/js/jquery.anythingslider.min.js"></script>
<!-- ColorBox -->
<link href="image_slider/demos/colorbox/colorbox.css" rel="stylesheet">
<script src="image_slider/demos/colorbox/jquery.colorbox-min.js"></script>
<script type="text/javascript">
$(function(){
$('#slider1')
.anythingSlider({
toggleControls : true,
theme : 'metallic',
navigationFormatter : function(i, panel){ // add thumbnails as navigation links
return '<img src="demos/images/th-slide-' + ['civil-1', 'env-1', 'civil-2', 'env-2'][i - 1] + '.jpg">';
}
})
// target all images inside the current slider
// replace with 'img.someclass' to target specific images
.find('.panel:not(.cloned) img') // ignore the cloned panels
.attr('rel','group') // add all slider images to a colorbox group
.colorbox({
width: '90%',
height: '90%',
href: function(){ return $(this).attr('src'); },
// use $(this).attr('title') for specific image captions
title: 'Press escape to close',
rel: 'group'
});
});
</script>
<style type="text/css">
/* New in version 1.7+ */
#slider1 {
width: 400px;
height: 300px;
list-style: none;
}
/* CSS to expand the image to fit inside colorbox */
#cboxPhoto { width: 100%; height: 100%; margin: 0 !important; }
/* Change metallic theme defaults to show thumbnails -
using #demo2 (page wrapper) to increase this CSS priority */
.anythingSlider-metallic .thumbNav a {
background-image: url();
height: 30px;
width: 30px;
border: #000 1px solid;
border-radius: 2px;
-moz-border-radius: 2px;
-webkit-border-radius: 2px;
text-indent: 0;
}
.anythingSlider-metallic .thumbNav a span {
visibility: visible; /* span changed to visibility hidden in v1.7.20 */
}
/* border around link (image) to show current panel */
#demo2 .anythingSlider-metallic .thumbNav a:hover,
#demo2 .anythingSlider-metallic .thumbNav a.cur {
border-color: #fff;
}
/* reposition the start/stop button */
#demo2 .anythingSlider-metallic .start-stop {
margin-top: 15px;
}
</style>
</head>
<body>
<div id="sombra">
<div id="superiorsombra">
<div id="superior" class="clearfix">
<div class="wrapper">
</div><!-- wrapper -->
</div><!-- superior -->
</div><!-- superiorsombra -->
<div class="wrapper">
<!-- <div class="separador"></div> -->
<?php include('includes/header.php'); ?>
<?php include('includes/nav.php'); ?>
<div id="contentbg">
<div id="content">
<h1>Contact Me</h1>
<?php include('includes/contact_form.php'); ?>
<br />
<br />
<p>Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. Nam at nunc lectus, id vulputate purus. In et turpis ac mauris viverra iaculis. Cras sed elit a purus ultrices iaculis eget sit amet dolor. Praesent ac libero dolor, id viverra libero. Mauris aliquam nibh vitae eros sodales fermentum. Fusce cursus est varius ante vehicula eget ultrices felis eleifend. Nunc pharetra rutrum nibh et lobortis. Morbi vitae venenatis velit.</p>
<p>Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. Nam at nunc lectus, id vulputate purus. In et turpis ac mauris viverra iaculis. Cras sed elit a purus ultrices iaculis eget sit amet dolor. Praesent ac libero dolor, id viverra libero. Mauris aliquam nibh vitae eros sodales fermentum. Fusce cursus est varius ante vehicula eget ultrices felis eleifend. Nunc pharetra rutrum nibh et lobortis. Morbi vitae venenatis velit.</p>
<h3>Another Heading Starting Point</h3>
<p>Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. Nam at nunc lectus, id vulputate purus. In et turpis ac mauris viverra iaculis. Cras sed elit a purus ultrices iaculis eget sit amet dolor. Praesent ac libero dolor, id viverra libero. Mauris aliquam nibh vitae eros sodales fermentum. Fusce cursus est varius ante vehicula eget ultrices felis eleifend. Nunc pharetra rutrum nibh et lobortis. Morbi vitae venenatis velit.</p>
<p>Quisque pellentesque sodales aliquam. Morbi mollis neque eget arcu egestas non ultrices neque volutpat. Nam at nunc lectus, id vulputate purus. In et turpis ac mauris viverra iaculis. Cras sed elit a purus ultrices iaculis eget sit amet dolor. Praesent ac libero dolor, id viverra libero. Mauris aliquam nibh vitae eros sodales fermentum. Fusce cursus est varius ante vehicula eget ultrices felis eleifend. Nunc pharetra rutrum nibh et lobortis. Morbi vitae venenatis velit.</p>
</div> <!-- end #content -->
<?php include('includes/sidebar.php'); ?>
<?php include('includes/footer.php'); ?>
</div>
<br />
<br />
<div class="separador">
</div>
</div><!-- wrapper -->
<div id="footerborder">
<div id="footer" class="clearfix">
<div class="wrapper">
</div><!-- wrapper -->
</div><!-- footer -->
</div><!-- footerborder -->
</div><!-- sombra -->
</body>
</html>
includes/contact_form.php
Code:
<div id="contact_form_wrap">
<span class="message"><?php echo $message_text; ?></span>
<?php echo $errors; ?>
<?php if(isset($_GET['sent'])): ?><h2>Your message has been sent</h2><?php endif; ?>
<form id="contact_form" method="post" action="includes/contact_form_send.php">
<p><label>First Name:<br />
<input type="text" name="firstname" class="textfield" value="<?php echo htmlentities($firstname); ?>" />
</label><br /><span class="errors"><?php echo $firstnameErr; ?></span></p>
<p><label>Surname:<br />
<input type="text" name="surname" class="textfield" value="<?php echo htmlentities($surname); ?>" />
</label><br /><span class="errors"><?php echo $surnameErr; ?></span></p>
<p><label>Email: <br />
<input type="text" name="email" class="textfield" value="<?php echo htmlentities($email); ?>" />
</label><br /><span class="errors"><?php echo $emailErr ?></span></p>
<p><label>Contact Number:<br />
<input type="text" name="contactnumber" class="textfield" value="<?php echo htmlentities($contactnumber); ?>" />
</label><br /><span class="errors"><?php echo $contactnumberErr; ?></span></p>
<p><label>Property Price:<br />
<input type="text" name="propertyprice" class="textfield" value="<?php echo htmlentities($propertyprice); ?>" />
</label><br /><span class="errors"><?php echo $propertypriceErr; ?></span></p>
<p><label>Property Location:<br />
<input type="text" name="propertylocation" class="textfield" value="<?php echo htmlentities($propertylocation); ?>" />
</label><br /><span class="errors"><?php echo $propertylocationErr; ?></span></p>
<p><label>Message: <br />
<textarea name="message" class="textarea" cols="45" rows="5"><?php echo htmlentities($message); ?></textarea>
</label><br /><span class="errors"><?php echo $messageErr ?></span></p>
<p><input type="submit" name="submit" class="button" value="Submit" /></p>
</form>
</div>
|
|
Junior Member
|
|
Posts: 23
Join Date: Mar 2012
|
|
|

08-19-2012, 01:37 AM
includes/contact_form_send.php
Code:
<?php
define("EMAIL", "jock@jockitdesign.com");
if(isset($_POST['submit'])) {
include('validate.class.php');
//assign post data to variables
$firstname = trim($_POST['firstname']);
$surnname = trim($_POST['surname']);
$email = trim($_POST['email']);
$contactnumber = trim($_POST['contactnumber']);
$propertyprice = trim($_POST['propertyprice']);
$propertylocation = trim($_POST['propertylocation']);
$message = trim($_POST['message']);
//start validating our form
$v = new validate();
$v->validateStr($firstname, "firstname", 3, 75);
$v->validateStr($surname, "surname", 3, 75);
$v->validateEmail($email, "email");
$V->validateStr($contactnumber, "contactnumber", 3, 75);
$V->validateStr($propertyprice, "propertyprice", 3, 75);
$V->validateStr($propertylocation, "propertylocation", 3, 75);
$v->validateStr($message, "message", 5, 500);
if(!$v->hasErrors()) {
$header = "From: $email\n" . "Reply-To: $email\n";
$subject = "CutmoreProperty.com | Contact Enquiry";
$email_to = EMAIL;
$emailMessage = "First Name: " . $firstname . "\n";
$emailMessage .= "Surname: " . $surname . "\n\n";
$emailMessage .= "Email: " . $email . "\n";
$emailMessage .= "contactnumber: " . $contactnumber . "\n\n";
$emailMessage .= "propertyprice: " . $propertyprice . "\n";
$emailMessage .= "propertylocation: " . $propertylocation . "\n\n";
$emailMessage .= $message;
//use php's mail function to send the email
@mail($email_to, $subject ,$emailMessage ,$header );
//grab the current url, append ?sent=yes to it and then redirect to that url
$url = "http". ((!empty($_SERVER['HTTPS'])) ? "s" : "") . "://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
header('Location: '.$url."?sent=yes");
} else {
//set the number of errors message
$message_text = $v->errorNumMessage();
//store the errors list in a variable
$errors = $v->displayErrors();
//get the individual error messages
$firstnameErr = $v->getError("firstname");
$surnameErr = $v->getError("surname");
$emailErr = $v->getError("email");
$contactnumberErr = $v->getError("contactnumber");
$propertypriceErr = $v->getError("propertyprice");
$propertylocationErr = $v->getError("propertylocation");
$messageErr = $v->getError("message");
}//end error check
}// end isset
?>
<script language="javascript" type="text/javascript">
// Print a message
alert('Thank you for the message. We will contact you shortly.');
// Redirect to some page of the site. You can also specify full URL, e.g. http://template-help.com
window.location = '../contact.php';
</script>
includes/validate.class.php
Code:
<?php
class validate {
// ---------------------------------------------------------------------------
// paramaters
// ---------------------------------------------------------------------------
/**
* Array to hold the errors
*
* @access public
* @var array
*/
public $errors = array();
// ---------------------------------------------------------------------------
// validation methods
// ---------------------------------------------------------------------------
/**
* Validates a string
*
* @access public
* @param $postVal - the value of the $_POST request
* @param $postName - the name of the form element being validated
* @param $min - minimum string length
* @param $max - maximum string length
* @return void
*/
public function validateStr($postVal, $postName, $min = 5, $max = 500) {
if(strlen($postVal) < intval($min)) {
$this->setError($postName, ucfirst($postName)." must be at least {$min} characters long.");
} else if(strlen($postVal) > intval($max)) {
$this->setError($postName, ucfirst($postName)." must be less than {$max} characters long.");
}
}// end validateStr
/**
* Validates an email address
*
* @access public
* @param $emailVal - the value of the $_POST request
* @param $emailName - the name of the email form element being validated
* @return void
*/
public function validateEmail($emailVal, $emailName) {
if(strlen($emailVal) <= 0) {
$this->setError($emailName, "Please enter an Email Address");
} else if (!preg_match('/^[^0-9][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[@][a-zA-Z0-9_]+([.][a-zA-Z0-9_]+)*[.][a-zA-Z]{2,4}$/', $emailVal)) {
$this->setError($emailName, "Please enter a Valid Email Address");
}
}// end validateEmail
// ---------------------------------------------------------------------------
// error handling methods
// ---------------------------------------------------------------------------
/**
* sets an error message for a form element
*
* @access private
* @param string $element - name of the form element
* @param string $message - error message to be displayed
* @return void
*/
private function setError($element, $message) {
$this->errors[$element] = $message;
}// end logError
/**
* returns the error of a single form element
*
* @access public
* @param string $elementName - name of the form element
* @return string
*/
public function getError($elementName) {
if($this->errors[$elementName]) {
return $this->errors[$elementName];
} else {
return false;
}
}// end getError
/**
* displays the errors as an html un-ordered list
*
* @access public
* @return string: A html list of the forms errors
*/
public function displayErrors() {
$errorsList = "<ul class=\"errors\">\n";
foreach($this->errors as $value) {
$errorsList .= "<li>". $value . "</li>\n";
}
$errorsList .= "</ul>\n";
return $errorsList;
}// end displayErrors
/**
* returns whether the form has errors
*
* @access public
* @return boolean
*/
public function hasErrors() {
if(count($this->errors) > 0) {
return true;
} else {
return false;
}
}// end hasErrors
/**
* returns a string stating how many errors there were
*
* @access public
* @return void
*/
public function errorNumMessage() {
if(count($this->errors) > 1) {
$message = "There were " . count($this->errors) . " errors sending your message!\n";
} else {
$message = "There was an error sending your message!\n";
}
return $message;
}// end hasErrors
}// end class
?>
Ok so what is happening is it is popping up, notifying me that the message is sent, but nothing is sent or received from either email address / account.
Please help me work out what's happened???
Thank you so much for reading my thread!
|
 |
Senior Member
|
|
Posts: 416
Join Date: Jun 2012
|
|
|

08-19-2012, 04:34 AM
Does the uppermost source-code work on the original site without errors?
Seems like a lot of code to perform a relatively simple task, but I could be wrong as I couldn't take the time to go through and study it all line-by-line. Regardless, here's what I found in includes/contact_form_send.php:
I'm not sure why your mail function is proceeded by the @, I would think the @ would suppress the function all together.
IE:
@mail($email_to, $subject ,$emailMessage ,$header );
Try removing the @ symbol.
|
 |
Super Moderator
|
|
Posts: 6,620
Join Date: Jul 2009
Location: Spain
|
|
|

08-19-2012, 07:07 AM
Hello,
PHP programming the at symbol @ prevents display errors or warnings that returns a function when it is executed.
Recuerda realizar copias de seguridad de tus sitios web. Si este mensaje te ayudó puedes pulsar sobre el botón karma
|
|
Senior Member
|
|
Posts: 762
Join Date: Dec 2010
|
|
|

08-19-2012, 07:57 AM
There are typing errors in the second contact_form_send.php. For validating contact
number, property price and property location, $V (upper case V) were used instead
of $v (lower case v). So, please make changes accordingly.
PHP Code:
//start validating our form
$v = new validate();
$v->validateStr($firstname, "firstname", 3, 75);
$v->validateStr($surname, "surname", 3, 75);
$v->validateEmail($email, "email");
$V->validateStr($contactnumber, "contactnumber", 3, 75);
$V->validateStr($propertyprice, "propertyprice", 3, 75);
$V->validateStr($propertylocation, "propertylocation", 3, 75);
$v->validateStr($message, "message", 5, 500);
Last edited by grace1004; 08-19-2012 at 10:21 AM.
|
|
Junior Member
|
|
Posts: 23
Join Date: Mar 2012
|
|
|

08-19-2012, 11:43 AM
thanks for the suggestions, but none changed anything
|
|
Senior Member
|
|
Posts: 762
Join Date: Dec 2010
|
|
|

08-20-2012, 05:23 AM
There's another typing error in the 2nd contact_form_send.php. Please change:
From: $surnname = trim($_POST['surname']);
To:$surname = trim($_POST['surname']);
Also, I think you need to change validate.class.php as shown below:
From: public function validateStr($postVal, $postName, $min = 5, $max = 500) {
To: public function validateStr($postVal, $postName, $min = 3, $max = 500) {
Last edited by grace1004; 08-20-2012 at 05:56 AM.
|
|
Junior Member
|
|
Posts: 23
Join Date: Mar 2012
|
|
|

08-20-2012, 07:10 AM
thank you very much,
what if i changed from $_POSt
to
$_REQUEST
?
do you think that would improve anything?
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Powered by vBulletin® Version 3.8.2 Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com
|