1,105,534 Community Members

Captcha not working with jquery

Member Avatar
Light Poster
36 posts since Jan 2008
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]

am using jquery.min.js to insert a form data into myqsl db.I just added a captcha script i got online,but i keep geting an [ Notice: Undefined index: secretNumber in D:\xampp\htdocs\mim\insert.php on line 25 ].I tryed all i know ,nwwd your help.

javascript code:

<script type="text/javascript">
>         $(document).ready(function(){
>         //Get the input data using the post method when Push into mysql is clicked .. we pull it using the id fields of ID, Name and
> Email respectively...
>         $("#insert").click(function(){
>         //Get values of the input fields and store it into the variables.
>         var hotel=$("#hotel").val();
>         var guestname=$("#guestname").val();
>         var mob=$("#mob").val();
>         var email=$("#email").val();
>         var description=$("#description").val();
>         var calltime=$("#calltime").val();
>         var ftd=$("#ftd").val();          //var ftd=$("#secretNumber").val();
>         //use the $.post() method to call insert.php file.. this is the ajax request
>         $.post('insert.php', {hotel: hotel, guestname: guestname, mob: mob, email: email, description: description, calltime: calltime, ftd:
> ftd,},
>         function(data){
>         $("#message").html(data);
>         $("#message").hide();
>         $("#message").fadeIn(1500); //Fade in the data given by the insert.php file
>         });
>         return false;
>         });
>         });
>         </script>

form field captcha code:

<img src="secureImage.php" alt="CAPTCHA" />
<input name="secretNumber" id="secretNumber"  value="" maxlength="6" />


<?php session_start(); include"inc/config.php";?>

if(!empty($_POST["secretNumber"]) &&
    //Correct number is entered
    //Pull data from home.php front-end page
 //Insert Data into mysql
$query=mysql_query("INSERT INTO  cntacts (hotel,guestname,mob,email,description,calltime,ftd) VALUES('$hotel','$guestname','$mob','$email','$description','$calltime','$ftd')");
echo "<img src='img/icon/thankyou.gif' border='0' width='400' height='200' align='center'>";
else{ echo "An error occurred!".mysql_error(); }
    //Display error message
     echo "An error occurred!".$_POST["secretNumber"];
Member Avatar
Where are my eyes?
12,980 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,848 [?]
Skill Endorsements: 92 [?]
{hotel: hotel, guestname: guestname, mob: mob, email: email, description: description, calltime: calltime, ftd:
> ftd,},

I can't see secretName in the list. You can't pick up $_POST['var'] directly from a form sent by Ajax. It either has to be sent via parameter (.post or .get or .ajax etc) or serialized and then sent.

So, add the parameter to your list.

This article has been dead for over three months: Start a new discussion instead
Start New Discussion
View similar articles that have also been tagged: