-1

I am trying to create a web form for a website, but when I hit send, the page links to the .php file. Please tell me what I am doing wrong.

The .html and .php codes respectively look like this:

<form action="email.php" method="post">
    <input class="input-text animated wow flipInY delay-02s" type="text" name="name" value="Your Name *" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;">
    <input class="input-text animated wow flipInY delay-04s" type="text" name="email" value="Your E-mail *" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;">
    <textarea class="input-text text-area animated wow flipInY delay-06s" name"description" cols="0" rows="0" onFocus="if(this.value==this.defaultValue)this.value='';" onBlur="if(this.value=='')this.value=this.defaultValue;">Describe your facilities and what you’re looking for. *</textarea>
    <input class="input-btn animated wow flipInY delay-08s" type="submit" value="send message">
</form>

<?php

$name = $_POST['name'];
$email = $_POST['email'];
$description = $_POST['description'];
$to = "Email Address";
$subject = "Facility and Other Specifications";

mail($to, $subject, $description "From: " . $name);
echo "Your message has been sent.";

?>

Also, I am not certain how to use PHP with the .php and .html files, or whether or not the operating system I am using (Snow Leopard) already comes with it.

I'm a little new to all of this, and any bit of information will be greatly appreciated.

RamenChef
  • 5,557
  • 11
  • 31
  • 43
Logan
  • 1
  • 2

2 Answers2

3

If you mean what I think you do, it's linking to the literal code of your PHP file. From that, I can tell you that you probably don't have PHP installed. Thus, you need to install it.

Nissa
  • 4,636
  • 8
  • 29
  • 37
  • I am currently using Dreamweaver on a Mac. Thus, when I get to php.net, do I just click "Installation on Mac OS X", or is there more that I have to do? – Logan May 26 '16 at 23:20
1

Be sure your php code is in a separate document (email.php).

Extra: Change

mail ($to, $subject, $description "From: " . $name);
echo "Your message has been sent.";

to

    $success = mail($to, $subject, $description "From: " . $name)
    if($success){
        echo "Your message has been sent.";
    }else{
        echo "Mail failure";
    }

Right now your code is saying success even on a failure. The mail function returns true on success so you can just check the variable to see if it worked

mcky
  • 823
  • 2
  • 7
  • 20
  • 1
    @Logan Noticed you said you were using dreamweaver. You'll want to install Apache (or an alternative web server) to use php. If you have your heart set on php and Dreamweaver, you can use http://www.tomsguide.com/faq/id-1956632/php-codes-work-dreamweaver.html to set up a php environment in Dreamweaver – mcky May 26 '16 at 23:29