Having trouble making PHP work.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
MattCollins
Forum Newbie
Posts: 5
Joined: Tue Jan 30, 2007 3:11 am

Having trouble making PHP work.

Post by MattCollins »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


Ok, i am very, very new to PHP. Infact this is my first attempt to use it. I have downloaded and installed both MySQL, PHP 5.2.0 and Apache 2.2. I pointed the PHP installer to the Apache configuration files and it updated those successfully. However when i come to write a php file (e.g. sendmail.php) all i get is a blank page when it loads. the code i have in there is something i copied and pasted from a tutorial and is:

Code: Select all

<?
  $email = $_REQUEST['email'] ;
  $message = $_REQUEST['message'] ;

  mail( "yourname@example.com", "Feedback Form Results",
    $message, "From: $email" );
  header( "Location: http://www.example.com/thankyou.html" );
?>
and it gets the data from a very simple html file with a submission form. I have changed the e-mail address in the mail("yourname@example.com", "Feedback Form Results", line to my own e-mail address however nothing appears to be happening.

Do i need to enable any services or should they all have started automatically? Anyone have any ideas?

Many thanks,

Matt Collins


feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
MattCollins
Forum Newbie
Posts: 5
Joined: Tue Jan 30, 2007 3:11 am

Post by MattCollins »

New development, originally i have Mozilla as my default browser however when i open the html file in IE and click the button, it asks me if i want to open or save the php file.

Does this mean that PHP didn't install?
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

Not a right place to post(should be posted in Installation and configuration), but still write the following code into a file .

Code: Select all

<?php
phpinfo();
?>
and save it as test.php, place it in the document root and access the file through browser. If it gives some output with php information, then your php works. otherwise you need to add few lines in httpd.conf file
MattCollins
Forum Newbie
Posts: 5
Joined: Tue Jan 30, 2007 3:11 am

Post by MattCollins »

Thank you for the reply and sorry for posting in the wrong area.

Have done that but as soon as i double click the file it asks me to open or save again :(
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

Yes, your php doesnt work. I suggest you to download the xampp which takes just few minutes to install and setup complete LAMP environment. If you dont want to try new things then Open your httpd.conf file and add
few lines

Code: Select all

AddType application/x-httpd-php .php .php3 .php4
And then

Code: Select all

DirectoryIndex index.html index.html.var index.php index.php3 index.php4
MattCollins
Forum Newbie
Posts: 5
Joined: Tue Jan 30, 2007 3:11 am

Post by MattCollins »

Thank you, where abouts in the file do i put those? at the end?
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

No, search for AddType and place it below them, and replace the DirectoryIndex with the following suggested. Also check for LoadModule has added php or not., if not you need to do that too

Code: Select all

<IfDefine PHP5>
LoadModule php5_module        modules/libphp5.so
</IfDefine>
near LoadModules list
MattCollins
Forum Newbie
Posts: 5
Joined: Tue Jan 30, 2007 3:11 am

Post by MattCollins »

Ok added everything you've said. Nothing seems to have worked :(

Downloaded XAMPP and installed. All services running. Still get the "Do you want to open or save the file?" box. Added the extra lines into the conf file and still getting this.

Any other ideas?
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

Kindly read the readme_en file of xampp, everything will be alright.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

MattCollins wrote:Have done that but as soon as i double click the file it asks me to open or save again :(
The webserver(and php) has to process the file. You have to request it via http://localhost instead of double-clicking it in the windows (file) explorer.
Post Reply