Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
PHP
<?php
if(isset($_POST['inputName3']) && isset($_POST['inputEmail3']) && isset($_POST['inputSite3']) && isset($_POST['inputMessage3']))
{
$inputName3 = $_POST['inputName3'];
$inputEmail3 = $_POST['inputEmail3'];
$inputSite3 = $_POST['inputSite3'];
$inputMessage3 = $_POST['inputMessage3'];

if(!empty($inputName3) && !empty($inputEmail3) &&!empty($inputSite3) &&!empty($inputMessage3) )
{
if(strlen($inputName3)>25 || strlen($inputEmail3)>50 || strlen($inputSite3)>30 || strlen($inputMessage3)>1000){
  echo 'Sorry, maxlength for some field has been exceeded';
 }else{
  $to = 'ahammad559@gmail.com';
 $subject = 'This is an email';
 $body = $inputName3."\n\n".$inputMessage3 ;
 $headers = 'From : "php academy" <ahammad559@gmail.com>';
 if(@mail($to, $subject, $body, $headers)){
 echo 'Thanks for contacting us.we\'ll be touch in soon.';
 }else{
 echo 'Sorry, an error occurred.Please try again';
 }
 }
}
else{
 echo'all fields are required';
}
}
?>
Posted
Comments
Maarten Kools 28-Jan-14 3:43am    
Don't really spot the error just like that. But usually there's a line number with the error. And you can always apply the process of elimination otherwise.
Member 10554449 28-Jan-14 4:02am    
line :2
Maarten Kools 28-Jan-14 4:23am    
And this is the whole file? Or are there any includes, or is this file included in a different file?
CPallini 28-Jan-14 3:50am    
That code looks correct.
Member 10554449 28-Jan-14 4:01am    
no , getting error.

1 solution

if(isset($_POST['inputName3']) && isset($_POST['inputEmail3']) && isset($_POST['inputSite3']) && isset($_POST['inputMessage3']))

Are each of the values in the if condition above returning boolean?
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900