Toon posts:

[php] login doet "niks" php4 -> 3 probleem?!

Pagina: 1
Acties:
  • 134 views sinds 30-01-2008
  • Reageer

Verwijderd

Topicstarter
Heej eerst maar even het script pasen (nog niet helemaal geoptimaliseert maar dat terzeide):
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<?
if ($username &amp;amp;&amp;amp; $password )
{

include("db.inc.php");

$result = mysql_query( "SELECT * FROM users WHERE name = '$username'" );
$users = mysql_fetch_array( $result );

if ($users != '0')
{
    if ($password == $users[password])
    {
        function make_session_id($length) 
        {   
            $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
            mt_srand((double) microtime() * 1000000);   
            for ($i=1;$i<=$length;$i++) 
                {       
                $blaat_id .= substr($chars, mt_rand(0, strlen($chars))-1, 1);   
                }   
            return $blaat_id;
        }
        $session_id = make_session_id(20); 
            

            setcookie( "session_id", "$session_id", 0);
            $check = mysql_query("SELECT uid FROM logged_in WHERE uid = '$users[uid]'");
            $bestaat = mysql_fetch_array( $check );
            if ($bestaat == 0)
            {    
                $insert = mysql_query("INSERT INTO logged_in ( session_id, uid )
                          values( '$session_id', '$users[uid]' )");
                }
                else
                {
                    $delete = mysql_query("DELETE FROM logged_in where uid = '$users[uid]' ");
                    $insert = mysql_query("INSERT INTO logged_in ( session_id, uid )
                          values( '$session_id', '$users[uid]' )");
                }    
            print "<style><!--        A:link {text-decoration: none; color: #C0C0C0; }
            A:visited {text-decoration: none; color: #C0C0C0; }
            A:active {text-decoration: none; }
            A:hover {text-decoration: none;  color: #6F7275}
        -->
        </style>";
            print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#6F7275\">";
            print "Welcome $users[name]!<br><br>";
            
            
            if ($users[news] == 1 ) 
                print "News: <a href=add.php?item=news&amp;amp;uid=$users[uid]>Add</a> / <a href=change.php?item=news&amp;amp;uid=$users[uid]>Change</a> / <a href=delete.php?item=news&amp;amp;uid=$users[uid]>Delete</a><br>";
                else    
                print "News: no admin rights<br>";
            
            if ($users[column] == 1 ) 
                print "Column: Add / Change / Delete<br>";
                else            
                print "Column: no admin rights<br>";
            
            if ($users[team] == 1 ) 
                print "Team: <a href=add.php?item=team&amp;amp;uid=$users[uid]>Add</a> / <a href=change.php?item=team&amp;amp;uid=$users[uid]>Change</a> / <a href=delete.php?item=team&amp;amp;uid=$users[uid]>Delete</a><br>";
                else            
                print "Team: no admin rights<br>";
            
            if ($users[wars] == 1 ) 
                print "Wars: <a href=add.php?item=wars&amp;amp;uid=$users[uid]>Add</a> / <a href=change.php?item=wars&amp;amp;uid=$users[uid]>Change</a> / <a href=delete.php?item=wars&amp;amp;uid=$users[uid]>Delete</a><br>";
                else            
                print "Wars: no admin rights<br>";
                
            if ($users[demos] == 1 ) 
                print "Demos: <a href=add.php?item=demos&amp;amp;uid=$users[uid]>Add</a> / <a href=change.php?item=demos&amp;amp;uid=$users[uid]>Change</a> / <a href=delete.php?item=demos&amp;amp;uid=$users[uid]>Delete</a><br>";
                else            
                print "Demos: no admin rights<br>";
            
            if ($users[other] == 1 ) {
                print "Info: <a href=change.php?item=info&amp;amp;uid=$users[uid]>Change</a><br>";
                print "Links: <a href=change.php?item=links&amp;amp;uid=$users[uid]>Change</a><br>";
                print "Contact: <a href=change.php?item=contact&amp;amp;uid=$users[uid]>Change</a><br>";}
                else {            
                print "Other: no<br><p>";}
                    
                            
            $resultcount = mysql_query( "SELECT * FROM stats" );
            $count = mysql_fetch_array( $resultcount );

        print "<br>Visitor count: $count[count]";       
                            
        
    }
    else
    {
        print "username: ok!<br>";
        print "password: wrong!<br>";
        print "your ip has been logged and has been sent to ReaLX! ($REMOTE_ADDR)<br>";
        print "<a href=news.php>click here to continue</a>";
    }
}

elseif ($users == '0')
{
    print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#6F7275\">";
    print "username: wrong!<br>";
    print "password: wrong!<br>";
    print "your ip has been logged and has been sent to ReaLX! ($REMOTE_ADDR)<br>";
    print "<a href=news.php>click here to continue</a>";
}
mysql_close( $link );
}
else
{
    print "<font face=\"Verdana, Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#6F7275\">";
    print "please fill in all the stuff!";
}
?>

Het script draaide eerst op een server met php4, maar is gecrashed en draait sinds dien op een php3 server... Als ik via een form met daarmee de login en password in meegeef laat ie normaal (op php4 server) alles perfect zien, welke rechten je hebt enzo...
Maar nu op de php3 server krijg ik gewoon NIKS te zien :( niet eens dat het login/password verkeerd is ofzo...

Weet iemand misschien hoe ik dit kan fixen? Ik bedoel dus om het (waarschijnlijk is dit het probleem) php3 compatible te maken ?

  • marcusk
  • Registratie: Februari 2001
  • Laatst online: 26-09-2023
code:
1
if ($password == $users[password])

moet dat soms zijn:
code:
1
if ($password == $users["password"])

?

(en bij de andere arrays dus ook)

  • ACM
  • Registratie: Januari 2000
  • Niet online

ACM

Software Architect

Werkt hier

PHP:
1
2
3
4
5
<?
$delete = mysql_query("DELETE FROM logged_in where uid = '$users[uid]' ");
$insert = mysql_query("INSERT INTO logged_in ( session_id, uid )
values( '$session_id', '$users[uid]' )");
?>
Het zou heel goed aan die $array[bla] dingen binnen strings kunnen liggen?

  • Lord-M
  • Registratie: September 2000
  • Laatst online: 17-07 20:42
Op zaterdag 06 oktober 2001 23:01 schreef ReaLX het volgende:
nope :(
Uit de PHP manual:

Why is $foo[bar] wrong?
You might have seen the following syntax in old scripts:
PHP:
1
2
3
4
5
<?
$foo[bar] = 'enemy';
echo $foo[bar];
// etc
?>


This is wrong, but it works. Then, why is it wrong? The reason is that, as stated in the syntax section, there must be an expression between the square brackets ('[' and ']'). That means that you can write things like this:
PHP:
1
2
3
<?
echo $arr[ foo(true) ];
?>



This is an example of using a function return value as the array index. PHP knows also about constants, and you may have seen the E_* before.
PHP:
1
2
3
4
5
<?
$error_descriptions[E_ERROR] = "A fatal error has occured";
$error_descriptions[E_WARNING] = "PHP issued a warning";
$error_descriptions[E_NOTICE] = "This is just an informal notice";
?>



Note that E_ERROR is also a valid identifier, just like bar in the first example. But the last example is in fact the same as writing:
PHP:
1
2
3
4
5
<?
$error_descriptions[1] = "A fatal error has occured";
$error_descriptions[2] = "PHP issued a warning";
$error_descriptions[8] = "This is just an informal notice";
?>


because E_ERROR equals 1, etc.

Then, how is it possible that $foo[bar] works? It works, because bar is due to its syntax expected to be a constant expression. However, in this case no constant with the name bar exists. PHP now assumes that you meant bar literally, as the string "bar", but that you forgot to write the quotes.

Verwijderd

Topicstarter
Op zondag 07 oktober 2001 00:40 schreef ACM het volgende:

[..]

Het zou heel goed aan die $array[bla] dingen binnen strings kunnen liggen?
Hmm, maar ligt dat dan aan me "ransige code" of aan php3 ?!

Verwijderd

Topicstarter
Op zondag 07 oktober 2001 11:16 schreef Lord-M het volgende:

[..]

Uit de PHP manual:

[..]
Ik heb het geprobeerd, maar doet nog steeds even weinig :'(

Verwijderd

hmmm hier stond iets doms...

Verwijderd

Topicstarter
hmm, ik zie nu ook als ik voor username en password allebij iets invul wat niet bestaat (dus niet in de database staat) dat ie zegt dat de username WEL bestaat, maar password NIET goed is..... :? :? :?

  • marcusk
  • Registratie: Februari 2001
  • Laatst online: 26-09-2023
verander
code:
1
if ($users != '0')

eens in:
code:
1
if (mysql_num_rows($result) > 0)

is misschien niet de fout, maar iig niet echt netjes

  • ACM
  • Registratie: Januari 2000
  • Niet online

ACM

Software Architect

Werkt hier

Op zondag 07 oktober 2001 11:32 schreef ReaLX het volgende:
Hmm, maar ligt dat dan aan me "ransige code" of aan php3 ?!
Dat ligt er meer aan, dat dat in php4 veranderd was ;)

In php3 mag dit niet: $string = "blaat {$array[1][2]}";
en in php4 wel, kan heel goed dat dat ook jou dwars zit.

Verwijderd

Topicstarter
hmm najah, het draait weer op een php4 server, geen zin meer om dit uit te zoeken :D

tnx anyway :)
Pagina: 1