Working through Head First PHP & MySQL as a newbie.

I first had EasyPHP installed and managed to get php using the $\_POST array and echoing nicely the html form input, but then the mail() function wouldn't work. Did some googling and found that I needed a smtp server, so then I uninstalled EasyPHP and installed XAMPP. I put my html and php files in the htdocs folder. The html form works but the php generates a page showing the code of the php rather than the the data held in the $\_POST array. I have had no success with the sql INSERT query either.

I have also tried the code provided by the online answers to the book - no joy.

I have made sure that the Apache and MySQL servers are running. I have also successfully used phpMyAdmin. So it seems these modules are working OK - just nothing I've written.

I also uninstalled XAMPP and installed the latest Apache and MySQL servers following the book's instructions to the letter - again no joy.

I have checked for loitering folders and cleaned the registry between each uninstall and reinstall.

I'm on windows 7 home premium 32bit.

Here's my html:

```
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="style.css" /> 
    </head>
    <body>
        <h1>Share your story of alien abduction:</h1>
        <form method="post" action ="report.php">
            <label for="firstname">First name:</label>
            <input type="text" id = "firstname" name="firstname" /><br/>

            <label for="lastname">Last name:</label>
            <input type="text" id = "lastname" name="lastname"/><br/>

            <label for"email">What is your email address?</label>
            <input type "text" id = "email" name="email"/><br/>

            <label for="when">When did it happen?</label>
            <input type "text" id="when" name="when"/><br/>

            <label for="howlong">How long were you gone?</label>
            <input type="text" id="howlong" name="howlong"/><br/>

            <label for="howmany">How many did you see?</label>
            <input type = "text" id="howmany" name="howmany"/><br/>

            <label for="describe">Describe them:</label>
            <input type="text" id="describe" name="describe"/><br/>

            <label for="whattheydid">What did they do to you?</label>
            <input type="text" id="whattheydid" name="whattheydid"/><br/>

            <label for="fangspotted">Have you seen my dog Fang?</label>

            Yes <input type="radio" id="fangspotted" name="fangspotted" value="yes" />
            No <input type="radio" id="fangspotted" name="fangspotted" value="no" /><br />

            <img src="fang.jpg" width="100" height="175"><br/>

            <label for="other">Any other info then?</label>
            <textarea name="other"></textarea><br />

            <input type="submit" value="Send the skinny" name="submit" />
        </form>
    </body>
</html>

```

And here's my php:

```
<html>
    <head>
        <title>Aliens abducted me - Report an abduction</title>
    </head>
    <body>

    <h2>Aliens abducted me - Report an abduction</h2>

<?php

    $first_name = $_POST['firstname'];
    $last_name = $_POST['lastname'];
    $email = $_POST['email'];
    $when = $_POST['when'];
    $how_long = $_POST['howlong'];
    $how_many = $_POST['howmany'];
    $describe = $_POST['describe'];
    $what_they_did = $_POST['whattheydid'];
    $fang_spotted = $_POST['fangspotted'];
    $other = $_POST['other'];

    $dbc = mysqli_connect('localhost', 'root', '', 'aliendatabase');

    $query = "INSERT INTO aliens_abduction (first_name, last_name, when, how_long, " . 
    "how_many, description, what_they_did, fang_spotted, other, email) " . 
    "VALUES ('$first_name', '$last_name', '$when', '$how_long', '$how_many', " . 
    "'$describe', '$what_they_did', '$fang_spotted', '$other', '$email')";

    $result = mysqli_query($dbc, $query)
    or die ('Its fornicated');

    mysql_close($dbc);

    echo 'Thanks for submitting the form ' . $first_name . ' ' . $last_name . '.<br />';
    echo 'You were abducted ' . $when;
    echo ' by ' . $how_many . ' aliens';
    echo ' and were gone for ' . $how_long . '<br />';
    echo 'You described them like this:  ' . $describe . '<br />';
    echo 'Was fang there? ' . $fang_spotted . '<br />';
    echo 'Your email address is: ' . $email;

?>
    </body>
</html>

```

Please note I'm new here and will not take offence at advice on how to ask the question better!

Thanks in advance.