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"];
}
?>