473,395 Members | 1,863 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to pass php variable to ajax url

ditditsasa
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.

2 4026
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
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

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

Similar topics

1
by: weiwei | last post by:
Hi all I am having trouble, let's say, I have a form text field, and I want to pass it to the next page, however, I don not want to use submitted button, instead I want to have a variable in link...
5
by: GB | last post by:
Hello: In my MS Access project I have two objects - my form and my report. I need to pass variable value from Command_click procedure of my form to Report_open procedure of my report. How can I...
1
by: Ben Kial | last post by:
I'd like to write a wrapper function "mysprintf(char *buffer, char *format, ....)" which calls sprintf(). My question is how can I pass variable argument in mysprintf() to sprintf(). Thanks in...
8
by: darrel | last post by:
I'm still trying to fully understand how best to pass variables between pages/usercontrols/each other. On a current site I've done, I've had one userControl do the logic and set the variable,...
1
by: dollar | last post by:
I want to ask what is the best way to pass variable between asp.net we pages, and user controls , any examples - dolla -----------------------------------------------------------------------...
2
by: rhungund | last post by:
Hi all. I have a user control I'm using as my "include" file for my flash navigation. My asp.net app is written in vb.net. The swf file takes a parameter which I would like to pass into my user...
1
by: drec | last post by:
I need to pass a variable from script1.php to script2.php. The problem is that these scripts use frames and therefore I am able to pass the variable through the URL. It also does not use forms to...
1
by: vijaynarang | last post by:
strCmdLine = " " + " -o restore -url " + sSitePath + "/sites/" + sToplevelSiteName + " -filename " + sFileName+ " -overwrite "; process1 =...
12
by: simon2x1 | last post by:
i have a page which is home.php on that page i have a CSS tab which is tab1 and tab2 on that page in both tabs i have a link called next that pass variable to the next page (<a...
2
by: peachdot | last post by:
hi, The MainForm will have 2 buttons: 1.) Button A : User click button A, hide Mainform then go to form1. User enter data in the textbox.Click finish button,form1 close then go back to...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.