Jump to content

rohan.bajaj17

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

rohan.bajaj17's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. i have table login master in database (username,password,status)...i differentiate logins according to status (tm,oa,tl,frnc,dealer,me,admin)...when username,password and status matches it redirects to related header......so please give me solution ....solution must be through ajax and php.....here wht i did......see examle below......index .php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252" /> <title></title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <link rel="stylesheet" type="text/css" href="style/admin.css" /> <script src="js/jquery.js" type="text/javascript" language="javascript"></script> <script language="javascript"> $(document).ready(function() { $("#login_form").submit(function() { //remove all the class add the messagebox classes and start fading $("#msgbox").removeClass().addClass('messagebox').text('Validating....').fadeIn(1000); //check the username exists or not from ajax $.post("ajax_login.php",{ user_name:$('#username').val(),password:$('#password').val(),rand:Math.random() } ,function(data) { if(data=='yes'&& id=='1') //if correct login detail { $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('Logging in.....').addClass('messageboxok').fadeTo(900,1, function() { //redirect to secure page document.location = '../oshonicaoriginalfinal/topmanagement/top_management_admin.php'; }); }); } else { $("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox { //add message and change the class of the box and start fading $(this).html('Your login detail is wrong.....').addClass('messageboxerror').fadeTo(900,1); }); } }); return false; //not to post the form physically }); //now call the ajax also focus move from $("#password").blur(function() { $("#login_form").trigger('submit'); }); }); </script> <style type="text/css"> <!-- .buttondiv {margin-top: 10px; } .top {margin-bottom: 15px; } --> </style> <style type="text/css"> body { font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px; } .top { margin-bottom: 15px; } .buttondiv { margin-top: 10px; } .messagebox{ position:absolute; width:100px; margin-left:30px; border:1px solid #c93; background:#ffc; padding:3px; } .messageboxok{ position:absolute; width:auto; margin-left:30px; border:1px solid #349534; background:#C9FFCA; padding:3px; font-weight:bold; color:#008000; } .messageboxerror{ position:absolute; width:auto; margin-left:30px; border:1px solid #CC0000; background:#F7CBCA; padding:3px; font-weight:bold; color:#CC0000; } .buttondiv1 {margin-top: 10px; } .buttondiv1 {margin-top: 10px; } </style> </head> <body> <div id="main_container"> <div id="header"> <div id="logo"></div> <div class="banner_adds"></div> </div> <div id="main_content"> <div class="admin_login"> <div class="center_right_box"> <form action="" method="post" name="login_form" id="login_form"> <div align="center"> <div class="top" ><span class="box_title"><span>Admin</span> login</span></div> <div > User Name : <input name="username" type="text" id="username" value="" maxlength="20" /> </div> <div style="margin-top:5px" > Password : <input name="password" type="password" id="password" value="" maxlength="20" /> </div> <div class="buttondiv"> <input name="Submit" type="submit" id="submit" value="Login" style="margin-left:-10px; height:23px" /> <span id="msgbox" style="display:none"></span> </div> </form> </div> </div> <!-- end of main_content --> </div> <!-- end of main_container --> </body> </html> ajax_login.php <?php session_start(); //Connect to database from here $link = mysql_connect('localhost', 'root', ''); if (!$link) { die('Could not connect: ' . mysql_error()); } //select the database | Change the name of database from here mysql_select_db('osho'); //get the posted values $user_name=htmlspecialchars($_POST['user_name'],ENT_QUOTES); $pass=($_POST['password']); //now validating the username and password $sql="SELECT username, password,status FROM login_master WHERE username='".$user_name."'"; $result=mysql_query($sql); $row=mysql_fetch_array($result); $status[]='tm'; $status[]='oa'; //if username exists if(mysql_num_rows($result)>0) { //compare the password if(strcmp($row['password'],$pass)==0) { for($i=0;$i<count($status);$i++) { if(strcmp($row['status'],$status[$i])=='tm') { echo "yes"; header("loaction:../oshonicaoriginalfinal/topmanagement/top_management_admin.php?id=1"); $_SESSION['u_name']=$user_name; } if(strcmp($row['status'],$status[$i])=='oa') { echo "yes"; header("loaction:../oshonicaoriginalfinal/oa/oa_admin.php?id=2"); //now set the session from here if needed $_SESSION['u_name']=$user_name; } } } else echo "no"; } else echo "no"; //Invalid Login ?>
  2. i want to fetch databse value to textbox based in selected value form select list IN PHP AND THROUGH AJAX....please guys give some examples
  3. <?php $f="F"; $Cnt=99; //<-- id, value from DB //range of ascii, //A:0-99, B:100-199, C:200-299, ..Z:2600-2699 $asciiPrefix = (int)65; $asciiPrefix += (int)($Cnt/100); $Cnt++; $newValue =$f. chr($asciiPrefix).''.((int)$Cnt%100); echo $newValue; ?> from above code i ll get output on cnt=0 =FA1 Cnt=1=FA2.....CNT=99=A0 but i dont wanna dis like....i wanted an output like dis cnt=1=FA1 Cnt=2=FA2 ....Cnt 99=FA99 and when cnt reaches100 it will be like Cnt=100=FB1....Cnt=198=FB99......Cnt=199=FC1 Cnt=297=FC99 an so on....so guys please give me a solution how to put range A=1 to 99 den B=100 to 198 ....c=199 to 297 and z=2476 to 2574 18716_.php
  4. [<?php $f="F"; $Cnt=1; $var=4; $var2=$var; $var1=66; $var5=65; $myarray=array(); if($var==100 || $var==200) { $var2=1; $var1++; echo$var1; $var5++; echo$var5; } if($var1<93) { for($s=$var5;$s<$var1;$s++) { $char=chr($s); if($var2<100) { for($i=0;$i<$var2;$i++) { $String=$f.$char.$Cnt; //echo $String; array_push($myarray,$String); //foreach( $myarray as $key => $value) $keys = array_keys($myarray); //$lastKey = end($keys); //echo$lastKey; reset($myarray); //Safety - sets pointer to top of array $firstKey = key($myarray); // Returns the first key of it echo "Key = ".$firstKey; echo "<br>"; $Cnt++; } } } //break; $Cnt=1; } //$flag=1; ?> i already generated code like FA1 ...FA99 ....FB1 ...FB99 ...FZ1...FZ99.....i already stored in an array..u can see in above code. so i want to retrieve values one by one firstly fa1 and the fa2 and den fa3 and so on and fa1 store into database when i m trying to get keys one by one...bt it will print one key many times.... 18712_.php 18713_.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.