PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 10th, 2013, 04:47 PM
rdbrotherton rdbrotherton is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 22 rdbrotherton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 20 m
Reputation Power: 0
HTML form to email

I've been using a form I found online for a website in order to allow customers to contact the company by filling in the form and clicking submit.

This form worked perfectly before however I've recently been re-writing the site into HTML5 and since I did this for the php file submitting the form no longer works.

When I submit the form I get the following error:

Parse error: syntax error, unexpected $end in /home/fhlinux203/d/designercurtains.biz/user/htdocs/flex/send_form_email.php on line 179.

The file is located at www.designercurtains.biz/flex/send_form_email.php and the form is located at www.designercurtains.biz/flex/contact.html

Your help is greatly appreciated!

Reply With Quote
  #2  
Old February 10th, 2013, 05:52 PM
requinix's Avatar
requinix requinix is online now
Still alive
Dev Shed God 16th Plane (12500 - 12999 posts)
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,872 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 5 Days 7 h 23 m 51 sec
Reputation Power: 8977
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
The error is in the code (you're probably missing a }) but we can't help much if we can't see it.

Reply With Quote
  #3  
Old February 10th, 2013, 05:58 PM
rdbrotherton rdbrotherton is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 22 rdbrotherton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 20 m
Reputation Power: 0
How's this...

PHP Code:
<?php
if(isset($_POST['email'])) {
     
    
// EDIT THE 2 LINES BELOW AS REQUIRED
    
$email_to "sue@designercurtains.biz";
    
$email_subject "Designer Curtains Online Contact Form";
     
     
    function 
died($error) {
        
// your error code can go here
        
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
        echo 
"These errors appear below.<br /><br />";
        echo 
$error."<br /><br />";
        echo 
"Please go back and fix these errors.<br /><br />";
        die();
    }
     
    
// validation expected data exists
    
if(!isset($_POST['first_name']) ||
        !isset(
$_POST['last_name']) ||
        !isset(
$_POST['email']) ||
        !isset(
$_POST['telephone']) ||
        !isset(
$_POST['comments'])) {
        
died('We are sorry, but there appears to be a problem with the form you submitted.');       
    }
     
    
$first_name $_POST['first_name']; // required
    
$last_name $_POST['last_name']; // required
    
$email_from $_POST['email']; // not required
    
$telephone $_POST['telephone']; // not required
    
$comments $_POST['comments']; // required
     
    
$error_message "";
    
$email_exp '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  if(!
preg_match($email_exp,$email_from)) {
    
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  }
    
$string_exp "/^[A-Za-z .'-]+$/";
  if(!
preg_match($string_exp,$first_name)) {
    
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
  }
  if(!
preg_match($string_exp,$last_name)) {
    
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
  }
  if(
strlen($comments) < 2) {
    
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
  }
  if(
strlen($error_message) > 0) {
    
died($error_message);
  }
    
$email_message "Form details below.\n\n";
     
    function 
clean_string($string) {
      
$bad = array("content-type","bcc:","to:","cc:","href");
      return 
str_replace($bad,"",$string);
    }
     
    
$email_message .= "First Name: ".clean_string($first_name)."\n";
    
$email_message .= "Last Name: ".clean_string($last_name)."\n";
    
$email_message .= "Email: ".clean_string($email_from)."\n";
    
$email_message .= "Telephone: ".clean_string($telephone)."\n";
    
$email_message .= "Comments: ".clean_string($comments)."\n";
     
     
// create email headers
$headers 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' phpversion();
@
mail($email_to$email_subject$email_message$headers);  
?>

Reply With Quote
  #4  
Old February 10th, 2013, 08:52 PM
Jacques1's Avatar
Jacques1 Jacques1 is offline
pollyanna
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 2012
Location: Germany
Posts: 2,042 Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level)Jacques1 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 48 m 47 sec
Reputation Power: 812
Hi,

there's no closing brace for the "if" statement.

Use an IDE like Netbeans or Eclipse to avoid errors like that.

Reply With Quote
  #5  
Old February 11th, 2013, 01:19 AM
rdbrotherton rdbrotherton is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 22 rdbrotherton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 20 m
Reputation Power: 0
Sorry I have no understanding whatsoever of PHP - still trying to conquer HTML. Where should the closing brack go?

Reply With Quote
  #6  
Old February 11th, 2013, 04:14 AM
requinix's Avatar
requinix requinix is online now
Still alive
Dev Shed God 16th Plane (12500 - 12999 posts)
 
Join Date: Mar 2007
Location: Washington, USA
Posts: 12,872 requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)requinix User rank is General 120th Grade (Above 100000 Reputation Level)  Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1Folding Points: 417516 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 5 Months 1 Week 5 Days 7 h 23 m 51 sec
Reputation Power: 8977
Send a message via AIM to requinix Send a message via MSN to requinix Send a message via Yahoo to requinix Send a message via Google Talk to requinix
It's the closing brace to
PHP Code:
if(isset($_POST['email'])) { 

So where do you think it should go?

Reply With Quote
  #7  
Old February 11th, 2013, 05:36 AM
revillwebdesign revillwebdesign is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 9 revillwebdesign User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 47 sec
Reputation Power: 0
Facebook
Right at the very end before the ?> you should put a closing "}" brace.

Using a decent editor can avoid these errors like has been mentioned.

Take care,

Leon.

Reply With Quote
  #8  
Old February 11th, 2013, 11:57 AM
rdbrotherton rdbrotherton is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 22 rdbrotherton User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 20 m
Reputation Power: 0
Quote:
Originally Posted by revillwebdesign
Right at the very end before the ?> you should put a closing "}" brace.

Using a decent editor can avoid these errors like has been mentioned.

Take care,

Leon.


Excellent, that's got it working again. Strange as it worked before and I just copied and pasted that extract of code over from the previous version of the website.

No matter, thanks for the help. As ever Devshed is an invaluable resource for annoying newbies like myself. I promise to research php when I'm more settled with HTML.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > HTML form to email

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap