PHP Form

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
pepps11976Asked:
Who is Participating?
 
darren-w-Commented:
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
 
darren-w-Commented:
0
 
darren-w-Commented:
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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
DVation191Commented:
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
 
pepps11976Author Commented:
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
 
darren-w-Commented:
do a search for php, you should see FastCGI 1.5 for IIS 6.0 and IIS 5.1, install this
0
 
pepps11976Author Commented:
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
 
darren-w-Commented:
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
 
pepps11976Author Commented:
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
 
pepps11976Author Commented:
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
 
darren-w-Commented:
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
 
pepps11976Author Commented:
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
 
pepps11976Author Commented:
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
 
darren-w-Commented:
assuming your able to login to the mailserver via telnet and manually send a mail? :
http://support.microsoft.com/kb/153119
0
 
pepps11976Author Commented:
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
 
darren-w-Commented:
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
 
pepps11976Author Commented:
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
 
darren-w-Commented:
line 21 is missing a semicolon

echo "true";

0
 
pepps11976Author Commented:
i get the value false

john
0
 
darren-w-Commented:
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
 
pepps11976Author Commented:
i still get false when trying to submit
0
 
pepps11976Author Commented:
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
 
darren-w-Commented:
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
 
pepps11976Author Commented:
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
 
pepps11976Author Commented:
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
 
darren-w-Commented:
Can do, need to setup a vm environment with windows as running linux, will get back to you soon
0
 
pepps11976Author Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.