Problem with creation of a Login file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
almossaid
Forum Newbie
Posts: 13
Joined: Sat Feb 25, 2012 11:27 am

Problem with creation of a Login file

Post 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]
Last edited by almossaid on Fri Jun 01, 2012 11:58 am, edited 4 times in total.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Problem with creation of a Login file

Post 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.
(#10850)
almossaid
Forum Newbie
Posts: 13
Joined: Sat Feb 25, 2012 11:27 am

Re: Problem with creation of a Login file

Post by almossaid »

Hi
The problem is the construction of login file. how to create it and make it work.

thank you for answering
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Problem with creation of a Login file

Post by social_experiment »

Intro to / tutorial for login system
viewtopic.php?f=28&t=135287
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
almossaid
Forum Newbie
Posts: 13
Joined: Sat Feb 25, 2012 11:27 am

Re: Problem with creation of a Login file

Post by almossaid »

No help founded there.
thank you for answering me.
Post Reply