Page 1 of 1

Having trouble making PHP work.

Posted: Tue Jan 30, 2007 3:17 am
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]

Posted: Tue Jan 30, 2007 3:20 am
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?

Posted: Tue Jan 30, 2007 3:26 am
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

Posted: Tue Jan 30, 2007 3:30 am
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 :(

Posted: Tue Jan 30, 2007 3:39 am
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

Posted: Tue Jan 30, 2007 3:45 am
by MattCollins
Thank you, where abouts in the file do i put those? at the end?

Posted: Tue Jan 30, 2007 3:55 am
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

Posted: Tue Jan 30, 2007 5:00 am
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?

Posted: Tue Jan 30, 2007 5:15 am
by dude81
Kindly read the readme_en file of xampp, everything will be alright.

Posted: Tue Jan 30, 2007 5:40 am
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.