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 24th, 2013, 10:13 AM
itm2 itm2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 itm2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 16 sec
Reputation Power: 0
PHP5 - Mail function simply echos PHP file to page

I'm trying to get a copy of an existing PHP site up and running on my Windows 2008 Server. I've installed PHP 5.4 using the Microsoft Web Platform Installer (v4.5). The installation seemed to go fine, and I've managed to display the phpinfo page.

There's a contact form on the site which captures user details and sends an email - the code of the php which is executed on form submission is below. This functionality works on the live site, but when I submit the form on my Windows server it simply echos the content of the .php file (i.e. the code below) to the page.

I've configured the SMTP server in php.ini to use localhost on port 25, and have successfully sent an outbound email using the local SMTP server.

Can anyone suggest why this is happening?

PHP Code:
<?


$strContents 
"

This is an email from the xxxxx website\n \n<br><br>
Sender: \t "
.$_POST['firstName']." \n<br>
Email: \t "
.$_POST['_sendersemail']." \n<br>
Telephone: \t "
.$_POST['phoneNumber']." \n<br>
Company: \t "
.$_POST['enquiry']." \n<br>
"
;

if (!
sendMail(array('subject' => 'Contact Form''contents' => $strContents'recipients' => array(
    array(
'emailAddress' => 'info@xxxxx.com')
)))) {
    
header('Location: ' $_POST['missing_fields_redirect']);
}



function 
sendMail($arrMail) {
    
    if (!
array_key_exists('contents'$arrMail)) {return false;} else {$strContents $arrMail['contents'];}
    if (!
array_key_exists('recipients'$arrMail)) {return false;}
    
    
$headers "From: xxxxxx contact form <noreply@xxxxxxx> \n"
    
$headers .= "Return-Path: <noreply@xxxxx>\n"
    
$headers .= "MIME-Version: 1.0\n"
    
$headers .= "Content-Type: text/html; charset=UTF-8\n"
    
    foreach (
$arrMail['recipients'] as $arrRecipient) {
        if (!
mail($arrRecipient['emailAddress'],$arrMail['subject'],$strContents$headers)) {return false;}
    }
    
    return 
true;
    
}

header('Location: ' $_POST['redirect']);

?>

Reply With Quote
  #2  
Old February 24th, 2013, 01:21 PM
DonR DonR is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2009
Posts: 464 DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)DonR User rank is Captain (20000 - 30000 Reputation Level)  Folding Points: 29722 Folding Title: Starter FolderFolding Points: 29722 Folding Title: Starter Folder
Time spent in forums: 2 Weeks 2 Days 58 m 41 sec
Reputation Power: 216
the first thing I am seeing is that you are trying to use short-tags which is probably not turned ON in your webserver.
change your opening php tags from <? to <?php and see if that helps.

Reply With Quote
  #3  
Old February 24th, 2013, 01:38 PM
itm2 itm2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2013
Posts: 2 itm2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 m 16 sec
Reputation Power: 0
That was it! Many thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > PHP5 - Mail function simply echos PHP file to page

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