Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
checkin values against db
Old 04-02-2005, 06:07 PM checkin values against db
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
okay in my pos script for login i need it to verify at the end if admin = yes and if yes set cookie saying admin...

my login script so far. works with regular users. not for admins

PHP Code:
<?php
// login form script
require 'config.php';


//if calling pages into an index file place this section at the start of your index
if (isset($_POST['userid']) && isset($_POST['password']))
{
  
// if the user has just tried to log in
  
$query "select * from users "
           
."where username='$_POST[userid]' "
           
." and password='$_POST[password]' ";
  
$result mysql_query($query$dbh);
  
$row mysql_fetch_assoc($result);
  if (
mysql_num_rows($result) >0)  {
    
// if they are in the database register the user id
    //below are the session variables add/remove or modify these as you wish
    
$valid_user $_POST['userid'];
    
$_COOKIE['valid_user'] == $valid_user;
    
setcookie ("valid_user""$valid_user"time()+60*60*24*365"/");
    
     }
}
mysql_query($query$dbh);
if (
admin == yes) {
$_COOKIE['admin'] == "admin";
setcookie ("admin""admin"time()+60*60*24*365"/");
}
?>
<a href="member.php">Click Here to Continue</a>
this is the script for checking the user name agianst the db for access
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
 
Register now for full access!
Old 04-04-2005, 12:11 AM
metho's Avatar
Ultra Talker

Posts: 481
Location: Gold Coast - Brisbane QLD, Australia
Trades: 0
if (isset($_POST['userid']) && isset($_POST['password'])){
$query = "select * from users "
."where username='$_POST[userid]' "
." and password='$_POST[password]' ";
$result = mysql_query($query, $dbh);
$row = mysql_fetch_assoc($result);
if (mysql_num_rows($result) >0) {
$valid_user = $_POST['userid'];
$_COOKIE['valid_user'] == $valid_user;
setcookie ("valid_user", "$valid_user", time()+60*60*24*365, "/");
}
}

// you havent constructed a conditional that works with the fetch_assoc() properly

$dbAdmin = $row['insert your access column name'];
if ($dbAdmin == 'admin') {
$_COOKIE['admin'] == "admin";
setcookie ("admin", "admin", time()+60*60*24*365, "/");
}
__________________
I do
Please login or register to view this content. Registration is FREE
based.
Spend a lot of time in
Please login or register to view this content. Registration is FREE
.
And
Please login or register to view this content. Registration is FREE
chews up the rest.
metho is offline
Reply With Quote
View Public Profile Visit metho's homepage!
 
Old 04-04-2005, 11:26 AM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
thanks will try this script when i get home around 3:00

how would i write the fetch_assoc(); to work properly???? i got the main part of the script from hotscripts.com then modified it to work with the cookies and mysql database for my perposes
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1

Last edited by amw_drizz; 04-04-2005 at 11:29 AM..
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Old 04-04-2005, 06:44 PM
amw_drizz's Avatar
Ultra Talker

Posts: 340
Name: Jon
Location: New York
Trades: 0
okay after some screwing around with it i got it to do what i wanted it to do...


Thanks
__________________
AMW_Drizz
Dev Machine:: Apache 2.2.6 PHP 5.2.6 MySQL 5.1
amw_drizz is offline
Reply With Quote
View Public Profile Visit amw_drizz's homepage!
 
Reply     « Reply to checkin values against db
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.87806 seconds with 12 queries