By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,334 Members | 2,776 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,334 IT Pros & Developers. It's quick & easy.

how to pass php variable to ajax url

ditditsasa
P: 17
i want to redirect a login page. i have three text box. these values are get by php and passed through the ajax url.how can i do that
Mar 31 '12 #1

✓ answered by limweizhong

To redirect pages, you either issue a header from PHP (search "http header redirect php" on Google), use a meta redirect (search "html meta refresh redirect" on Google), or use a script to set window.location.href (search "javascript window.location.href").

I have no clue what you're talking about after that.

Share this Question
Share on Google+
2 Replies


P: 62
To redirect pages, you either issue a header from PHP (search "http header redirect php" on Google), use a meta redirect (search "html meta refresh redirect" on Google), or use a script to set window.location.href (search "javascript window.location.href").

I have no clue what you're talking about after that.
Mar 31 '12 #2

ditditsasa
P: 17
thanks for ur reply the ajax url can get the php value of username and password then to redirect the given url
Expand|Select|Wrap|Line Numbers
  1.  <?php
  2. $ignoreAuth = true;
  3. include_once("interface/globals.php");
  4. $site_id=$_GET['site_id'];
  5. $authUser=$_GET['authUser'];
  6. $clearPass=$_GET['clearPass'];
  7. //echo $site_id;
  8. if($_GET['$site_id'])
  9. {
  10. if (!empty($_GET['site']))
  11.   $site_id = $_GET['site'];
  12. else if (is_dir("sites/" . $_SERVER['HTTP_HOST']))
  13.   $site_id = $_SERVER['HTTP_HOST'];
  14. else
  15.   $site_id = 'saravana';
  16. require_once("sites/$site_id/sqlconf.php");
  17. }
  18.  ?>
  19. <html>
  20. <head>
  21. <script type="text/javascript">
  22. function chk_hash_fn()
  23. {
  24.  if(document.getElementById("site_id").value=='')
  25.    {
  26.     alert("Enter Facility");
  27.     document.getElementById("site_id").focus();
  28.     return false;
  29.    }
  30.    var str = document.forms[0].authUser.value;
  31.    var str1= document.forms[0].clearPass.value;
  32.    //document.write(str1);
  33.    $.ajax({
  34.    url: "interface/login/validateUser.php?u="+str+"&p="+clearPass,
  35.    type: "POST",
  36.    dataType: "html",
  37.    async: false,
  38.    success: function(data){
  39.    //alert(data);
  40.     if(data == 0) //VicarePlus :: If the hashing algorithm is 'MD5'
  41.     {
  42.      //alert("old1"+MD5(document.forms[0].clearPass.value));
  43.      //alert("new1"+SHA1(document.forms[0].clearPass.value));
  44.       document.forms[0].authPass.value=MD5(document.forms[0].clearPass.value);
  45.       document.forms[0].authNewPass.value=SHA1(document.forms[0].clearPass.value);
  46.       //alert("old"+document.forms[0].authPass.value);
  47.       //alert("new"+document.forms[0].authNewPass.value);
  48.     }
  49.     else  //VicarePlus :: If the hashing algorithm is 'SHA1'
  50.     {
  51.       document.forms[0].authPass.value=SHA1(document.forms[0].clearPass.value);
  52.     }
  53.       document.forms[0].clearPass.value='';
  54.       document.login_form.action="openemr/interface/main/main_screen.php?auth=login&site="+document.getElementById("site_id").value;
  55.       document.login_form.submit();
  56.     },
  57.     error:function(){
  58.         //alert("fail");
  59.     }    
  60.     });
  61. }
  62. </script>
  63. </head>
  64. <body>
  65. <form target="_top" name="login_form" method="get" action="index.php" onSubmit="return chk_hash_fn();">
  66. <table>
  67. <tr>
  68. <td><span class="text"><?php xl('Facility:','e'); ?></span></td>
  69. <td>
  70.  
  71.  
  72. <input type="text" size="10" name="site_id" id="site_id">
  73. </td></tr><tr>
  74. <td><span class="text"><?php xl('Username:','e'); ?></span></td>
  75. <td>
  76. <input type="text" size="10" name="authUser" id="authUser">
  77. </td></tr><tr>
  78. <td><span class="text"><?php xl('Password:','e'); ?></span></td>
  79. <td>
  80. <input type="password" size="10" name="clearPass" id="clearPass">
  81. </td></tr>
  82. <tr><td>
  83. <tr><td><input type="submit" value="submit"/></td></tr>
  84.  
  85. </table>
  86. </form>
  87.  </body>
  88.  </html>
Apr 2 '12 #3

Post your reply

Sign in to post your reply or Sign up for a free account.