If all you're doing is taking values from an email form and then emailing them to a certain email address, then it's easy. I managed it no problem and I'd never even heard of PHP 60 posts ago. Here's a simple example. Put the two files in the same directory, or alter the path in your form.
XHTML:
Code:
// Sets up the form to process the results using 'sendmail.php. Alter the path
// if 'sendmail.php' is in a different directory.
<form method="post" action="sendmail.php">
// Supplies a hidden value that will tell you what page the user came from.
// Not essential, only useful if you have more than one form like this.
<input type="hidden" name="page" value="Name of the page the form is on." class="textform"/>
// The actual form. Add extra inputs if you want more fields.
<table>
<tr>
<td>Name</td>
<td><input type="text" name="name" size="40" class="textform"/></td>
</tr>
<tr>
<td>Email Address</td>
<td><input type="text" name="email" size="40" class="textform"/></td>
</tr>
<tr>
<td>Notes</td>
<td><textarea name="notes" rows="10" cols="40" class="textform"></textarea></td>
</tr>
<tr>
<td align="right"><input type="reset" value="Clear"/></td>
<td><input type="submit" value="Send Info"/></td>
</tr>
</table>
</form>
OK, so put that in your XHTML page, editing the style to match your page. It will send the values 'page' (which might not be necessary), 'name', 'email' and 'notes' to 'sendmail.php'. Adding more fields is easy enough, just put more inputs in with the relevant details.
Now the code for sendmail.php.
PHP Code:
<?php
// Puts the user's email address in the variable $email.
$email = $_REQUEST['email'] ;
// Puts the message together. The bits in the "" are actual text, the other bits
// will insert the details from the form. \n is a line break.
$message = "Page:";
$message .= $_REQUEST['page'];
$message .= "\nName:";
$message .= $_REQUEST['name'];
$message .= "\nNotes:";
$message .= $_REQUEST['notes'];
// Sends the email to 'target@address.com' with a subject of 'Subject Of
// Email'. Inserts the message in the email. Says it's from the user's email
// address.
mail( "target@address.com", "Subject Of Email",
$message, "From: $email" );
// Redirects the user to [url]www.yoursite/thanks.html[/url].
header( "Location: http://www.yoursite/thanks.html" );
?>
OK, so obviously you have to change a few things there to reflect your site and your email address.
The
function in PHP means 'add this to what's already there' so
PHP Code:
$message .= $_REQUEST['notes'];
means 'add 'notes' to the end of $message'. So if you've added new fields to your form in the XHTML you need to add them here too. For example, if there was an input in your form named 'location', you'd need to alter the bit that generates the message in the PHP to this:
PHP Code:
$message = "Page:";
$message .= $_REQUEST['page'];
$message .= "\nName:";
$message .= $_REQUEST['name'];
$message .= "\nNotes:";
$message .= $_REQUEST['notes'];
$message .="\nLocation:";
$message .= $_REQUEST['location'];
So say some one fills in the form like this:
Name Me
Email
me@me.com
Notes Hello world!
Location Somewhere
this would send an email to the address you specify that looks like his:
Name : Me
Email :
me@me.com
Notes : Hello world!
Location : Somewhere
Hope this helps. It's the second bit of PHP advice I've given out. Let me know if it works!
Miggsy007