Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Contact form

  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    16
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Contact form

    was wondering if anyone could please help me to add a captcha to this form please?

    Code:
    <?php
    
    //Change contact info here
    
    $webMaster = "you@yourmail.com";
    
    //END INFO
    
    if (!defined('MODULE_FILE')) {
    	header('Location: ../../index.php');
    	die();
    }
    
    require_once("mainfile.php");
    $module_name = basename(dirname(__FILE__));
    $pagetitle = "- $module_name";
    get_lang($module_name);
    
    include("header.php");
    OpenTable();
    
    function Main(){
    global $module_name, $db, $prefix, $webMaster;
    
    	echo"<center><form method='post' action='modules.php?name=$module_name&op=sendmail'>
    	<font size='24' class='title'><b>Contact</b></font><hr><br>
    
    	<table border='0' cellspacing='10' cellpadding='0'>
    		
    	<tr><td align='right'><b>Name:</b></td>
    	<td align='left'><input type='text' name='urname' size='35'></td></tr>
    
    	<tr><td align='right'><b>E-mail:</b></td>
    	<td align='left'><input type='text' name='uremail' size='35'></td></tr>
    	
    	<tr><td align='right'><b>Subject:</b></td>
    	<td align='left'><input type='text' name='ursubject' size='35'></td></tr>	
    	
    	<tr><td align='right' valign='top'><b>Message:</b></td>
    	<td align='left'><textarea cols='70' name='urmessage' rows='15'></textarea></td></tr>
    
    	<tr><td align='right'></td>
    	<td align='left'><input type='submit' name='submit' value='Send Message'></td></tr>	
    	</table></form></center>";
    			
    }
    
    function SendMail(){
    	global $webMaster;
    	if($_POST['urmessage'] !="" && $_POST['ursubject'] !="" && $_POST['urname'] !="" && $_POST['uremail'] !=""){
    
        $mail_body  = "". $_POST['ursubject']."<br><hr><br>\n\r\n";
    	$mail_body .= "". $_POST['urmessage']."\n\r\n";	
    						
    	$to = $webMaster;
    	$emailSubject = 'Webmail';	
    	$headers  = "From: ". $_POST['urname'] . " <" . $_POST['uremail'] . ">\r\n";	
        $headers .= "Content-type: text/html\r\n"; 
    	
    	mail($to, $emailSubject, $mail_body, $headers);
    	
    	/* Success Message */	
    	echo ("<center><img src=\"images/success.gif\"></center><br>");
    	echo ("<center><b>Your message has been successfully sent!</b><br><br>");
    	echo ("<center>Please allow 24hrs for a response<br>");
    	echo ("<meta http-equiv='refresh' content='5;URL=http://www.yoursite.com/index.php'><br>");
        echo ("<center><b>[</b> You are being redirected <b>]</b>");
    }else{
    	/* Error Message */
    	echo ("<center><img src=\"images/error.gif\"></center><br>");
    	echo ("<center><b>You must complete all fields!</b></center><br>");
    	echo ("<meta http-equiv='refresh' content='5;URL=modules.php?name=Contact'><br>");
    	echo ("<center><b>[</b> You are being redirected <b>]</b>");
    }
    }
    
    
    switch ($op) {
    
        default:
    	Main();
    	break;
    	
    	case "sendmail":
    	SendMail();
    	break;
    	
    }
    
    CloseTable();
    include("footer.php");
    ?>

    most appreciated

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts

  • #3
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,537
    Thanks
    45
    Thanked 259 Times in 256 Posts
    Or my personal favorite

    http://www.google.com/recaptcha

  • #4
    Regular Coder
    Join Date
    Jul 2010
    Posts
    149
    Thanks
    0
    Thanked 5 Times in 5 Posts

    PHP Add Captcha

    Please look at below URL it is help full to you

    http://www.cyberciti.biz/faq/php-cap...ptcha-example/


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •