Directing to the same page over and over!!

Discussion in 'PHP' started by ausgezeichnete, Jan 6, 2008.

  1. #1
    I want the user to login to his client_see_fotos.php to see his own Photos

    but it redirect me always to the same page
    client_see_fotos.php?client_id=1
    so i put do{.////}while(fetch_...)
    and now it redirects me always to
    client_see_fotos.php?client_id=2
    i dont know what is wrong
    
    <?php require_once('../Connections/mystique.php'); ?>
    <?php
    mysql_select_db($database_mystique, $mystique);
    $query_Recordset1 = "SELECT * FROM clients";
    $Recordset1 = mysql_query($query_Recordset1, $mystique) or die(mysql_error());
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    $totalRows_Recordset1 = mysql_num_rows($Recordset1);
    ?>
    <?php
    // *** Validate request to login to this site.
    if (!isset($_SESSION)) {
      session_start();
    }
    
    $loginFormAction = $_SERVER['PHP_SELF'];
    if (isset($_GET['accesscheck'])) {
      $_SESSION['PrevUrl'] = $_GET['accesscheck'];
    }
    
    if (isset($_POST['username'])) {
      $loginUsername=$_POST['username'];
      $password=$_POST['password'];
      $MM_fldUserAuthorization = "";
    [B] do{[/B]
      $MM_redirectLoginSuccess = 
      "client_see_fotos.php?client_id=".$row_Recordset1['client_id'];
    [B]}while($row_Recordset1 = mysql_fetch_assoc($Recordset1));[/B]
      
      $MM_redirectLoginFailed = "failed.php";
      $MM_redirecttoReferrer = true;
      mysql_select_db($database_mystique, $mystique);
      
      $LoginRS__query=sprintf("SELECT username, password FROM clients WHERE username='%s' AND password='%s'",
        get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password)); 
       
      $LoginRS = mysql_query($LoginRS__query, $mystique) or die(mysql_error());
      $loginFoundUser = mysql_num_rows($LoginRS);
      if ($loginFoundUser) {
         $loginStrGroup = "";
        
        //declare two session variables and assign them
        $_SESSION['MM_Username'] = $loginUsername;
        $_SESSION['MM_UserGroup'] = $loginStrGroup;	      
    
        if (isset($_SESSION['PrevUrl']) && true) {
          $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];	
        }
        header("Location: " . $MM_redirectLoginSuccess );
      }
      else {
        header("Location: ". $MM_redirectLoginFailed );
      }
    }
    ?>
    
    <table border="1" align="center">
    <form name="client" action="<?php echo $loginFormAction; ?>" method="POST">
    <tr>
    <td colspan="2"><div align="center"><strong>Client login</strong></div></td>
    </tr>
    <tr>
    <th>Username</th>
    <td><input name="username" type="text"></td>
    </tr>
    <tr>
    <th>Password</th>
    <td><input name="password" type="password" ></td>
    <tr>
      <td>&nbsp;</td>
      <td><div align="center">
        <input name="submit" type="submit">
      </div></td>
    </tr>
    </form>
    </table>
    
    
    PHP:
     
    ausgezeichnete, Jan 6, 2008 IP
  2. ausgezeichnete

    ausgezeichnete Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    No,it redirects me always to the last id when i put do{ //}while{}
    and to the first id when i remove it

    whats wrong???????????????
     
    ausgezeichnete, Jan 6, 2008 IP
  3. ausgezeichnete

    ausgezeichnete Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    btw,thnxxx i solved it now by changing
    
     $query_Recordset1 = "SELECT * FROM clients";
    
    PHP:
    to
    
     $query_Recordset1 = sprintf("SELECT * FROM clients WHERE username='".$username."' and password='".$password."'");
    
    PHP:
    thnxxxxxxxxxx it take me hours to do it
    now it logs me to the client page
     
    ausgezeichnete, Jan 6, 2008 IP