Current location: Hot Scripts Forums » General Community » Script Requests » login script


login script

Reply
  #1 (permalink)  
Old 04-20-04, 01:38 PM
cyberted cyberted is offline
New Member
 
Join Date: Apr 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
login script

hey
i want a script to do this:
from my site I want a person to login to a special area of my site withh a password and username But
when the person enter "username1" as a user name and therer passwoard i want it to go to userpage 1
put when a differnt person logon with the username "username2" i want it to go userpage2 which is totally differnt from the userpage 1

is there a script i can download for this as i have no iead about php
thanks
ed
Reply With Quote
  #2 (permalink)  
Old 04-21-04, 01:13 AM
PattonD PattonD is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Ok Bud here is my login script. it calls for User ID and sends them to thier id to edit thier info. What i basicly did is created a update script and put the id a called function in the login. and my Login SQL is the same as Users Profiles and Info.

PHP Code:

<?php // accesscontrol.php

include ("common.php");
include_once(
'db.php');
session_start();

$uid = isset($_POST['uid']) ? $_POST['uid'] : $_SESSION['uid'];
$pwd = isset($_POST['pwd']) ? $_POST['pwd'] : $_SESSION['pwd'];

if(!isset(
$uid)) {
include(
'header.php');
  
?>
  <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title> Please Log In for Access </title>
    <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1" />
  </head>
  <body>
  <br>
  <h4> Login Required </h4>
  <p>You must log in to access this area of the site. If you are
     not a Admin then No access.</p>
  <p><form method="post" action="<?=$_SERVER['PHP_SELF']?>">
  <table width='300'>
    <tr>
    <td>Name: </td><td><input type="text" name="uid" size="20" /></td>
    </tr>
    <tr>
    <td>Password: </td><td><input type="password" name="pwd" SIZE="20" /></td>
    </tr>
  </table>
    <input type="submit" value="Log in" />
  </form></p>
  </body>
  </html>
  <?php
  
include('footer.php');
  exit;
}

$_SESSION['uid'] = $uid;
$_SESSION['pwd'] = $pwd;

dbConnect($base);
$sql "SELECT * FROM user WHERE
        userid = '
$uid' AND password = ('$pwd')";
$result mysql_query($sql);
if (!
$result) {
  
error('A database error occurred while checking your '.
        
'login details.\\nIf this error persists, please '.
        
'contact [email]webmaster@patton-designs.com[/email].');
}

if (
mysql_num_rows($result) == 0) {
  unset(
$_SESSION['uid']);
  unset(
$_SESSION['pwd']);
 include(
'header.php');
  
?>
  <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title> Access Denied </title>
    <meta http-equiv="Content-Type"
      content="text/html; charset=iso-8859-1" />
  </head>
  <body>
  <h1> Access Denied </h1>
  <p>Your user ID or password is incorrect, or you are not a
     registered user on this site. To try logging in again, click
     <a href="<?=$_SESSION['PHP_SELF']?>">here</a>.</p>
  </body>
  </html>
  <?php
  
include('footer.php');
  exit;
}

$username mysql_result($result,0,'fullname');
$id mysql_result($result,0,'id');

?>
Ok Notice at the end the
$id = mysql_result($result,0,'id');
That calls for thier id!

Now the common.php
PHP Code:

<?php // common.php


function error($msg) {
    
?>
    <html>
    <head>
    <script language="JavaScript">
    <!--
        alert("<?=$msg?>");
        history.back();
    //-->
    </script>
    </head>
    <body>
    </body>
    </html>
    <?
    
exit;
}
?>

Now lets do the Edit Profile.

PHP Code:

<?php

include('db.php');
include(
'accesscontrol.php');
$dbcnx mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($base,$dbcnx);
include(
'header.php');

if (
$submit) {


  if (
$id) {

    
$sql "UPDATE user SET name='$name',email='$email',fullname='$fullname',age='$age',location='$location',weapon='$weapon',map='$map',quote='$quote',manufacturer='$manufacturer',processor='$processor',memory='$memory',harddrive='$harddrive',videocard='$videocard',soundcard='$soundcard',monitor='$monitor',headphones='$headphones',keyboard='$keyboard',mouse='$mouse',other='$other',userid='$userid',password='$password' WHERE id=$id";

  }


  
$result mysql_query($sql);

  echo 
"Record updated/edited!<p>";


} else {


  if (!
$id) {

    
$result mysql_query("SELECT * FROM user",$dbcnx);

    while (
$myrow mysql_fetch_array($result)) {


      
printf("<br>"$PHP_SELF$myrow["ID"]);

    }

  }



  
?>
  <center>
  <table width=574>

  <form method="post" action="<?php echo $PHP_SELF?>">

  <?php



  
if ($id) {


    
$sql "SELECT * FROM user WHERE id=$id";

    
$result mysql_query($sql);

    
$myrow mysql_fetch_array($result);

    
$id $myrow["id"];

    
$name $myrow["name"];
    
    
$email $myrow["email"];

    
$fullname $myrow["fullname"];

    
$age $myrow["age"];

    
$location $myrow["location"];

    
$weapon $myrow["weapon"];

    
$map $myrow["map"];

    
$quote $myrow["quote"];

    
$manufacturer $myrow["manufacturer"];

    
$processor $myrow["processor"];

    
$memory $myrow["memory"];

    
$harddrive $myrow["harddrive"];

    
$videocard $myrow["videocard"];

    
$soundcard $myrow["soundcard"];

    
$monitor $myrow["monitor"];

    
$headphones $myrow["headphones"];

    
$keyboard $myrow["keyboard"];

    
$mouse $myrow["mouse"];

    
$other $myrow["other"];

    
$userid $myrow["userid"];

    
$password $myrow["password"];
    
?>

    <input type=hidden name="id" value="<?php echo $id ?>">

    <?php

  
}



  
?>

  <tr>
  <td>Name:</td><td><input type="Text" name="name" value="<?php echo $name ?>"></td>
  </tr>
  <tr>
  <td>Login Name:</td><td><input type="Text" name="userid" value="<?php echo $userid ?>"></td>
  </tr>
  <tr>
  <td>Password:</td><td><input type="password" name="password" value="<?php echo $password ?>"></td>
  </tr>
  <tr>
  <td>Email:</td><td><input type="Text" name="email" value="<?php echo $email ?>"></td>
  </tr>
  <tr>
  <td>Full Name:</td><td><input type="Text" name="fullname" value="<?php echo $fullname ?>"></td>
  </tr>
  <tr>
  <td>Age:</td><td><input type="Text" name="age" value="<?php echo $age ?>"></td>
  </tr>
  <tr>
  <td>Location:</td><td><input type="Text" name="location" value="<?php echo $location ?>"></td>
  </tr>
  <tr>
  <td>Weapon Specialty:</td><td><input type="Text" name="weapon" value="<?php echo $weapon ?>"></td>
  </tr>
  <tr>
  <td>Map Intelligence:</td><td><input type="Text" name="map" value="<?php echo $map ?>"></td>
  </tr>
  <tr>
  <td>Quote:</td><td><input type="Text" name="quote" value="<?php echo $quote ?>"></td>
  </tr>
  <tr>
  <td>Manufacturer:</td><td><input type="Text" name="manufacturer" value="<?php echo $manufacturer ?>"></td>
  </tr>
  <tr>
  <td>Processor:</td><td><input type="Text" name="processor" value="<?php echo $processor ?>"></td>
  </tr>
  <tr>
  <td>Memory:</td><td><input type="Text" name="memory" value="<?php echo $memory ?>"></td>
  </tr>
  <tr>
  <td>Hard Drive(s):</td><td><input type="Text" name="harddrive" value="<?php echo $harddrive ?>"></td>
  </tr>
  <tr>
  <td>Video Card:</td><td><input type="Text" name="videocard" value="<?php echo $videocard ?>"></td>
  </tr>
  <tr>
  <td>Sound Card:</td><td><input type="Text" name="soundcard" value="<?php echo $soundcard ?>"></td>
  </tr>
  <tr>
  <td>Monitor:</td><td><input type="Text" name="monitor" value="<?php echo $monitor ?>"></td>
  </tr>
  <tr>
  <td>Headphones:</td><td><input type="Text" name="headphones" value="<?php echo $headphones ?>"></td>
  </tr>
  <tr>
  <td>Keyboard:</td><td><input type="Text" name="keyboard" value="<?php echo $keyboard ?>"></td>
  </tr>
  <tr>
  <td>Mouse:</td><td><input type="Text" name="mouse" value="<?php echo $mouse ?>"></td>
  </tr>
  <tr>
  <td>Other:</td><td><input type="Text" name="other" value="<?php echo $other ?>"></td>
  </tr>
  <tr>
  <td></td><td><input type="Submit" name="submit" value="Edit Now"></td>
  </tr>
  </form>
  </table>
  </center>

<?php
}
include(
'footer.php');
?>
OUT OF BREATH........



ok back

here is your SQL

CREATE TABLE `user` (
`id` int(10) NOT NULL auto_increment,
`fullname` varchar(100) NOT NULL default '',
`email` varchar(100) NOT NULL default '',
`location` varchar(150) default NULL,
`name` varchar(100) NOT NULL default '',
`rank` varchar(100) NOT NULL default '',
`age` varchar(100) NOT NULL default '',
`squad` varchar(10) NOT NULL default '',
`weapon` varchar(100) NOT NULL default '',
`map` varchar(100) NOT NULL default '',
`quote` text NOT NULL,
`manufacturer` text NOT NULL,
`processor` text NOT NULL,
`memory` text NOT NULL,
`harddrive` text NOT NULL,
`videocard` text NOT NULL,
`soundcard` text NOT NULL,
`monitor` text NOT NULL,
`headphones` text NOT NULL,
`keyboard` text NOT NULL,
`mouse` text NOT NULL,
`other` text NOT NULL,
`userid` varchar(100) NOT NULL default '',
`password` varchar(16) NOT NULL default '',
`notes` varchar(255) NOT NULL default '',
`icon` varchar(100) NOT NULL default '',
`medal1` varchar(100) NOT NULL default '',
`medal2` varchar(100) NOT NULL default '',
`medal3` varchar(100) NOT NULL default '',
`medal4` varchar(100) NOT NULL default '',
`medal5` varchar(100) NOT NULL default '',
`medal6` varchar(100) NOT NULL default '',
`medal7` varchar(100) NOT NULL default '',
`medal8` varchar(100) NOT NULL default '',
`medal9` varchar(100) NOT NULL default '',
`medal10` varchar(100) NOT NULL default '',
`medal11` varchar(100) NOT NULL default '',
`medal12` varchar(100) NOT NULL default '',
`medal13` varchar(100) NOT NULL default '',
`medal14` varchar(100) NOT NULL default '',
`medal15` varchar(100) NOT NULL default '',
`medal16` varchar(100) NOT NULL default '',
PRIMARY KEY (`id`)
) TYPE=MyISAM PACK_KEYS=0 AUTO_INCREMENT=2 ;
Reply With Quote
  #3 (permalink)  
Old 05-06-04, 01:57 AM
StevieB StevieB is offline
Newbie Coder
 
Join Date: Jun 2003
Location: Scotland
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
This looks like something I could use, however because I'm a bit of a newbie I have no idea what your on about! lol
__________________
Steve Bremner
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
login script - a better way to die... timsnell PHP 5 04-06-04 11:43 AM
looking for a login script sxmlink Script Requests 3 03-26-04 10:38 PM
login script required lochie Script Requests 2 03-06-04 07:44 PM
help me improve my login script please paulj000 PHP 8 08-15-03 05:37 PM


All times are GMT -5. The time now is 11:02 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.