Click here to Skip to main content
13,005,920 members (98,768 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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";

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

<script type="text/javascript" src=""></script>
<script type="text/javascript">
$(document).ready(function() {
    window.$required = $('<div></div>').dialog({
        autoOpen: false,
        title: 'Required Information'
<script type="text/javascript">

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

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

        if(country == "") {
    $required.html("Please fill country.").dialog('open');
    return false;
        if(state == "") {
    $required.html("Please fill state.").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;


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


<form name="register" method="post" id="register" >
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>
Posted 28-Feb-13 2:49am

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170628.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2017
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