I
ishakya

  • Oct 26, 2011
  • Joined Jan 11, 2011
  • Ok but the thing is user id's can be the same.
    This the login code

    <?php 
    if (!isset($_SESSION)) {
      session_start();
    }
    require_once('library/myconn.php');
    require_once('library/functions.php');
    
    // *** Validate request to login to this site.
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }
    
    if (isset($_POST['uname'])) {
      $loginUsername=$_POST['uname'];
      $password=$_POST['pword'];
    
      /*$redirectLoginSuccess_sadmin = "user/sadmin_home.php";
      $redirectLoginSuccess_admin = "user/home.php";
      $redirectLoginSuccess_user = "user/user_home.php";
      $redirectLoginSuccess_client = "user/client_home.php";*/
    
      $redirectLoginSuccess_sadmin = "import/add_job.php";
    
      $redirectLoginFailed = "index.php";
    
    
    $LoginRS__query=sprintf("SELECT * FROM tbl_com_user WHERE user_uname=%s AND user_pword=%s",GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text")); 
    
    $LoginRS = mysql_query($LoginRS__query, $myconn) or die(mysql_error());
    $loginFoundUser = mysql_num_rows($LoginRS);
    //$rowent = mysql_fetch_array($LoginRS);
    //$user_level=$rowent[8];
    
    //Get the user level
    
    
    if ($loginFoundUser) {
    	$r=mysql_fetch_assoc($LoginRS);
      //declare session variables and assign them
       	$_SESSION['s_username'] = $r['user_uname'];
    	$_SESSION['s_userpword'] = $r['user_pword'];
    	$_SESSION['s_mytimezone'] = $r['user_timezone'];
    	$_SESSION['s_user_id']= $r['user_id'];
    	$_SESSION['s_my_com_id']= $r['my_com_id'];
    	$_SESSION['s_user_email']= $r['user_email'];
    	$_SESSION['s_user_level']= $r['user_level'];
    	$_SESSION['s_user_tel']= $r['user_tel'];
    
      header("Location: ". $redirectLoginSuccess_sadmin);
    
    
    /*if($_SESSION['s_user_level']=="sadmin"){
      header("Location: ". $redirectLoginSuccess_sadmin);
    }
    if($_SESSION['s_user_level']=="admin"){
      header("Location: ". $redirectLoginSuccess_admin);
    }
    if($_SESSION['s_user_level']=="user"){
      header("Location: ". $redirectLoginSuccess_user);
    }
    if($_SESSION['s_user_level']=="client"){
    header("Location: ". $redirectLoginSuccess_client);
    }*/
    
    
     }
     else {
     header("Location: ". $redirectLoginFailed );
    	//header("Location: import/add_job.php");
    
     }
    }
    ?>

    This part is the functionality part.when i log off from the site1,site 2's sessions are get crashed.What will happen if we use separate company id to track the session??
    I'm just asking....... 🙁
    please help me to solve this up
    Thanks in advance

    • Hi all,
      I think i'm always new to php because i got lots of things to learn.
      So i have a problem.
      I have two separate systems and different users logs in to this systems.When i opens those two systems and type different user names and passwords for those systems.
      Site 1:user name-ABC
      Site 2:user name-XYZ

      After some times,I log off from the site 2,and when i checks the site 1,it's uesrname has changed in to XYZ.when i click on a page in site 1,site 1's session are expired and directs me to the index page.:mad:
      i think that is a problem when we come to the real world.
      So is there any way to prevent that???
      Hope everyone got the idea...
      Waiting for your quick reply.Thanks in advance

      • Thanks johanafm,
        It helps to add columns,but i need to know can i add textboxes in that column,so user can enter values....if yes how is that possible????

        Thanks in advance
        🆒

        • actually i think it should be done using javascript.I have no idea to add column dynamically to a datagrid.

          • Hi all,
            I need to add a column to a datagrid when user click on a button.
            I can add a row to a datagrid when clicks on a button.
            [text]
            NAME VALUE VALUE
            TSH 123
            ABC 123
            [/text]
            When user clicks ADD Button,I need to add another column Same as a value to enter repeated values.I'm doing this to record earlier values.
            I hope everyone got the idea.
            Thanks all

            • Hi, i need to export particular data to a excel file.
              When user clicks on the export to link i need to display a pop up saying "Export to excel".I have some part of this.But the matter is excel creating page is showed in another tab.
              $f is='453'

              <a href="../excel1/reorder.php?id='.$f.'">Export</a>';?>

              and after that
              page redirect to this:

              <html>
              <head>
              <script language="javascript">
              function download()
              {
              	window.location='report.xls';
              }
              </script>
              </head>
              <body onLoad="download();">
              
              <?php
              
              
              require_once("excelwriter.class.php");
              require_once('../library/myconn.php');
              
              		  $u=$_POST['rquery'];
              		  $fname=$_POST['rfields'];
              
              
              
              $excel=new ExcelWriter("report.xls");
              if($excel==false)	
              echo $excel->error;
              
              $myArr=(explode(",",$fname));
              
              $excel->writeLine($myArr);
              
              
              $resultu=mysql_query($u);
               while ($rowu = mysql_fetch_array($resultu)) {
              
                for($i=0;$i<count($rowu);$i++){
              
              $myArr[$i]=$rowu[$i];
              
                 }	
                 $excel->writeLine($myArr);	
              }
              // header("refresh: 2; ../import/search_result.php");
              //exit;
              
              ?>
              
              </body>
              </html>

              The thing is i need to stay on the same page when user tries to export data to a excel...
              I hope everyone got the idea...
              Thanks in advance...
              Waiting to see some help thanks...........

              • thanks guys...
                but can u tell me how should i get the REMOTE_HOST value in the index page...

                thanks in advance.

                • Hi all,
                  our team have developed a web application to a particular company.that company is accessing the web application.That company maintain a static ip to log in.They have multiple computers in side that static ip address.Users can login to the system using their user name & passwords at any time & from any where.
                  So company management wants to allow their users to log to the system when they comes from their company static ip address. It means they cannot access to the system from outside of the company.So can i get the company static ip address from the login page????.
                  This what i have been thinking.....
                  Store the static ip address in the users table and match the ip address with the ip address got from the login page...

                  So to that i need to get ip address from login page.
                  any idea would be great.

                  Thanks in advance.......

                  • Hi all,
                    I have a php page to send multiple emails to different mail id's when user submit a button.but when i submit a button,emails will be send to first 7 or 8 mail id's.i think this is happening because of the timeout.

                    So hope all got the idea.
                    help me to figure this out
                    thanks in advance

                    • I found a code for auto complete option which used jquery.But the suggestionlist cant access using arrow keys.can someone please give suggestion to use arrow keys to select required suggestion without using mouse.

                      This is the html code for form

                      <div>
                      		<form>
                      			<div>
                      				Type your county:
                      				<br />
                      				<input type="text" size="30" value="" id="inputString" onkeyup="lookup(this.value,'12AB');" onblur="fill();" />
                      			</div>
                      
                      		<div class="suggestionsBox" id="suggestions" style="display: none;">
                      			<img src="upArrow.png" style="position: relative; top: -12px; left: 30px;" alt="upArrow" />
                      			<div class="suggestionList" id="autoSuggestionsList">
                      				&nbsp;
                      			</div>
                      		</div>
                      	</form>
                      </div>
                      

                      This is the javascript function used to popup auto complete option

                      <script type="text/javascript" src="jquery-1.2.1.pack.js"></script>
                      <script type="text/javascript">
                      	function lookup(inputString,com_id) {
                      		if(inputString.length == 0) {
                      			// Hide the suggestion box.
                      			$('#suggestions').hide();
                      		} else {
                      			$.post("rpc.php", {queryString: ""+inputString+"|"+com_id+""}, function(data){
                      				if(data.length >0) {
                      					$('#suggestions').show();
                      					$('#autoSuggestionsList').html(data);
                      				}
                      			});
                      		}
                      	} // lookup
                      
                      function fill(thisValue) {
                      	$('#inputString').val(thisValue);
                      	setTimeout("$('#suggestions').hide();", 200);
                      }
                      </script>
                      

                      This is the code for css of suggestion box and list

                      <style type="text/css">
                      	body {
                      		font-family: Helvetica;
                      		font-size: 11px;
                      		color: #000;
                      	}
                      
                      h3 {
                      	margin: 0px;
                      	padding: 0px;	
                      }
                      
                      .suggestionsBox {
                      	position: relative;
                      	left: 30px;
                      	margin: 10px 0px 0px 0px;
                      	width: 200px;
                      	background-color: #212427;
                      	-moz-border-radius: 7px;
                      	-webkit-border-radius: 7px;
                      	border: 2px solid #000;	
                      	color: #fff;
                      }
                      
                      .suggestionList {
                      	margin: 0px;
                      	padding: 0px;
                      }
                      
                      .suggestionList li {
                      
                      	margin: 0px 0px 3px 0px;
                      	padding: 3px;
                      	cursor: pointer;
                      }
                      
                      .suggestionList li:hover {
                      	background-color: #659CD8;
                      }
                      </style>
                      

                      This is the code of the rpc.php page that process the query

                      <?php
                      mysql_connect('localhost','root', '123');
                      mysql_select_db('my_db') or die(mysql_error());
                      
                      
                      $queryString = $_POST['queryString'];
                      $queryString = mysql_real_escape_string($queryString);
                      
                      		if(strlen($queryString) >0) {
                      
                      			$query =("SELECT distinct cus_name FROM tbl_cus_company WHERE cus_name LIKE '%$queryString%' LIMIT 10");
                      			$result = mysql_query($query) or die(mysql_error());
                      			$affectedRows=mysql_affected_rows();
                      			if ($affectedRows==0){
                      
                      				echo '<center>There is no Record </center>';
                      				}
                      				else{
                      			while($row1 = mysql_fetch_array($result))
                      				 {
                      
                               			echo '<li onClick="fill(\''.$row1[0].'\');">'.$row1[0].'</li>';
                               		}
                      			} 
                      
                      
                      		}
                      
                      ?>
                      

                      Hope someone will help me to solve this issue.
                      Thanks in advance..

                      • Hi all,
                        I am saving some check box ids in a java script variable when a check box is clicked.
                        So after that i need to pass that variable to a another page via url in a php code....
                        so can anyone give an idea to solve that matter.....so thanks in advance............

                        • Hi all,

                          I need to remove read only option to a set of text boxes when a check box is checked.I have done that part.But i want to apply read only option again when earlier check box is unchecked.

                          Here is the code to remove read only.

                          function closeObject(someID,someID1,someID2,someID3)
                          {
                          document.getElementById(someID).removeAttribute('readonly');
                          document.getElementById(someID1).removeAttribute('readonly');
                          document.getElementById(someID2).removeAttribute('readonly');
                          document.getElementById(someID3).removeAttribute('readonly');
                          
                          //document.getElementById(someID).value ='NEW';
                          
                          }

                          So i need to apply read only again when the check box is unchecked.

                          Need a quick response please!!!!!!!!

                          • hi all,
                            i need to convert a value(could be a integer,float) to word

                            Assume:150.23
                            Result should be😮ne Hundred Fifty and twenty three cents only.

                            Like wise....
                            So anyone can help ,it will be grate....

                            Sample code would be a grate advantage...

                            Thanks in advance

                            • Hi everyone,

                              I need to generate a report to a pdf format.I'm using php as my language & database is mysql.Server version is Apache.
                              When i press a button,normally report views as a php page.But now i need to convert it to a PDF page when i press that button.i tried the PDF converter,but it is too difficult to handle it.
                              So is everyone know how to do it by php?

                              Please help me to figure it out...
                              sample code would be an advantage....

                              Thanks in Advance

                              • rajend3; you will need to use JavaScript.[/QUOTE wrote:

                                Then can u direct me to??

                                • Hi,
                                  I need to calculate the sum of all text boxes(which user is entered) to a single text box to display.
                                  I tried many ways but couldn't fulfill it.

                                  so i have gain many results from this wonderful site.so i hope experts will help me to come up.
                                  hope all got my explanation.

                                  I'm in a little hurry.

                                  Thanks in advance....

                                  • Hi,
                                    i have a page that use to insert data to my database.After inserting the data,I'm displaying the entered data in the same page in a different div.[FONT="Arial Black"]If i hit the refresh button,page will insert duplicate data rows.And display them in the div that i mentioned[/FONT].I have given the same page as the FORM ACTION.

                                    Currently I'm using a code to that.but it is not working...

                                    header(“Location: add.php“);
                                    exit();
                                    

                                    So can anyone please help me to figure this out?
                                    And I'm in a big trouble..

                                    Thanks in advance.....

                                    • Thanks Brother.....
                                      Thanks a Lot......

                                      • Thanks NogDog for your quick reply.
                                        But can u be more specific?
                                        What is the best collation type to change the database field to a case sensitive one?
                                        please help me to figure this out..

                                        thanks in advance...

                                        • Hi,
                                          i have a login page which is connected with a mysql database table called tbl_user.
                                          Basically two fields :
                                          user_name & pass_word.
                                          Assume i have saved a user name called 'ABC' & my password is 'aBc123'.
                                          When i log in to the system i enter my user name 'ABC' & type my password as 'aBc123'.
                                          But the problem is i can log in to the system when i enter 'abc123'.But my real password is 'aBc123'.So my guess is that the password should be case sensitive.

                                          Apache/2.2.17 (Fedora)
                                          PHP Version 5.3.6
                                          mysql 5.1.56

                                          Can anyone please help me to figure this out?

                                          Thanks in advance....