Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 132,679 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,185 people online right now. Registration is fast and FREE... Join Now!




How to use session in login

 
Reply to this topicStart new topic

How to use session in login

antiturncoat
post 8 Aug, 2007 - 03:07 PM
Post #1


D.I.C Head

**
Joined: 8 Aug, 2007
Posts: 98


My Contributions


Good Day! I'm having a problem with this using sessions here are my problems

*When I tried to use session_start(); and error occured like this
Warning: open(/tmp\sess_2e57cbe4af9c8fc7535726456ad13470,O_RDWR) failed: No such file or directory (2) in c:\phpdev5\www\softlandia\login.php on line 3

*I can't get to the admin page it always direct me to the customer page even though i specified the location to the admin page

*One last thing.. I wanted to use a dialog box when prompting errors could you please help me

Thanks guys

CODE
<?php

ob_start();
include 'includes\connect.php';
require_once('includes\connect.php');

   if(isset($_POST['Login'])){
      $username=$_POST['username'];
      $password=$_POST['password'];

      if(empty($username)){
          $problem=true;
          $errors="<li>Empty Username</li>";
      }

       else if(empty($password)){
          $problem=true;
          $errors="<li>Empty Password</li>";
       }

       if(!$problem){
          $query = "Select username,password from accounts where username ='$username' and password='$password'";
          $result = mysql_query($query) or die(mysql_error());
    
          if(mysql_num_rows($result)==0){
             $errors="<li>Incorrect Username or Incorrect Password</li>";
          }
          else{
             //Custome succesfully log in
             header("Location: Customer.php");
         }
         }
      else{
         $query1 = "Select username,password from admin where username ='$username' and password='$password'";
         $result1 = mysql_query($query1) or die(mysql_error());

         if(mysql_num_rows($result1)==0){
            $errors="<li>Incorrect Username or Incorrect Password</li>";  
         }
         else{
            //Admin succesfully log in
            header("Location: Admin.php");
        }
    }
}

?>


[mod edit] How is it that someone is able to program, yet unable to use simple [ code ] tags?
User is offlineProfile CardPM

Go to the top of the page

PsychoCoder
post 8 Aug, 2007 - 03:35 PM
Post #2


using DIC.Core;

Group Icon
Joined: 26 Jul, 2007
Posts: 8,933



Thanked 118 times

Dream Kudos: 8525

Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions


Login with sessions

Theres a little piece I wrote on using sessions with your login. Hope it helps smile.gif

Happy Coding!

<edit>You need to put your code in code tags (see below</edit>

Attached Image

This post has been edited by PsychoCoder: 8 Aug, 2007 - 03:36 PM
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/23/08 06:35AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month