Gau gau. Of course.
Here goes, though it's not perfect, doesn't function fully yet and you experts might think it is unwieldy, but here goes. It does generate a message sent to me at least! After trying out things for several hours last night, this is a milestone!
I created two files, one that contains my normal header and functioning and the form action written in html ( I haven't got round to tweaking this yet for design or content or even wording).This is the page my 'Contact us' button on the site will go to.
Then I created a file called mail.php (the first file needs this to generate the action) which holds my normal header and functioning then the php function to send the fom to me and error messages. Once the form has been sent, this will generate a new page saying. "Thank you for your message", etc. My only problem here is this seem to come up even if they haven't fill in anything, and the error message is not showing at all, but for now it work as I imagine most people will not press submit until they have filled in something. It does look like I'm missing some vital php functioning here. If someone could fill me in...
The two files contains the following:
The First file (called in my instance contactus.php)
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
pageheader('About whatever');
// your actual page content starts here
starttable("100%", 'Content block title', 1);
?>
<tr>
<td class="tableb" valign="top" align="center">
lorum ipsum lorum ipsum Hello world and all that mock text
</td>
</tr>
<?php
endtable();?>
<form action="mail.php" method="post">
<table border="0" cellspacing="0" cellpadding="5">
<tr>
<br><td>Your name:</td>
<td><input type="text" name="name" cols="60" rows="6"></td>
</tr>
<tr>
<br><td>Email address</td>
<td><input type="text" name="email" cols="60" rows="6"></td>
</tr>
<br><tr><td>Subject</td>
<td><input type="text" name="subject" cols="60" rows="6"></td>
</tr>
<tr>
<br><td valign="top">Message</td>
<td><textarea name="message" cols="60" rows="6"></textarea></td>
</tr>
<tr>
<td> </td>
<br><td><input type="submit" value="Submit">
<input type="reset" name="Reset" value="Reset"></tr></td>
</table>
</form>
<?php
// your actual page content ends here
pagefooter();
ob_end_flush();
?>
the second file (called in my instant mail.php) contains
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
pageheader('Thank you');
// your actual page content starts here
starttable("100%", 'Content block title', 1);
?>
<tr>
<td class="tableb" valign="top" align="center">
lorum ipsum lorum ipsum Hello world and all that mock text
</td>
</tr>
<?php
endtable();
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name=$_POST['name'];
checkOK($name);
$name=$_POST['subject'];
checkOK($subject);
$email=$_POST['email'];
checkOK($email);
$comments=$_POST['message'];
checkOK($message);
$to="you@yourwebsite.co.uk";
$message="$name just filled in your comments form. They said:\n$comments\n\nTheir e-mail address was: $email";
if(mail($to,"Comments From Your Site",$message,"From: $email\n")) {
echo "Thank you for your message. We'll get back to you asap";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
// your actual page content ends here
pagefooter();
ob_end_flush();
?>
Hope there's something of use here
Stock