Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page Contact Form Validation
Reply
 
Thread Tools Display Modes
(#11 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 735
Join Date: Dec 2010
Default 08-20-2012, 07:19 AM

In the form, the method is defined as "post", so it's OK to use $_POST.
$_REQUEST will not improve as far as you do not correct typing error.
The typing error $surnname--you typed additional n before name--it's
an fatal error, as variable name is not correct one ($surname).
Reply With Quote
Sponsored Links
(#12 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 735
Join Date: Dec 2010
Default 08-20-2012, 07:27 AM

Also, when testing your code, it's not displaying error message at all in case
I entered less than 3 characters and invalid email address format. So, please
try the following code and see if error message is displayed in the same case.

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']);
  
$surname 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"375);
  
$v->validateStr($surname"surname"375);
  
$v->validateEmail($email"email");
  
$v->validateStr($contactnumber"contactnumber"375);
  
$v->validateStr($propertyprice"propertyprice"375);
  
$v->validateStr($propertylocation"propertylocation"375);
  
$v->validateStr($message"message"5500);  
 
  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
     
$sent mail($email_to$subject ,$emailMessage ,$header );   
   
    if(
$sent) echo 
    
'<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>'
;  
             
    } else {
    
//set the number of errors message
    
$message_text $v->errorNumMessage(); 
    echo 
$message_text;      
 
    
//store the errors list in a variable
    
$errors $v->displayErrors();
    echo 
$errors;
 
    
//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
 
}       
?>
Reply With Quote
(#13 (permalink))
Old
Junior Member
MusoFreak200 is on a distinguished road
 
Posts: 23
Join Date: Mar 2012
Default 08-20-2012, 09:14 PM

Huzzah!

that fixed the script!

thank you SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO much

so do you think you could go step through step on how you defined the problem and redeveloped a solution?


Personal website:
http://www.angelpoetry.org/
Reply With Quote
(#14 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 735
Join Date: Dec 2010
Default 08-20-2012, 10:36 PM

When finding problems, I do not read codes line by line. First, I change the code
in accordance with testing environment, e.g. in this case changed the defined Email
to mine, found the first error ($V) by displayed error message and the second error
($surnname) by entering invalid data. It's not easy to find typos by reading line
by line; testing is the best method in developing process. However, you need to
have an ability to interprete the error message displayed. To have such ability,
first of all, you have to master the basics of php/mysql/html/javascript.
Reply With Quote
Reply

Tags
contact form, failure to send, not receiving, validation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are 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