Hi there, i hope someone can help me with my problem......

I have designed a web site and developed it already, i am on my Contact page and i am trying to write a php script for the user to send me email..........i have the code, and i followed several tutorials and i think teh code could be fine........anyways, when i click on the button to submit the information and to send i get a window popping up saying what programme should i use to open PHP files.......i really dont know where i have gone wrong?

below is the PHP code i am using............Can someone please have a look at it and tell me if there is anything wrong and im getting the window that asks me what should php be opened with.......?

many thanx, guys.....

<?php

/* SUBJECT AND EMAIL VARIABLES */

    $emailSubject = 'Crazy PHP Scirpting!';
    $webMaster = 'artashh@aol.com';

/* Gathering Data Variables */

    $emailField = $_POST['email'];
    $nameField = $_POST['name'];
    $phoneField = $_POST['phone'];
    $budgetField = $_POST['budget'];
    $travelersField = $_POST['travelers'];
    $commentField = $_POST['comment'];
    $newsletterField = $_POST['newsletter'];

    $body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Phone Number: $phone <br>
Budget: $budget <br>
Number of Travelers: $travelers <br>
Comments: $comments <br>
Newsletter: $newsletter <br>
EOD;

    $headers = "From: $email\r\n";
    $headers .= "Content-type: text/html\r\n";
    $success = mail($webMaster, $emailSubject, $body, $headers);


/* Results on HTML */

    $theResults = <<<EOD
<html>
<head>
<title>JakesWorks - travel made easy-Homepage</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
    background-color: #f1f1f1;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 12px;
    font-style: normal;
    line-height: normal;
    font-weight: normal;
    color: #666666;
    text-decoration: none;
}
-->
</style>
</head>

<div>
  <div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";

?>

Edited 3 Years Ago by mike_2000_17: Fixed formatting

no.....would you be able to advice me on how to do it please?

In order to run a php script, you will need to install apache web server and php. You can download it at this website:
http://www.apache.org/
www.php.net

After installing, you will need to configure the apache web server to works with php plugin. You can search on how to configure in google. If you want to make it easier, then you can search for package software with php/apache/mysql.

To send an email, you will also need to configure the smtp under php config file.

Another question is are you attempting this from your own computer or are you working on a hosted server?

If you are using a hosted server and they don't provide you with PHP then you won't be able to run it from there because most likely they won't install Apache and PHP just for you. What you would need to do is find another host that provides you with at least PHP.

If you are working on your own personal machine for testing then you can install the software and run your application locally. I would suggest that if you are only doing this for testing purposes you might want to use something like XAMPP which provides everything you need to build and test your PHP applications (Apache, MySQL and PHP) without having to do all the installation by hand which can be quite confusing if you don't know what you are doing.

yes i am working from my own computer for testing purposes and i think i will download the XAMPP to see how i get along....any update i shall post.

Thanx for your replies, much appreciated.

Another question is are you attempting this from your own computer or are you working on a hosted server?

If you are using a hosted server and they don't provide you with PHP then you won't be able to run it from there because most likely they won't install Apache and PHP just for you. What you would need to do is find another host that provides you with at least PHP.

If you are working on your own personal machine for testing then you can install the software and run your application locally. I would suggest that if you are only doing this for testing purposes you might want to use something like XAMPP which provides everything you need to build and test your PHP applications (Apache, MySQL and PHP) without having to do all the installation by hand which can be quite confusing if you don't know what you are doing.

i've downloded XAMPP and it still doesn't work? when i click on the submit button i get the window asking what programme shoudl php be opened with........and the XAMPP is running as well........im stuck, dunno what else to try...

This article has been dead for over six months. Start a new discussion instead.