?
Solved

PHP Form

Posted on 2011-10-18
27
Medium Priority
?
597 Views
Last Modified: 2012-05-12
Please please can someone help me, i have a webserver that is running windows server 2003 web edition and i have a html page that contains a form once submitted the form goes to a php file,

What do i need to add on my windows server 2003 to allow php scripts etc so that i can submit my form, i know my current website is written in .html, but my form that somebody has created for me is in php, i know there is some server side stuff i need to configure but i am not sure what???

john
0
Comment
Question by:pepps11976
  • 14
  • 12
27 Comments
 
LVL 13

Expert Comment

by:darren-w-
ID: 36985778
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36985796
if you run  web platform installer it should give the option to add php.

Then you need to add a php file that captures a posted array from the form , some examples here http://myphpform.com/
0
 
LVL 20

Expert Comment

by:DVation191
ID: 36985806
There's quite a bit of info out there getting PHP installed on IIS:
http://blogs.iis.net/bills/archive/2006/09/19/How-to-install-PHP-on-IIS7-_2800_RC1_2900_.aspx
http://www.websiteadministrator.com.au/articles/install_guides/installing_php536.html
http://www.themetroservices.com/sandy/?p=9

Once you get PHP installed, we can help diagnose any problems with the forms.
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Comment

by:pepps11976
ID: 36985902
ok i am running the installer from http://php.iis.net/ 

i get the option to install applications these  are

Orchard CMS
DotNetNuke
Umbraco
RedCritter
EC-Cube
Visual Studio
AXCMS
and IIS 7 Recommended configuration

nothing about PHP
 do i need to pick one of these?
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986004
do a search for php, you should see FastCGI 1.5 for IIS 6.0 and IIS 5.1, install this
0
 

Author Comment

by:pepps11976
ID: 36986012
Ok i have installed php using the installer, The error message i get when i try to submit my form has simply changed now to just "Mail Failed"

i am assuming i have to configure something else?
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986035
Then you need to add a php file that captures a posted array from the form
mentioned above, was there a php file with the form?
0
 

Author Comment

by:pepps11976
ID: 36986071
Ok This is what i have

Contact Form

 
<form action="/bin/MailHandler.php" method="post" name="contact-form" class="main-contacts" id="contact-form">
<fieldset>
															<input type="hidden" name="owner_email" id="owner_email" value="john.pepper@testsite.com" />
															<input type="hidden" name="serverProcessorType" id="serverProcessorType" value="php" />
															<input type="hidden" name="smtpMailServer" id="smtpMailServer" value="localhost" />
															<input type="hidden" name="stripHTML" id="stripHTML" value="true" />
						
										
                  	<div class="rowElem">
						<b>Enter your Name:</b>
						<div class="bg">
							<input type="text"  name="name" id="name">
						</div>
						<label class="error" for="name" id="name_error">*This field is required.</label>
						<label class="error" for="name" id="name_error2">*This is not a valid name.</label>
					</div>
                   	<div class="rowElem">
						<b>Enter your E-mail:</b>
						<div class="bg">
                    		<input type="text"  name="email" id="email" value="">
                   		</div>
						<label class="error" for="email" id="email_error">*This field is required.</label>
						<label class="error" for="email" id="email_error2">*This is not a valid email address.</label>
					</div>
                   <div class="rowElem">
				   		<b>Enter your Phone:</b>
						<div class="bg">
                      		<input type="text" name="phone" id="phone">
                   		</div>
						<label class="error" for="phone" id="phone_error">*This field is required.</label>
						<label class="error" for="phone" id="phone_error2">*This is not a valid phone number.</label>
					
					</div>
                    <div class="textarea-box">
						<b>Enter your Message:</b>
						<textarea rows="1" cols="1" name="message" id="message"></textarea>
						<label class="error" for="message" id="message_error">*This field is required.</label>
						<label class="error" for="message" id="message_error2">*The message is too short.</label>
					</div>
                    <div class="clear"></div>
                    <a href="#" class="link" id="clear">Reset</a> 
					<label></label>
					<input type="submit" name="sub" value="Submit" class="link">


				</fieldset>
                </form>

Open in new window


Mail Handler

 
<?php
	$owner_email = $_POST["owner_email"];
	$headers = 'From:' . $_POST["email"];
	$subject = 'A message from your site visitor ' . $_POST["name"];
	$messageBody = "";
	
	$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
	$messageBody .= '<br>' . "\n";
	$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
	$messageBody .= '<br>' . "\n";
	$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
	$messageBody .= '<br>' . "\n";
	$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
	
	if($_POST["stripHTML"] == 'true'){
		$messageBody = strip_tags($messageBody);
	}

	try{
		if(!mail($owner_email, $subject, $messageBody, $headers)){
			throw new Exception('mail failed');
		}else{
			echo 'mail sent';
		}
	}catch(Exception $e){
		echo $e->getMessage() ."\n";
	}
?>

Open in new window


Is this correct?
0
 

Author Comment

by:pepps11976
ID: 36986330
Ok it seems now that when i submit the form it all seems to be sussesfull

however i never recieve the mail

any idears i have been struggling with this for ages but have never resolved it

john
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986376
check your mailer setting in your php.ini file,  you may need to point it to a smtp server, also check your web server log for errors
0
 

Author Comment

by:pepps11976
ID: 36986390
when i installed FastCGI 1.5 for IIS 6.0 would this have created a php.ini file if so what is the default path?

john
0
 

Author Comment

by:pepps11976
ID: 36986404
ok these are my mail settings

[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25

they seem ok?
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986420
assuming your able to login to the mailserver via telnet and manually send a mail? :
http://support.microsoft.com/kb/153119
0
 

Author Comment

by:pepps11976
ID: 36986438
yes all that is ok, i have other forms on another site on the same server but they are using .asp

so i know the mail flow works for them.

any other idears?
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986522
It looks like the mail function either returns true or false, not so sure if the exception will catch anything?

if you do this:

if(mail($owner_email, $subject, $messageBody, $headers) === true){
echo "true"
            }else{
                  echo "false";
            }

assume you still get true, if this is the case I think the mail is going
0
 

Author Comment

by:pepps11976
ID: 36986702
Well if i have done this correctly and my mail handler now looks like this

 
<?php
	$owner_email = $_POST["owner_email"];
	$headers = 'From:' . $_POST["email"];
	$subject = 'A message from your site visitor ' . $_POST["name"];
	$messageBody = "";
	
	$messageBody .= '<p>Visitor: ' . $_POST["name"] . '</p>' . "\n";
	$messageBody .= '<br>' . "\n";
	$messageBody .= '<p>Email Address: ' . $_POST['email'] . '</p>' . "\n";
	$messageBody .= '<br>' . "\n";
	$messageBody .= '<p>Phone Number: ' . $_POST['phone'] . '</p>' . "\n";
	$messageBody .= '<br>' . "\n";
	$messageBody .= '<p>Message: ' . $_POST['message'] . '</p>' . "\n";
	
	if($_POST["stripHTML"] == 'true'){
		$messageBody = strip_tags($messageBody);
	}

	try{
		if(mail($owner_email, $subject, $messageBody, $headers) === true){
echo "true"
            }else{
                  echo "false";
            }

	}catch(Exception $e){
		echo $e->getMessage() ."\n";
	}
?>

Open in new window


the form now does not work it errors
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986709
line 21 is missing a semicolon

echo "true";

0
 

Author Comment

by:pepps11976
ID: 36986792
i get the value false

john
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36986902
Try adding a from field in your php.ini file:

SMTP=localhost
sendmail_from = '[from email address here]'
smtp_port=25

http://learn.iis.net/page.aspx/751/configure-smtp-e-mail-in-iis-7-and-above/

0
 

Author Comment

by:pepps11976
ID: 36986941
i still get false when trying to submit
0
 
LVL 13

Accepted Solution

by:
darren-w- earned 2000 total points
ID: 36987047
Have a look at the error logs:

http://help.yahoo.com/l/us/yahoo/smallbusiness/webhosting/php/php-03.html

It looks like the mailserver is failing to relay your mail because some setting is incorrect?   Need to see output to determine this.

Darren
0
 

Author Comment

by:pepps11976
ID: 36991554
Hi Darren-W

I just need to confirm a few things with you and can you tell me if you think i have done this right.

I used theWindows installer for PHP i also have FASTCGI installed, although i am not totally sure what fastcgi is?

anyway i uninstalled all of that and reinstalled to see if it changed any thing, now i cant even seem to view a php page,

could you help me to take this from the first steps again so atleast i then know it has been installed correctly?

John
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36991611
Hi,

It sounds like iis has lost its association with .php extensions, and this is why you get a blank page, fastcgi is a prerequisite to run php and is always installed it speeds processing up.

Any way I would use the 'web platform installer' to remove php capability then re-add it, then restart the server, and try again, just use a simple php file with this line:

<?php phpinfo() ?>

this will show the php config.

if still no luck you will need to add .php files in iis's configuration to execute using the php.exe parser.

Then go through the processes as before.

Darren

 
0
 

Author Comment

by:pepps11976
ID: 36993606
Hi Darren-w

i am at ac omplete loss now i have ininstalled php installer and fast cgi and i have reinstalled but i simply cannot get a php page to display.

i simply do not have the knowlwdge to do as you suggested "add .php files in iis's configuration to execute using the php.exe parser"

so if you could walk me through simply getting php up and running as a first i will be most grateful.

john
0
 

Author Comment

by:pepps11976
ID: 36993623
Ok Update i have managed to be able to get php pages to view so im back now to the original question of getting the form to work.

Can you still assist?

john
0
 
LVL 13

Expert Comment

by:darren-w-
ID: 36995692
Can do, need to setup a vm environment with windows as running linux, will get back to you soon
0
 

Author Comment

by:pepps11976
ID: 36995834
Darren-w

ive managed to get this working  i found an installer on the net and everything just started working,

really appreciate your help on this

john
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As Wikipedia explains 'robots.txt' as -- the robot exclusion standard, also known as the Robots Exclusion Protocol or robots.txt protocol, is a convention to prevent cooperating web spiders and other web robots from accessing all or part of a websit…
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
Loops Section Overview
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question