• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

First script for PHP is not working

 
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have following file phpTest.html

Another file on server is phpTest1.php in the same location where phpTest.html is
When I feed data in two text fields in phpTest.html form and click submit, I dont get message from phpTest1.php. Instead of that, I get message "Do you want to open or save phpTest1.php(299 bytes) from My-PC ?"
When I click on open it opens source file phpTest1.php from server instead of displaying message. Why is that ?

How can I get message displayed from php script ? Apache server is running and WAMP is server is started (Apache MySQL, PHP for windows).

Thanks
 
Bartender
Posts: 7645
178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds like PHP is not configured correctly - instead of it being execute don the server the Apache server apparently serves it to the client. Check the PHP installation documentation to see if everything concerning mod_php is set up correctly.
 
Ranch Hand
Posts: 71
PHP Linux Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the httpd.conf file and make sure you have lines that look like this (your paths might be different):



The second line enables PHP within Apache. The third line tells Apache to let PHP handle all requests for files ending in .php

By the way, I usually use a simple phpinfo file to test PHP:



I call it info.php and use http://localhost/info.php to access it. I get all kinds of data on my PHP setup if everything is correctly configured..
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for replies. But none of the suggestion is working.

Now I have put phpTest1.php file in root dir (www) instead of putting in dir where phpTest.html is placed. Then I changed phpTest.html as follows
Now when I type in fields and click on submit phpTest.html, I am getting response from phpTest1.php

But I don't think this is right way to do things. Please let me know whats wrong I am doing and suggest correct approach.

Secondly, I am using following code with phpTest1.php script When I use this code, message is not getting sent to [email protected] and I get following message.

Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\phpTest1.php on line 12


Why is that ? I dont unerstand this message.How can I use mail() in the script ?
 
Nick Charles
Ranch Hand
Posts: 71
PHP Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't side-track your main question with an email question. Setting up email under PHP is a whole different topic. If you want to discuss that, please delete the email question from this post and crate a new discussion thread with that question.

Please read: ItDoesntWorkIsUseless
I pointed out some configuration settings you should have. If they are not working for you, then you need to post the settings that you have; there must be something wrong with them but without seing what you have I can't help you. Please post your httpd.conf file.

The "action" value in the <form> is not what you want. This limits your app to running only on your PC. You really want to have it the way it originally was.

Also, please give full directory paths. I have no idea where "www" is located (I would know on Linux, but you're running Windows). Give the full paths for both the HTML and PHP file.
 
nirjari patel
Ranch Hand
Posts: 386
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
following is path for httpd.conf and below that is httpd.conf file
"C:\wamp\bin\apache\Apache2.2.21\conf"

following is path for www root dir
"C:\wamp\www"

Following is path for firstTest.html parent dir
"C:\Users\Nirjari\Desktop\all text files\HTML Files"

I have placed one copy of phpTest1.php in this location and in www root dir.

Both mail() is part of first script and thats why I asked question about it in here.

Please let me know why is this script not working.

Thanks for your support
 
Nick Charles
Ranch Hand
Posts: 71
PHP Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Following is path for firstTest.html parent dir
"C:\Users\Nirjari\Desktop\all text files\HTML Files


This explains a lot. How did you open the HTML file? By double-clicking on it in Explorer? That is not how things work. Instead, you should have something like this:

C:\wamp\www\app\phpTest1.php
C:\wamp\www\app\phpTest.html

Then you need to go to your browser and enter this url: http://localhost/app/phpTest.html

Then it should work.

By the way, the "app" in the path and URL is really not necessary, but it helps if you want to have multiple apps running. And you can replace "app" with anything your like.

And you really need to start another thread for the email!!! (Even though you are calling mail() in the same script, dealing with mail is a whole separate issue.)
 
No more fooling around. Read this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic