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);
 

        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;
  }
 

 

 
  $.ajax({
            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 {
                  //alert(msg);
                  $required.html("Your Enquiry has not been sent.").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 190
1 Jochen Arndt 165
2 PIEBALDconsult 150
3 BillWoodruff 148
4 DamithSL 140
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 28 Feb 2013
Copyright © CodeProject, 1999-2014
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