Jump to content

Archived

This topic is now archived and is closed to further replies.

justretarded

Problem with php login sessions

Recommended Posts

Hi I'm currently working on a website and here is my problem that i been trying to fix for over a week now.
im using Dreamweaver and phpyadmin.

Im trying to make a login page which i succeded ... but when i make it go to the "private" section it simply  show the 1st on my database list

(lets say i log in as member2 ... on the 2nd page i get member1 info ... and therefore when i make a "edit profile" member2 edits member1 info) here are the login page and the private page ... thanks for your help guys

Login:
[code]<?php require_once('Connections/mysite.php'); ?>
<?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['textfield'])) {
  $loginUsername=$_POST['textfield'];
  $password=$_POST['textfield2'];
  $MM_fldUserAuthorization = "";
  $MM_redirectLoginSuccess = "members/private1.php";
  $MM_redirectLoginFailed = "members/failed1.php";
  $MM_redirecttoReferrer = false;
  mysql_select_db($database_mysite, $mysite);
 
  $LoginRS__query=sprintf("SELECT email, password FROM members WHERE email='%s' AND password='%s'",
    get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername), get_magic_quotes_gpc() ? $password : addslashes($password));
 
  $LoginRS = mysql_query($LoginRS__query, $mysite) 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']) && false) {
      $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
    }
    header("Location: " . $MM_redirectLoginSuccess );
  }
  else {
    header("Location: ". $MM_redirectLoginFailed );
  }
}
?>
<HTML><HEAD><TITLE>Bienvenue Sur le Reseau de webcam en direct</TITLE>
<META content=index,follow name=robots><LINK
href="images/main.css"
type=text/css rel=stylesheet>
<STYLE type=text/css>
.style2 {color: #FF0000}
.style5 {font-size: 12px}
.style9 {color: #999999}
.style10 {font-size: x-small}
.style11 {font-size: xx-small}
.style12 {color: #999999; font-weight: bold; }
</STYLE>
<TABLE id=header cellSpacing=0 cellPadding=0 width=900 align=center border=0>
  <TBODY>
  <TR>
    <TD width=220 height=100 rowSpan=2 align=left vAlign=top bgcolor="#FFFFFF"><p><img src="images/logo2.JPG" width="218" height="113"></p>      </TD>
    <TD width="638" height=70 align=right vAlign=top bgcolor="#FFFFFF"><div align="left"><img src="images/logo1.JPG" width="675" height="71"></div></TD>
  </TR>
  <TR>
    <TD height=30 colspan="3" bgColor=#d1d7dc>   
   
<DIV align=right></DIV></TR></TBODY></TABLE>
<BR>
<TABLE id=midmenu cellSpacing=0 cellPadding=10 width=900 align=center
  border=0>
  <TBODY>
  <TR>
    <TD width="847" vAlign=top>
      <CENTER><br><br>
</CENTER></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=900 align=center border=0>
  <TBODY>
  <TR>
    <TD></TD></TR>
  <TR>
    <TD></TD></TR>
  <TR>
    <TD></TD></TR>
  <TR>
<TD></TD></TR></TBODY></TABLE>
<TABLE id=maintable cellSpacing=10 cellPadding=0 width=900 align=center
border=0>
  <TBODY>
  <TR id=midmenu2>
    <TD width=191>
      <DIV align=left>Bienvenue Sur Notre Reseau!</DIV></TD>
    <TD width=477><div align="center"><span class="style5"><strong>Page Principale </strong></span></div></TD>
    <TD width=190>
      <div align="left"><a href="contactus.php">Contactez-nous</a> | <a href="loginw.php" class="style12">Acces restreint</a></div></TD></TR>
  <TR>
    <TD vAlign=top><TABLE class=leftmenu cellSpacing=1 cellPadding=1 width=190 border=0>
      <TBODY>
        <TR>
          <TH width="100%"> <DIV class=leftmenu2 align=center>Navigation</DIV></TH>
        </TR>
        <TR>
          <TD vAlign=top width="100%" bgColor=#efefef><p><span class="style5"><a href="index2.php">Acceuil</a></span><span class="style5"><br>
                    <a href="login.php">Mon compte </a><br>
                    <a href="signin.php"><strong>Inscrivez-Vous</strong></a> (gratuit!) <br>
                    <a href="schedule.php">Horraire des filles </a><br>
                    <a href="contactus.php">Contactez-Nous</a></span>         
            <p><span class="style5"><br>
                  <span class="style10"><span class="style11"><a href="loginw.php" class="style9"></a></span></span></span><span class="style11"><br>
                  </span><span class="style11">
                  </span>
            <p><FONT size=-2><BR>
                    <BR>
            </FONT></p></TD>
        </TR>
      </TBODY>
    </TABLE></TD>
    <TD rowspan="2" align=left vAlign=top>
      <TABLE width=475 height="426"
      border=0 cellPadding=1 cellSpacing=1 class=leftmenu id=leftmenu2>
        <TBODY>
         
          <TR>
            <TD vAlign=top width="100%" bgColor=#efefef><p><BR>
              </p>
                <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p><BR>
              </p></TD>
          </TR>
        </TBODY>
      </TABLE>
      <P align=center>&nbsp;</P>
      </TD>
    <TD vAlign=top align=right><TABLE class=leftmenu id=leftmenu2 cellSpacing=1 cellPadding=1 width=190
      border=0>
      <TBODY>
        <TR>
          <TH width="100%"> <DIV class=leftmenu2 align=center>Partenaire</DIV></TH>
        </TR>
        <TR>
          <TD width="100%" height="157" vAlign=top bgColor=#efefef><p><BR>
          </p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p><BR>
            </p></TD>
        </TR>
      </TBODY>
    </TABLE></TD>
  </TR>
  <TR>
    <TD height="224" vAlign=top><TABLE class=leftmenu id=leftmenu2 cellSpacing=1 cellPadding=1 width=190
      border=0>
        <TBODY>
          <TR>
            <TH width="100%"> <DIV class=leftmenu2 align=center>Votre Compte </DIV></TH>
          </TR>
          <TR>
            <TD width="100%" height="146" vAlign=top bgColor=#efefef><form name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
                <p>&nbsp;</p>
                <p>Email <br>
                  <input type="text" name="textfield">
                    <br>
                  Mot de Passe<br>
                  <input type="password" name="textfield2">
                  <br>
                 
                  <input type="submit" name="Submit" value="Envoyer">
                  </p>
            </form>            <p><BR>
              </p></TD>
          </TR>
        </TBODY>
      </TABLE>
      <p>&nbsp;</p></TD>
    <TD vAlign=top align=right><TABLE width=190 height="224"
      border=0 cellPadding=1 cellSpacing=1 class=leftmenu id=leftmenu2>
        <TBODY>
          <TR>
            <TH width="100%" height="27"> <DIV class=leftmenu2 align=center>Partenaire</DIV></TH>
          </TR>
          <TR>
            <TD width="100%" height="192" vAlign=top bgColor=#efefef><p><BR>
                  </p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p><BR>
              </p></TD>
          </TR>
        </TBODY>
      </TABLE></TD></TR>
  <TR>
    <TD colSpan=3><BR>
      <CENTER>
<a href="aboutus.php">A notre propos </a>| <span class="style2"><a href="policy.php">Engagement legal</a></span> | <a href="conactus.php">Nous Contacter </a> | &copy;2006<BR>
      </CENTER></TD></TR></TBODY></TABLE>[/code]

Private page:
[code]<?php require_once('../Connections/mysite.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);

  $logoutGoTo = "../index2.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!isset($_SESSION)) {
  session_start();
}
$MM_authorizedUsers = "";
$MM_donotCheckaccess = "true";

// *** Restrict Access To Page: Grant or deny access to this page
function isAuthorized($strUsers, $strGroups, $UserName, $UserGroup) {
  // For security, start by assuming the visitor is NOT authorized.
  $isValid = False;

  // When a visitor has logged into this site, the Session variable MM_Username set equal to their username.
  // Therefore, we know that a user is NOT logged in if that Session variable is blank.
  if (!empty($UserName)) {
    // Besides being logged in, you may restrict access to only certain users based on an ID established when they login.
    // Parse the strings into arrays.
    $arrUsers = Explode(",", $strUsers);
    $arrGroups = Explode(",", $strGroups);
    if (in_array($UserName, $arrUsers)) {
      $isValid = true;
    }
    // Or, you may restrict access to only certain users based on their username.
    if (in_array($UserGroup, $arrGroups)) {
      $isValid = true;
    }
    if (($strUsers == "") && true) {
      $isValid = true;
    }
  }
  return $isValid;
}

$MM_restrictGoTo = "failed1.php";
if (!((isset($_SESSION['MM_Username'])) && (isAuthorized("",$MM_authorizedUsers, $_SESSION['MM_Username'], $_SESSION['MM_UserGroup'])))) { 
  $MM_qsChar = "?";
  $MM_referrer = $_SERVER['PHP_SELF'];
  if (strpos($MM_restrictGoTo, "?")) $MM_qsChar = "&";
  if (isset($QUERY_STRING) && strlen($QUERY_STRING) > 0)
  $MM_referrer .= "?" . $QUERY_STRING;
  $MM_restrictGoTo = $MM_restrictGoTo. $MM_qsChar . "accesscheck=" . urlencode($MM_referrer);
  header("Location: ". $MM_restrictGoTo);
  exit;
}
?>
<?php
mysql_select_db($database_mysite, $mysite);
$query_Recordset1 = "SELECT * FROM members";
$Recordset1 = mysql_query($query_Recordset1, $mysite) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?>
<HTML><HEAD><TITLE>Bienvenue Sur le Reseau de webcam en direct</TITLE>
<META content=index,follow name=robots><LINK
href="../images/main.css"
type=text/css rel=stylesheet>
<STYLE type=text/css>
.style2 {color: #FF0000}
.style5 {font-size: 12px}
.style11 {font-size: xx-small}
.style12 {color: #999999; font-weight: bold; }
.style13 {color: #0000FF}
.style14 {font-size: 12px; color: #0000FF; }
.style15 {
font-size: 14px;
font-weight: bold;
}
.style16 {
color: #333333;
font-size: 9px;
}
</STYLE>
<TABLE id=header cellSpacing=0 cellPadding=0 width=900 align=center border=0>
  <TBODY>
  <TR>
    <TD width=220 height=100 rowSpan=2 align=left vAlign=top bgcolor="#FFFFFF"><p><img src="../images/logo2.JPG" width="218" height="113"></p>      </TD>
    <TD width="638" height=70 align=right vAlign=top bgcolor="#FFFFFF"><div align="left"><img src="../images/logo1.JPG" width="675" height="71"></div></TD>
  </TR>
  <TR>
    <TD height=30 colspan="3" bgColor=#d1d7dc>   
   
<DIV align=right></DIV></TR></TBODY></TABLE>
<BR>
<TABLE id=midmenu cellSpacing=0 cellPadding=10 width=900 align=center
  border=0>
  <TBODY>
  <TR>
    <TD width="847" vAlign=top>
      <CENTER><br><br>
</CENTER></TD></TR></TBODY></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=900 align=center border=0>
  <TBODY>
  <TR>
    <TD></TD></TR>
  <TR>
    <TD></TD></TR>
  <TR>
    <TD></TD></TR>
  <TR>
<TD></TD></TR></TBODY></TABLE>
<TABLE id=maintable cellSpacing=10 cellPadding=0 width=900 align=center
border=0>
  <TBODY>
  <TR id=midmenu2>
    <TD width=191>
      <DIV align=left>Bienvenue Sur Notre Reseau!</DIV></TD>
    <TD width=477><div align="center"><span class="style5"><strong>Page Principale </strong></span></div></TD>
    <TD width=190>
      <div align="left"><a href="../contactus.php">Contactez-nous</a> | <a href="../loginw.php" class="style12">Acces restreint</a></div></TD></TR>
  <TR>
    <TD vAlign=top><TABLE class=leftmenu cellSpacing=1 cellPadding=1 width=190 border=0>
      <TBODY>
        <TR>
          <TH width="100%"> <DIV class=leftmenu2 align=center>Navigation</DIV></TH>
        </TR>
        <TR>
          <TD vAlign=top width="100%" bgColor=#efefef><p><span class="style5"><a href="../index2.php">Acceuil</a></span><span class="style5"><br>
                    <a href="../login.php">Mon compte </a><br>
                    <a href="../signin.php"><strong>Inscrivez-Vous</strong></a> (gratuit!) <br>
                    <a href="../schedule.php">Horraire des filles </a><br>
                    <a href="../contactus.php">Contactez-Nous</a></span>         
            <ul>
              <li><span class="style14"><a href="profile1.php">Mon Profile</a></span></li>
              <li><a href="addpoints.php"><span class="style5 style2">Ajouter des Points</span></a></li>
              <li><a href="contactus1.php"><span class="style5">Contacter un admin</span></a></li>
              <li><a href="pointshistory1.php"><span class="style5">Historiques des points    <br>
                  </span><span class="style11"><br>
                    </span>
              </a></li>
            </ul>           
            <p><FONT size=-2><BR>
                    <BR>
            </FONT></p></TD>
        </TR>
      </TBODY>
    </TABLE></TD>
    <TD rowspan="2" align=left vAlign=top>
      <TABLE width=475 height="426"
      border=0 cellPadding=1 cellSpacing=1 class=leftmenu id=leftmenu2>
        <TBODY>
         
          <TR>
            <TD vAlign=top width="100%" bgColor=#efefef><p><BR>
              </p>
                <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p><BR>
              </p></TD>
          </TR>
        </TBODY>
      </TABLE>
      <P align=center>&nbsp;</P>
      </TD>
    <TD vAlign=top align=right><TABLE class=leftmenu id=leftmenu2 cellSpacing=1 cellPadding=1 width=190
      border=0>
      <TBODY>
        <TR>
          <TH width="100%"> <DIV class=leftmenu2 align=center>Partenaire</DIV></TH>
        </TR>
        <TR>
          <TD width="100%" height="157" vAlign=top bgColor=#efefef><p><BR>
          </p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p>&nbsp;</p>
            <p><BR>
            </p></TD>
        </TR>
      </TBODY>
    </TABLE></TD>
  </TR>
  <TR>
    <TD height="224" vAlign=top><TABLE class=leftmenu id=leftmenu2 cellSpacing=1 cellPadding=1 width=190
      border=0>
        <TBODY>
          <TR>
            <TH width="100%"> <DIV class=leftmenu2 align=center>Votre Compte </DIV></TH>
          </TR>
          <TR>
            <TD width="100%" height="146" vAlign=top bgColor=#efefef><p> Bienvenue <span class="style13"><?php echo $row_Recordset1['username']; ?></span><br>
              Vous avez : <span class="style2"><?php echo $row_Recordset1['points']; ?>  </span> point(s)           
              <p>                <a href="addpoints.php"><span class="style2">(Ajouter des points)</span></a>
              <p align="center" class="style15"><u><a href="tradepoints.php">PAYER UNE FILLE </a></u></p>
              <p align="left" class="style15 style16"><a href="<?php echo $logoutAction ?>">Deconnection</a> </p></TD>
          </TR>
        </TBODY>
      </TABLE>
      <p>&nbsp;</p></TD>
    <TD vAlign=top align=right><TABLE width=190 height="224"
      border=0 cellPadding=1 cellSpacing=1 class=leftmenu id=leftmenu2>
        <TBODY>
          <TR>
            <TH width="100%" height="27"> <DIV class=leftmenu2 align=center>Partenaire</DIV></TH>
          </TR>
          <TR>
            <TD width="100%" height="192" vAlign=top bgColor=#efefef><p><BR>
                  </p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p>&nbsp;</p>
              <p><BR>
              </p></TD>
          </TR>
        </TBODY>
      </TABLE></TD></TR>
  <TR>
    <TD colSpan=3><BR>
      <CENTER>
<a href="../aboutus.php">A notre propos </a>| <span class="style2"><a href="../policy.php">Engagement legal</a></span> | <a href="../conactus.php">Nous Contacter </a> | &copy;2006<BR>
</CENTER></TD></TR></TBODY></TABLE>

<?php
mysql_free_result($Recordset1);
?>
[/code]


thx for your help guys :)

Share this post


Link to post
Share on other sites

×

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.