Page 1 of 1

Problem with creation of a Login file

Posted: Sat Apr 21, 2012 11:08 am
by almossaid
Hi!

3 users from 3 different tables.(table1, table2 and table3)
I want them to use one single login.

table1 = goes to mencp.php
table2 = goes to womencp.php
table3 = goes to fotografercp.php

My login work only with user´s from table1. I don´t know what I am doing worrong...
Help please!

login.php OBS! is uppdated

Code: Select all

 <?php
session_start();
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <?php


//int $i;boolean $resultat=false;
$trouve=false;$i=0;
 while(!$trouve && $i<3){
  switch($i){
  case 0:$type="table1";  $query = "SELECT * FROM table1 WHERE username='$postuser'";break;
  case 1: $type="table2";$query = "SELECT * FROM table2 WHERE username='$postuser'";break;
  case 2: $type="table3";$query = "SELECT * FROM table3 WHERE username='$postuser'";break;
  }


loginForm
...........

Code: Select all

<?php
if($_SESSION['userlogin']==true){?>
<table width="270" height="70" border="0" align="left">
<tbody>
<tr>
<td align="right"><font style="font-size:16px; font-weight:bold; font-family:Verdana, Arial, sans-serif; color:#D9EEF2"> <?php echo "WELLCOME $_SESSION[name]";?> </font></td>
</tr>
<tr>
<td align="right"><a href="logout.php"><font style="font-size:11px; font-weight:bold; font-family:Verdana, Arial, sans-serif; color:#ffffff">LOG OUT</font></a></td>
</tr>
<tr>
<td align="right"></td>
</tr>
</tbody>
</table>
<?php }else{ ?>
<form action="login.php" method="post">
<input type="text" name="user" class="itext" size="25" />L&ouml;senord:
<table width="270" height="90" border="0" align="left">
<tbody>
<tr>
<td width="130" valign="top" height="15" align="right">Anv&auml;ndarnamn:</td>
<td valign="top" class="texta">&nbsp;</td>
</tr>
<tr>
<td width="130" valign="top" height="15" align="right">&nbsp;</td>
<td valign="top" style="width:125; height:12;background-repeat:no-repeat" class="texta"><input type="password" name="pass" class="itext" /></td>
</tr>
<tr>
<td height="15">&nbsp;</td>
<td valign="top" align="left"><input type="submit" value="Login" class="form-button" /></td>
</tr>
</tbody>
</table>
</form>
..............

config.php

Code: Select all

    <?php
    $host="localhost";
    $user="xxxxxxxxxxxxx";
    $password="xxxxxxxxxxxxxx";
    $db="xxxxxxxxxxx";
    ?> 

?>
[/syntax]

Re: Problem with creation of a Login file

Posted: Sat Apr 21, 2012 11:46 pm
by Christopher
What is not working? If you know the type of user, then you can redirect to the correct page once they are authenticated.

Re: Problem with creation of a Login file

Posted: Sun Apr 22, 2012 3:38 am
by almossaid
Hi
The problem is the construction of login file. how to create it and make it work.

thank you for answering

Re: Problem with creation of a Login file

Posted: Sun Apr 22, 2012 5:41 am
by social_experiment
Intro to / tutorial for login system
viewtopic.php?f=28&t=135287

Re: Problem with creation of a Login file

Posted: Mon Apr 23, 2012 2:42 pm
by almossaid
No help founded there.
thank you for answering me.