Need help with my contact form...

Soldato
Joined
27 Sep 2005
Posts
5,903
Location
Burbage, Hinckley
I am building a new website and I want a small contact form to appear in the right hand margin on every page.

I'm not savvy with php, but I can get a single contact form working without any problems by using something like thesitewizard.com

Does anyone know of any templates, wizards etc which will enable me to do this without too much php knowledge?

Any help or advice very welcome.
 
This is what I use for all my pages now, though it's self-written (with a self-written/custom captcha) so messy as hell.

On the contact page:

PHP:
<?include('../includes/quickcontactscript.php');?>

quickcontactscript.php:

PHP:
<?
$a = addslashes($_GET['a']);
if($a == "quickcontact"){
$email = addslashes($_POST['email']);
$message = nl2br($_POST['message']);
$captchaword = addslashes($_POST['captchaword']);
$captchanum = addslashes($_POST['captchanum']);
if((!$email) or (!$captchaword)){
?>
<p class="red">Oops! You missed a required field. Please try again.</p>
<?include('quickcontactform.php');
} else {
$captchawords = array("word1", "word2", "word3", "word4", "word5", "word6");
$captchanumbers = array("1", "2", "3", "4", "5", "6");
$captchaconverted = str_replace($captchawords, $captchanumbers, $captchaword);
if($captchaconverted != $captchanum){
?>
<p class="red">Oops! The word you entered to match the image was incorrect. Please try again.</p>
<?include('quickcontactform.php');
} else {

    $to = "$name <$email>"; 
    $from = "You <[email protected]>"; 
    $subject = "Quick Contact";

    $message = "HTML email content here";

    $headers = "MIME-Version: 1.0\r\n"; 
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; 
    $headers .= "From: $from\r\n"; 
    $headers .= "Cc: [email protected]";
     
if(mail($to, $subject, $message, $headers)){
?>
<p><strong>Thank you for getting in contact with us.</strong></p><p>We should get back to you within 24 hours, but if not or if your enquiry is urgent then please call us on 0800 555 555.</p>
<?
} else {
?>
<p class="red">Oops!</p><p>An error occured when trying to send your message. Please try again, or if the problem persits, please call  0800 555 555.</p>
<?
include('quickcontactform.php');
}
}
}
} else {
include('quickcontactform.php');
}
?>

quickcontactform.php:

Code:
<form id="quickcontact" name="quickcontact" method="post" action="?a=quickcontact#quickcontact"> 
<p>Email address</p>
<p><input type="text" name="email" class="input"></p>
<p>Your message</p>
<p><textarea name="message" cols="40" class="input"></textarea></p>
<?$captchanum = rand(1, 5);?>
<p><img src="/images/captcha<?=$captchanum?>.png" title="Captcha image"><input type="hidden" name="captchanum" value="<?=$captchanum?>"></p>
<p>Type the word above here</p>
<p><input type="text" name="captchaword" class="input"></p>
<p><input name="Submit" type="submit" class="submit" value="Send Message"></p></form>

Hope that helps in some way!
 
Back
Top Bottom