We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,561 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Captcha not working with jquery

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" />

inser.php:

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

<?
if(!empty($_POST["secretNumber"]) &&
    $_SESSION["secureNumber"]==$_POST["secretNumber"])
{
    //Correct number is entered
    //Pull data from home.php front-end page
 $hotel=$_POST['hotel'];
 $guestname=$_POST['guestname'];
 $mob=$_POST['mob'];
 $email=$_POST['email'];
 $description=$_POST['description'];
 $calltime=$_POST['calltime'];
 $ftd=$_POST['ftd'];
 //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')");
if($query){
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"];
}
?>
2
Contributors
1
Reply
6 Minutes
Discussion Span
6 Months Ago
Last Updated
2
Views
dannybarh
Newbie Poster
20 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
{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.

diafol
Keep Smiling
Moderator
10,841 posts since Oct 2006
Reputation Points: 1,675
Solved Threads: 1,536
Skill Endorsements: 61

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0682 seconds using 2.7MB