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
how to pass php variable to ajax url
Collapse
X
-
Tags: None
-
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. -
thanks for ur reply the ajax url can get the php value of username and password then to redirect the given url
Code:<?php $ignoreAuth = true; include_once("interface/globals.php"); $site_id=$_GET['site_id']; $authUser=$_GET['authUser']; $clearPass=$_GET['clearPass']; //echo $site_id; if($_GET['$site_id']) { if (!empty($_GET['site'])) $site_id = $_GET['site']; else if (is_dir("sites/" . $_SERVER['HTTP_HOST'])) $site_id = $_SERVER['HTTP_HOST']; else $site_id = 'saravana'; require_once("sites/$site_id/sqlconf.php"); } ?> <html> <head> <script type="text/javascript"> function chk_hash_fn() { if(document.getElementById("site_id").value=='') { alert("Enter Facility"); document.getElementById("site_id").focus(); return false; } var str = document.forms[0].authUser.value; var str1= document.forms[0].clearPass.value; //document.write(str1); $.ajax({ url: "interface/login/validateUser.php?u="+str+"&p="+clearPass, type: "POST", dataType: "html", async: false, success: function(data){ //alert(data); if(data == 0) //VicarePlus :: If the hashing algorithm is 'MD5' { //alert("old1"+MD5(document.forms[0].clearPass.value)); //alert("new1"+SHA1(document.forms[0].clearPass.value)); document.forms[0].authPass.value=MD5(document.forms[0].clearPass.value); document.forms[0].authNewPass.value=SHA1(document.forms[0].clearPass.value); //alert("old"+document.forms[0].authPass.value); //alert("new"+document.forms[0].authNewPass.value); } else //VicarePlus :: If the hashing algorithm is 'SHA1' { document.forms[0].authPass.value=SHA1(document.forms[0].clearPass.value); } document.forms[0].clearPass.value=''; document.login_form.action="openemr/interface/main/main_screen.php?auth=login&site="+document.getElementById("site_id").value; document.login_form.submit(); }, error:function(){ //alert("fail"); } }); } </script> </head> <body> <form target="_top" name="login_form" method="get" action="index.php" onSubmit="return chk_hash_fn();"> <table> <tr> <td><span class="text"><?php xl('Facility:','e'); ?></span></td> <td> <input type="text" size="10" name="site_id" id="site_id"> </td></tr><tr> <td><span class="text"><?php xl('Username:','e'); ?></span></td> <td> <input type="text" size="10" name="authUser" id="authUser"> </td></tr><tr> <td><span class="text"><?php xl('Password:','e'); ?></span></td> <td> <input type="password" size="10" name="clearPass" id="clearPass"> </td></tr> <tr><td> <tr><td><input type="submit" value="submit"/></td></tr> </table> </form> </body> </html>
Comment
Comment