Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Ajax jQuery
Hi friends

please give solution for this issue

i am using Ajax and jquery in my appication

i want to pass session variable to other vriable through ajax please give slolution for this
actually i am using captcha for security so from catcha_config.php file am getting as code in session i want to use that captcha code in my appication

my code is here

include "db.php";
include "header.php";

session_start();
$cname=$_SESSION['6_letters_code']; // i want to use below in ajax code and send to other page

echo $cname;
//exit();

?>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
    window.$required = $('<div></div>').dialog({
        autoOpen: false,
        title: 'Required Information'
    });
});
 
</script>
<script type="text/javascript">
$(document).ready(function(){
    $("#register").submit(function(){
         name=$("#name").val();
     email=$("#email").val();
        country=$("#country").val();
         state=$("#state").val();
        letterscode=$("#letterscode").val();
        //alert(letterscode);
          message=$("#message").val();
        captchaimg=$("#captchaimg").val();
        alert(captchaimg);
 
<pre>
    if(name == &quot;&quot;) {
$required.html(&quot;Please fill name.&quot;).dialog('open');
return false;

}
 
    if(email == &quot;&quot;) {
$required.html(&quot;Please fill email.&quot;).dialog('open');
return false;

}
 
    if(country == &quot;&quot;) {
$required.html(&quot;Please fill country.&quot;).dialog('open');
return false;

}
 
    if(state == &quot;&quot;) {
$required.html(&quot;Please fill state.&quot;).dialog('open');
return false;

}
if(message == "") {
$required.html("Please fill message.").dialog('open');
return false;
}
if(letterscode == "") {
$required.html("Please fill letterscode.").dialog('open');
return false;
}

$.ajax({
type: "POST",
url: somepage.php;,
data: {
email: email,
message: message
},
success: function(msg){
 
            if(msg == 1) {
            $required.html(&quot;Your Enquiry has been sent. Support will get back to you shortly&quot;).dialog('open');
 
            }
            else {
              //alert(msg);
              $required.html(&quot;Your Enquiry has not been sent.&quot;).dialog('open');
            }
        }
    });

return false;
});
 
return true

});
</script>

<form name="register" method="post" id="register" >
<?php
if(!empty($errors)){
echo "<div style=color:red;padding-left:250px;>".nl2br($errors1)."</div>";
echo "<p style=color:red;padding-left:250px;>".nl2br($errors)."</p>";
}
?>
<table width="100%" cellspacing="5">
<tr><td>&nbsp;</td><td><span class="tmnl2">Post a Testimonials</td></tr>
<tr><td>Full Name *</td><td><input type="text" name="name" size="30" value='<?php echo htmlentities($name) ?>'></td></tr>
<tr><td>Email *</td><td><input type="text" name="email" id="email" size="30" value='<?php echo $_SESSION['username']; ?>'></td></tr>
<tr><td>Country </td><td><input type="text" name="country" size="30" value='<?php echo htmlentities($country) ?>'></td></tr>
<tr><td>State </td><td><input type="text" name="state" size="30" value='<?php echo htmlentities($state) ?>'></td></tr>
<tr><td>Message *</td><td><textarea rows="6" cols="36" name="message"><?php echo htmlentities($message) ?></textarea></td></tr>
<tr><td>Security Code *</td><td><input id="6_letters_code" name="6_letters_code" type="text"></td></tr>
<tr><td>&nbsp;</td><td><img src="captcha_code_file.php?rand=<?php echo rand(); ?>" id='captchaimg' name="captchaimg"></td></tr>
<tr><td>&nbsp;</td><td><input type="submit" value="SUBMIT" name="submit">&nbsp;&nbsp;<input type="reset" value="RESET"></td></tr>
</table>

</form>
Posted 28-Feb-13 3:49am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 310
3 ProgramFOX 265
4 CHill60 200
0 OriginalGriff 490
1 Sergey Alexandrovich Kryukov 405
2 Maciej Los 285
3 ProgramFOX 265
4 Peter Leow 210


Advertise | Privacy | Mobile
Web04 | 2.8.150331.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100