Hello,

I am very new to PHP and hope that someone here might be able to help with a challenge I cannot solve (yet).

I have created a simple hmtl form and corresponding php file which send some information to the designated email. However, I am not sure how to get all of the fields from the form into the email with a prefix.

In my email, I get exactly what I typed into the field 'message'. but what I would like is to have multiple fields included each with a label...such as:
name: Nick
colour: red
city: Melbourne

HTML:
<form method="post" action="selfsendmail.php">
    <table border="1" cellspacing="5%"><tr>
        <td><p>Please enter your email address:</p></td>
        <td><input name="email" type="text" /></td>
    </tr>
    <tr>
        <td><p>Message:</p></td>
        <td><textarea name="message" rows="10" cols="30" ></textarea></td>
    </tr>
    <tr>
        <td><p>Please enter your favourite colour:</p></td>
        <td><input type="text" name="FavColour" /></td>
    </tr>

    <tr>
        <td><p>Please hit submit: </p></td>
        <td><input type="submit" /></td>
    </tr></table>
</form>

PHP:
<?
$email = $_POST['email'] ;
$message = $_POST['message'] ;
mail( "ccv@y7mail.com", "Application Form", $message, "From: CCV@canadaclub.com.au" );
print "Wooohooo your email has been sent";
?>

Thanks in advance.

Replace your 25th line

$message = "E-mail:".$_POST['email']."<br>Color:".$_POST['FavColour']."<br>Message:".$_POST['message'] ;

Karthik,

Thanks for the prompt reply. I modified it slightly to get a more desired output...thank you!

$message = "E-mail: ".$_POST['email']."\r\nColor: ".$_POST['FavColour']."\r\nMessage: ".$_POST['message'] ;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.