There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Web Design & Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Internet & Networking > Web Design & Development >
Solved: MySQL array's don't wont to work for my login :(


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
Bert_2's Avatar
Junior Member with 20 posts.
 
Join Date: Sep 2005
Experience: i now enough
01-May-2006, 07:42 AM #1
Exclamation Solved: MySQL array's don't wont to work for my login :( i don't have mutch time, help ???
I am creating a website who is limited for a select group of user who are registered and accepted by the admin, this all works with PHP and MySQL now the problem is I don't get a good result.

I create a array like this: $users = mysql_fetch_array($result);

then a try: array_key_exists($users, $user) (user is the username who tries to log in) and that didn't wont to work so I deleted it and thought I would deal with it in the final check of the username and the password.

But there it goes wrong too: $users[$user] == $password

what am I doing that couses the problem ???

Last edited by Bert_2 : 01-May-2006 01:27 PM. Reason: Don't have mutch time, I need to solve this
aburnzi's Avatar
Account Disabled with 72 posts.
 
Join Date: May 2005
Location: uk
Experience: Advanced
01-May-2006, 04:33 PM #2
try.........

$var=@mysql_fetch_array($your_query);
Bert_2's Avatar
Junior Member with 20 posts.
 
Join Date: Sep 2005
Experience: i now enough
01-May-2006, 04:50 PM #3
that doesn't make any change

this is the total code al vars and comments are in dutch I am sorry for that.
But the real problem is the array from the MySQL database ha's no primary key

PHP Code:
<?
// Gebruikersnaam en wachtwoord controleren:
if (isset($_REQUEST['gn'])) {
    
//query opstelen
    
    
$sql "SELECT `gn`, `ww` FROM `toegang` ORDER BY `gn` ASC;";
      
// Databaseverbinding openen en query uitvoeren:

      
require_once('mysql_connect.inc.php');

      
$verbinding mysql_connect(MYSQL_SERVERMYSQL_GEBRUIKERSNAAMMYSQL_WACHTWOORD) or die(mysql_error());

      
mysql_select_db(MYSQL_DATABASE) or die(mysql_error());

      
$resultaat mysql_query($sql) or die(mysql_error());

    
$gebruikers mysql_fetch_array($resultaat);

    
mysql_free_result($resultaat);

    
mysql_close($verbinding);
    

    
//controleren van gn in een formulier of cookie

    
if(isset($_POST['gn'])){
        
$gebruikersnaam $_POST['gn'];
    }elseif(isset(
$_COOKIE['gn'])){
        
$gebruikersnaam $_COOKIE['gn'];
    }else    {
        
inloggen();
    }
    
$gebruikersnaam trim(strip_tags($gebruikersnaam));
    
//controle of $gebruikersnaam een onderdeel is van de array $gebruikers

    
if(array_key_exists($gebruikersnaam$gebruikers)){
        
//controleren van ww in een formulier of cookie
        
        
if(isset($_POST['ww'])){
            
$wachtwoord $_POST['ww'];
        }elseif(isset(
$_COOKIE['ww'])){
            
$wachtwoord $_COOKIE['ww'];
        }else    {
            
$melding "er is geen wachtwoord verzonden.";
            
inloggen($gebruikersnaam$melding);
        }
        
$wachtwoord trim(strip_tags($wachtwoord));
        
//controleren of gebruikersnaam => wachtwoord
        
        
if($gebruikers[$gebruikersnaam] == $wachtwoord){
            
//cookie instellen op 15 min (= 900 sec)
            
            
$verloopt_op time() + 900;
            
//gebruikersnaam en wachtwoord opslaan in cookie
            
            
setcookie("gn"$gebruikersnaam$verloopt_op);
            
setcookie("ww"$wachtwoord$verloopt_op);
            
//toegangsnaam voor admin-control-panel instellen

        
}else{
            
$melding "$gebruikersnaam doesn't match $wachtwoord.";
            
inloggen($gebruikersnaam$melding);
        }
    }else{
        
$melding "array_key doesn't exist.";
        
inloggen($gebruikersnaam$melding);
    }
}else{
    
inloggen();
}

//functie inloggen() definiëren met het inlogformulier

function inloggen($gebruikersnaam ''$melding='')
{
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="noindex, nofollow">
<meta name="robots" content="none">
<meta name="author" content="Bert Van de Poel">
<meta name="artwork_program" content="Jasc Paint Shop Pro 8">
<meta name="code" content="PHP, MySQL, HTML, CSS and Javascript">
<meta name="artwork_help_by" content="Aurelie">
<meta name="special_thanks" content="easy computing, Ward van der Put and bčta testers">
<title>Inloggen</title>
<link href="inloggen.css" rel="stylesheet" type="text/css">
</head>
<body>
<h1>Inloggen</h1>
<?php
if(isset($melding)) {
    echo 
"<p> $melding </p>";
}
?>
<p>De rest van deze website is alleen toegankelijk voor geregistreerde en toegestane gebruikers.<br>
Als u al geregistreerd en toegestaan bent kunt u hieronder uw gebruikersnaam en wachtwoord invoeren.<br>
Als u nog niet geregistreerde bent kunt dit doen door op de index pagina op registreren te klikken.<br>
Als u al wel geregistreerd bent maar nog niet bent toegelaten kan het zijn dat u nog moet toegestaan worden, het beste wat u hieraan kunt doen is Bert Van de Poel contacteren of een <a href="mailto:admin@rpgfamilie.net">mail sturen</a>.<br></p>
<a href="index.php">Terugkeren naar start</a><br><br>
<form action="<?php echo $_SERVER['SCRIPT_NAME']; ?>" method="post">
  <table border="0" cellpadding="0" cellspacing="2" width="100%">
    <tr>
      <td>
        <label for="gn">Gebruikersnaam:</label>
      </td>
    </tr>
    <tr>
      <td><input accesskey="g" id="gn" name="gn" type="text" value="<?php echo $gebruikersnaam?>"></td>
    </tr>
    <tr>
      <td>
        <label for="ww">Wachtwoord:</label>
      </td>
    </tr>
    <tr>
      <td><input accesskey="w" id="ww" name="ww" type="password"></td>
    </tr>
    <tr>
      <td><input class="knop" type="submit" value="Inloggen"></td>
    </tr>
  </table>
</form>
</body>
</html>
<?php
    
exit;
}
?>
Can someone help me quickly couse the deadline for this website was thuaesday and here in Belgium that's in less than 2 hours so I will not get my deadline but I wont to stay as close to it as possible, please help me as quickly as possible
Bert_2's Avatar
Junior Member with 20 posts.
 
Join Date: Sep 2005
Experience: i now enough
03-May-2006, 06:48 AM #4
I solved the problem myself, I totaly fergot that the arrays are multi-dimensional but thanks anyway, if it's possible can someone delete the PHPcode above, it'll only be confusing for people couse it ha's a lot off little mistakes couse off the MySQL arrays
Reply


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

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 On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 09:02 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.