FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


HomeWatched TopicsRegisterSearchDirectory
FAQMemberlistUsergroupsLog inStoresItemsBank
Google

Reply to topic Page 1 of 1
login system
Message  

Reply with quote
Post login system 
Hi

Sorry for my english (i'm from poland Wink ) .I have to do login system. I have login.php page with login form. I have to login to database (MySQL), and I have to have 3 users. After login I have to redirect those uers to their site. Admin user to him site, moderator to him site, user to him site. User have to have less privilages (just read, selected information from database)
Any conncept?  Very Happy

View user's profile Send private message

Reply with quote
Post  
http://www.phpmyedit.org/ to make a forum
http://www.phpmyadmin.net/ great tool, sounds like what you are describing.  check these out they should at least give you some inspiration.

View user's profile Send private message AIM Address

Reply with quote
Post login system 
YOU CAN TRY SOMETHING LIKE THE CODE BELOVE.


THIS IS THE EXAMPLE FOR CREATING DATABASE WHICH I HAVE USE TO TRY THE CODE

drop database if exists theexample;

create database theexample;

use theexample;

create table someusers
(
    username varchar(20) not null primary key,
    password char(40) not null,
    ufunction varchar(15) not null
)type=InnoDB;

create table somedata
(
    id int unsigned not null auto_increment primary key,
    somevalue varchar(20) not null,
    somenote varchar(100)
)type=InnoDB;

insert into someusers values
    ('someadmin', sha1('admin'), 'administrator'),
    ('someuser',sha1('user'), 'user'),
    ('somemoderator', sha1('moderator'), 'moderator');

insert into somedata values
    (null, 'data1', 'data1note'),
    (null, 'data2', 'data2note'),
    (null, 'data3', 'data3note');

grant select, insert, update, drop, create, create temporary tables, lock tables
on theexample.* to dataowner identified by 'dataowner';


--------------------------------------------------------------------

<?php
// THIS IS CONTENT OF thefunctions.php
// THERE ARE SOME FUNCTIONS WHICH YOU CAN USE CALL FROM OTHER SCRIPT PAGES


function db_conn(&$conndb) // CONNECT DATABASE
{
    if (@ !$conndb = mysql_connect('localhost', 'dataowner', 'dataowner'))
    {
        echo 'Database connection error.<br />';
        echo 'Please try later.';
        return false;
        exit;
    }
    $conndb = mysql_select_db('theexample');
    if (!$conndb)
        return false;
    return $conndb;
}

function prijavljenkorisnik() // CHECK IS USER LOG IN OR NOT
 {
    if (!isset($_SESSION['korisnik_fun']))
         return false;
    else
         return true;
 }

function proverikorisnika($ime, $lozinka, &$funkcija)
{
//CHECK USER NAME AND PASSWORD AND RETURN HIS FUNCTION (ADMIN, USER OR MODERATOR)

    $db = db_conn($vezadb);
    $upit = "select ufunction from someusers
            where username = '$ime'
            and password = sha1('$lozinka')";
    $rezultat = mysql_query($upit);
    if (mysql_num_rows($rezultat) == 0)
        return false;
    else            
    {
        $red = mysql_fetch_assoc($rezultat);
        $funkcija = htmlspecialchars(stripslashes($red['ufunction']));
        return true;
    }
    mysql_free_result($rezultat);
}

function logforma() // forma za prijavljivanje / odjavljivanje
{
// MAKES LOG IN INTERFACE
?>
    <html>
    <head>
        <title>LOG IN</title>
    </head>
    <body bgcolor="#CCCCCC">
          <form method='post' action="switchpage.php" name="logst">
            <h4 align="center">Please log in.</h4>
             <table bgcolor='#ffffff' align="center">
                <tr>
                     <td>User name:</td>
                     <td><input type="text" name="name" size="20" maxlength="20" /></td>
                </tr>
                   <tr>
                     <td>Password:</td>
                     <td><input type="password" name="pas" size="40" maxlength="40" /></td>
                </tr>
                   <tr>
                     <td colspan="2" align="center">
                         <input type="submit" value="Log in" />
                    </td>
                </tr>
             </table>
        </form>
<?php
}

function adminpage() // administrator page
{
// MAKES ADMINISTRATOR INTERFACE

    if (@ !db_conn(&$vezadb))
    {
        echo 'ERROR';
        exit;
    }
    
    $upit = "select id, somevalue, somenote from somedata order by id";
    $rezultat = mysql_query($upit);
    ?>
    <form method="post" action="proccesspage.php"> <!-- HERE YOU CAN JUMP TO SOME PAGE WHERE PROCCESS DATA -->
        <table width="800" align="center"><tr><td>
            <table align="left" width="100%">
                <tr>
                    <td align="left">
                        <input type="submit" value="Add" name="action" />
                    </td>
                    <td align="right">
                        <input type="submit" value="Edit" name="action" />
                        <input type="submit" value="Delete" name="action" />
                    </td>
                </tr>
            </table>
            </td></tr>
            <tr><td>            
            <table align="left" width="100%" border="1">
                <thead bgcolor="#3366CC">
                    <tr>
                        <td align="left">BR</td>
                        <td align="left">ID</td>
                        <td align="left">Some value</td>
                        <td align="right">Some note</td>
                        <td>&nbsp;</td>
                    </tr>
                </thead>
                <tbody>
    <?php    
        $brojsl = mysql_num_rows($rezultat);
        for ($i = 0; $i < $brojsl; $i++)
        {
            $red = mysql_fetch_assoc($rezultat);
            $valuecheck = $red['id'];
    ?>
                    <tr>
                        <td align="left" valign="top"><?php echo $i + 1; ?></td>
                        <td align="left" valign="top"><?php echo htmlspecialchars(stripslashes($red['id'])); ?></td>
                        <td align="right" valign="top"><?php echo stripslashes($red['somevalue']); ?></td>
                        <td align="right" valign="top"><?php echo stripslashes($red['somenote']); ?></td>
                        <td align="right" valign="bottom" class="tankacrta">
                            <input type="checkbox" name="cek[]" value="<?php echo "$valuecheck"; ?>" />
                            <!-- YOU CAN USE CHECK BOX ARRY TO IDENTIFIED WHICH DATA (ROW) YOU WILL DELETE, UPDATE ETC. -->
                        </td>
                    </tr>
    <?php
        }
    ?>
                </tbody>
            </table>
        </td></tr>
        <tr><td>
            <table align="left" width="100%">
                <tr>
                    <td align="left">
                        <input type="submit" value="Add" name="action" />
                    </td>
                    <td align="right">
                        <input type="submit" value="Edit" name="action" />
                        <input type="submit" value="Delete" name="action" />
                    </td>
                </tr>
            </table>                            
        </td></tr></table>
    </form>
    <?php
    mysql_free_result($rezultat);
}

function userpage() // user page
{
// MAKES USER INTERFACE

    if (@ !db_conn(&$vezadb))
    {
        echo 'ERROR';
        exit;
    }
    
    $upit = "select id, somevalue, somenote from somedata order by id";
    $rezultat = mysql_query($upit);
    ?>
    <form method="post" action="proccesspage.php"> <!-- HERE YOU CAN JUMP TO SOME PAGE WHERE PROCCESS DATA -->
        <table width="800" align="center"><tr><td>
            <table align="left" width="100%" border="1">
                <thead bgcolor="#3366CC">
                    <tr>
                        <td align="left">BR</td>
                        <td align="left">ID</td>
                        <td align="left">Some value</td>
                        <td align="right">Some note</td>
                        <td>&nbsp;</td>
                    </tr>
                </thead>
                <tbody>
    <?php    
        $brojsl = mysql_num_rows($rezultat);
        for ($i = 0; $i < $brojsl; $i++)
        {
            $red = mysql_fetch_assoc($rezultat);
            $valuecheck = $red['id'];
    ?>
                    <tr>
                        <td align="left" valign="top"><?php echo $i + 1; ?></td>
                        <td align="left" valign="top"><?php echo htmlspecialchars(stripslashes($red['id'])); ?></td>
                        <td align="right" valign="top"><?php echo stripslashes($red['somevalue']); ?></td>
                        <td align="right" valign="top"><?php echo stripslashes($red['somenote']); ?></td>
                        <td align="right" valign="bottom" class="tankacrta">
                            <input type="checkbox" name="cek[]" value="<?php echo "$valuecheck"; ?>" />
                            <!-- YOU CAN USE CHECK BOX ARRY TO IDENTIFIED WHICH DATA (ROW) YOU WILL DELETE, UPDATE ETC. -->
                        </td>
                    </tr>
    <?php
        }
    ?>
                </tbody>
            </table>
        </td></tr></table>
    </form>
    <?php
    mysql_free_result($rezultat);
}

?>


--------------------------------------------

<?php
// THIS CODE MAKES THE LOGIN PAGE

    require_once('thefunctions.php');
    logforma();
?>


--------------------------------------------------------


<?php
// THIS PAGE CHECK USER'S FUNCTION AND CALL THE PAGE WHICH FIT TO HIS PRIVILAGES

    session_start();
    require_once('thefunctions.php');
    
    if (!prijavljenkorisnik())
    {
        $ime = $_POST['name'];
        $lozinka = $_POST['pas'];
    
        if (@ !$ime || !$lozinka)
        {
            echo 'You did not supply all data. Please try again.<br />';
            echo '<a href="login.php" target="_top">Try again</a>';
            exit;
        }
        
        if (@ !proverikorisnika($ime, $lozinka, $funkcija))
        {
            echo 'Sorry, you have not privilages!<br />';
            echo '<a href="login.php" target="_top">Try again</a>';
            session_destroy();
            exit;
        }

        $_SESSION['korisnik_fun'] = $funkcija;
        $_SESSION['ime'] = $ime;
    }

    switch($funkcija)
    {
        case 'administrator':
            adminpage(); // go to administrator page
            break;
        case 'moderator':
            // go to moderator page
            break;
        case 'user':
            userpage(); // go to user page
            break;
    }
?>

AND DONT WORRY ABOUT YOUR ENGLISH.


_________________
"The only problem to drink water from cactus is ... to find a tap."
View user's profile Send private message

Reply with quote
Post  
I did not really read all of djidji's code, but if you need further help, please private message me, and I will be happy to help.


_________________
http://www.phpgfx.com
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:
Reply to topic Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
  



Google

FireFox! The PHP Forum Loans and Credit
Panama Web Design for Hire Free Insurance Quotes!
Web Hosting Advertise Here $10 a Month Designer Children
Never Pay Taxes Again HGH Domain name registration
Web Hosting and Dedicated Servers Insurance Affordable web-hosting


Web Design by PlatinumShore.com & Web Hosting by TradeWebHosting.com