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 9 of 9
  1. #1
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post

    Unhappy add a capcha on to my contact form

    hi

    what i want to do it to add a capcha on to my contact form the contact form submittes dater to a dater base and sends an email to me.

    PHP Code:
    <?php require_once('../Connections/mywigan.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function 
    GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
    {
      
    $theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

      
    $theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

      switch (
    $theType) {
        case 
    "text":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;    
        case 
    "long":
        case 
    "int":
          
    $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case 
    "double":
          
    $theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
          break;
        case 
    "date":
          
    $theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
          break;
        case 
    "defined":
          
    $theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
          break;
      }
      return 
    $theValue;
    }
    }

    $editFormAction $_SERVER['PHP_SELF'];
    if (isset(
    $_SERVER['QUERY_STRING'])) {
      
    $editFormAction .= "?" htmlentities($_SERVER['QUERY_STRING']);
    }

    if ((isset(
    $_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
      
    $insertSQL sprintf("INSERT INTO email_messages (id, email, subject, message) VALUES (%s, %s, %s, %s)",
                           
    GetSQLValueString($_POST['id'], "int"),
                           
    GetSQLValueString($_POST['email'], "text"),
                           
    GetSQLValueString($_POST['subject'], "text"),
                           
    GetSQLValueString($_POST['message'], "text"));

      
    mysql_select_db($database_mywigan$mywigan);
      
    $Result1 mysql_query($insertSQL$mywigan) or die(mysql_error());

      
    $insertGoTo "../index.php";
      if (isset(
    $_SERVER['QUERY_STRING'])) {
        
    $insertGoTo .= (strpos($insertGoTo'?')) ? "&" "?";
        
    $insertGoTo .= $_SERVER['QUERY_STRING'];
      }
      
    header(sprintf("Location: %s"$insertGoTo));
    }

    ?>
    <?php

    $to      
    'someone@somewhere.com';
    $subject $_POST['subject'];
    $message $_POST['message'];
    $headers 'From: emailadress@email.com' "\r\n" .
        
    'Reply-To: webmaster@example.com' "\r\n" .
        
    'X-Mailer: PHP/' phpversion();

    mail($to$subject$message$headers);
    ?>
    <form method="post" name="form1" action="<?php echo $editFormAction?>">
      <table align="center">
        <tr valign="baseline">
          <td nowrap align="right">Email:</td>
          <td><input type="text" name="email" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">Subject:</td>
          <td><input type="text" name="subject" value="" size="32"></td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right" valign="top">Message:</td>
          <td><textarea name="message" cols="50" rows="5"></textarea>
          </td>
        </tr>
        <tr valign="baseline">
          <td nowrap align="right">&nbsp;</td>
          <td><input type="submit" value="submit"></td>
        </tr>
      </table>
      <input type="hidden" name="id" value="">
      <input type="hidden" name="MM_insert" value="form1">
    </form>

    <p>&nbsp;</p>

    how would i add a capcha i have been tring to add one for a bit but keep failing.

    thanks again
    Last edited by phpcodelearner; 02-11-2010 at 09:13 PM.

  • #2
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    How complex of a captcha do you need?
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?

  • #3
    New Coder
    Join Date
    Mar 2005
    Posts
    59
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I'm not sure if you went here yet but they have a very easy implementation guide/system for php. Read the documentation and if you have any questions, post them.

  • #4
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post

    urrrrrrr

    uuuurrrr

    i want it a simple as possiable but still reasonably secure

    thanks agin

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

  • #6
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post
    Quote Originally Posted by MattF View Post
    yes i have been here but when i try and to put it in my form i get error i will try agin to put it in my form and post back the results

    thanks ever one

  • #7
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    recaptcha is by far the best in my opinion
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,865
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    If you are worried about accessibility, textcaptcha is a good alternative and indeed interesting!
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #9
    New Coder
    Join Date
    Feb 2010
    Posts
    50
    Thanks
    5
    Thanked 1 Time in 1 Post

    thanks everyone

    thanks every one i have got
    the
    http://www.phpcaptcha.org
    one to work it great

    thanks again sorry for the late repy


  •  

    Posting Permissions

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