BetaArchive Logo
Navigation Home Screenshots Image Uploader Server Info FTP Servers Wiki Forum RSS Feed Rules Please Donate
UP: 29d, 1h, 3m | CPU: 8% | MEM: 6224MB of 11168MB used
{The community for beta collectors}

Forum rules


Any off topic discussions should go in this forum. Post count is not increased by posting here.
FTP Access status is required to post in this forum. Find out how to get it


Post new topic Reply to topic  [ 15 posts ] 
Author Message
 PostPost subject: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:01 pm 
Reply with quote
I was just playing around with PHP and MD5 again, so, heres the "Intro Site":

Offtopic Comment
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PW Test</title>
</head>
<form action="pw2.php" method="post">
Benutzername:
<input type="text" name="user"><br />
Passwort:
<input type="password" name="password"><br /><br />
<input type="submit" value="Senden!" />
</form>
<body>
</body>
</html>


That works fine, it even gives the datas to pw2.php, but now the problem code...

Offtopic Comment
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PW Test</title>
</head>

<body>
<?php
$pass = $_POST[password];
$passwortmd5 = md5(§pass);

echo ("Eingegebener Benutzername: ".$_POST[user]."<br>Eingebenes Passwort: ".$pass."<br>Die MD5 Checksum des eingebenen Passwortes lautet: ".$passwortmd5."<br>");

if($pass = $passwordmd5)
{
echo ("Not Welcome!");
}
else
{
if($_POST[user]=="Norman")
{
if($passwortmd5 = "fc7094ec962a1ca4b19421326f6903c9")
{
echo ("<br>Hello!");
}
else if ($pass = "")
{
echo ("Not Welcome!");
}
else
{
echo ("Not Welcome!");
}
}
else
{
echo ("Not Welcome!");
}
}
?>
</body>
</html>


Whatever you enter in site 1, the MD5 Code is always the same. But the "You entered this user and this pass" thing above works...

I havent written anything in PHP for ages, I forgot about 99% of it :P, so, if someone sees what I did wrong, please tell me... :)


Top
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:05 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Sun Oct 05, 2008 3:11 pm

Posts
105
are you sure that $_POST[password]; is correct? I thought it was $_POST["password"]; , wasn't it?

But I haven't written PHP for ages either ;) But it's just an idea that could help

_________________
GreetZz, Sibbl

Image


Top  Profile
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:09 pm 
Reply with quote
sibbl wrote:
are you sure that $_POST[password]; is correct? I thought it was $_POST["password"]; , wasn't it?

But I haven't written PHP for ages either ;) But it's just an idea that could help

I tried it, and sadly no, it doesnt change anything... but if you were then it wouldnt show
Code:
echo ("Eingegebener Benutzername: ".$_POST[user]."<br>Eingebenes Passwort: ".$pass."[...]);

too, or would it?

Well, it really seems to be like the process of "overgiving" it to the docs itself works, so I guess the problem is somewhere else.

But again, I dont know :P


Top
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:10 pm 
Reply with quote
Administrator
User avatar
Offline

Joined
Fri Aug 18, 2006 11:47 am

Posts
12473

Location
Merseyside, United Kingdom

Favourite OS
Microsoft Windows 7 Ultimate x64
You need to put the quotes into the $_POST request as above. I don't think it works properly otherwise as it would be expecting a variable.

Also, try to indent your code and keep the brackets on the same line, it does help.

E.G. Instead of

Code:
if($this==$that)
{
do this
}
else
{
do that
}


Try

Code:
if($this==$that){
 do this
}
else{
 do that
}


Also you'd probably be best of using an array if you want multiple logins too.

_________________
Image

BetaArchive Discord: https://discord.gg/epK3r6A


Top  Profile  WWW
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:12 pm 
Reply with quote
Code:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PW Test</title>
</head>

<body>
<?php
   $pass = $_POST["password"];
   $passwortmd5 = md5(§pass);
   
   echo ("Eingegebener Benutzername: ".$_POST[user]."<br>Eingebenes Passwort: ".$pass."<br>Die MD5 Checksum des eingebenen Passwortes lautet: ".$passwortmd5."<br>");
   
   if($pass = $passwordmd5){
      echo ("Not Welcome!");
   }
   else{
      if($_POST[user]=="Norman")
      {
         if($passwortmd5 = "fc7094ec962a1ca4b19421326f6903c9"){
            echo ("<br>Hello!");
         }
         else if ($pass = ""){
            echo ("Not Welcome!");
         }
         else{
            echo ("Not Welcome!");
         }
      }
      else{
         echo ("Not Welcome!");
      }
   }
?>
</body>
</html>


New code, did I do it correctly? Well, it still doesnt work for me :(

Oh, and thanks to you both again :P

Edit: An array wouldnt be what I want at this point, this is just "refreshing" my mind about PHP, and it should just work with that one account :P, for me at my actual status in PHP, arrays and so on would just confuse me even more :P


Top
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:15 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Sun Oct 05, 2008 3:11 pm

Posts
105
lol maybe it's just not allowed to use a number in a variable name? So try to remove the 5 at the end of "$passwordmd5". I really have no idea :D

_________________
GreetZz, Sibbl

Image


Top  Profile
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:17 pm 
Reply with quote
Administrator
User avatar
Offline

Joined
Fri Aug 18, 2006 11:47 am

Posts
12473

Location
Merseyside, United Kingdom

Favourite OS
Microsoft Windows 7 Ultimate x64
Also the if()'s should be double ='s not single, that's probably where the problem is.

_________________
Image

BetaArchive Discord: https://discord.gg/epK3r6A


Top  Profile  WWW
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:19 pm 
Reply with quote
sibbl wrote:
lol maybe it's just not allowed to use a number in a variable name? So try to remove the 5 at the end of "$passwordmd5". I really have no idea :D

Doesnt work, too :(

Quote:
Eingegebener Benutzername: banana
Eingebenes Passwort: apple
Die MD5 Checksum des eingebenen Passwortes lautet: fc7094ec962a1ca4b19421326f6903c9
Not Welcome!


Quote:
Eingegebener Benutzername: banane
Eingebenes Passwort: apfel
Die MD5 Checksum des eingebenen Passwortes lautet: fc7094ec962a1ca4b19421326f6903c9
Not Welcome!


Andy wrote:
Also the if()'s should be double ='s not single, that's probably where the problem is.

Oh, well, that solves other Problems with correct login information for me, but still not the basic MD5 one. :(


Last edited by Namronia on Fri Jun 26, 2009 6:21 pm, edited 1 time in total.

Top
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:20 pm 
Reply with quote
Administrator
User avatar
Offline

Joined
Fri Aug 18, 2006 11:47 am

Posts
12473

Location
Merseyside, United Kingdom

Favourite OS
Microsoft Windows 7 Ultimate x64
Do some debugging. Instead of "Not welcome!" put "Error 1", "Error 2" so you know where its stopping.

_________________
Image

BetaArchive Discord: https://discord.gg/epK3r6A


Top  Profile  WWW
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:25 pm 
Reply with quote
Andy wrote:
Do some debugging. Instead of "Not welcome!" put "Error 1", "Error 2" so you know where its stopping.

Ok, also I disabled the username stuff for now, but I still got the same Problem: Whatever password I enter, it always shows "fc7094ec962a1ca4b19421326f6903c9" as hash.


Top
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:28 pm 
Reply with quote
Administrator
User avatar
Offline

Joined
Fri Aug 18, 2006 11:47 am

Posts
12473

Location
Merseyside, United Kingdom

Favourite OS
Microsoft Windows 7 Ultimate x64
The $ sign you used for md5($pass); is not a $ sign at all. I just looked. That's where the problem is!

_________________
Image

BetaArchive Discord: https://discord.gg/epK3r6A


Top  Profile  WWW
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:30 pm 
Reply with quote
Andy wrote:
The $ sign you used for md5($pass); is not a $ sign at all. I just looked. That's where the problem is!

Damn, you were right!

Thats embarrasing for me now ^^


Top
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:31 pm 
Reply with quote
Administrator
User avatar
Offline

Joined
Fri Aug 18, 2006 11:47 am

Posts
12473

Location
Merseyside, United Kingdom

Favourite OS
Microsoft Windows 7 Ultimate x64
The joys of debugging. And using a German keyboard probably makes it easier to accidentally put that symbol in place of the proper one.

_________________
Image

BetaArchive Discord: https://discord.gg/epK3r6A


Top  Profile  WWW
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:32 pm 
Reply with quote
FTP Access
User avatar
Offline

Joined
Sun Oct 05, 2008 3:11 pm

Posts
105
yeah this should solve the problem. :D the $ instead of the §. You hit the "2" key instead of "3" :idea: :)

_________________
GreetZz, Sibbl

Image


Top  Profile
 PostPost subject: Re: PHP MD5 Problem...        Posted: Fri Jun 26, 2009 6:32 pm 
Reply with quote
Andy wrote:
The joys of debugging. And using a German keyboard probably makes it easier to accidentally put that symbol in place of the proper one.

Yeah^^

Well, you must agree, with bad eyes like mine § and $ look nearly the same :P


Top
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 




Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  

All views expressed in these forums are those of the author and do not necessarily represent the views of the BetaArchive site owner.

Powered by phpBB® Forum Software © phpBB Group

Copyright © 2006-2018

 

Sitemap | XML | RSS