God knows what is the problem

3

God knows what is the problem

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

Balkanac82 ::You should have ; after md5()

it's not that.

i have other queries that doesnt have ; at the and and still works fine



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • PHP developer
  • Pridružio: 22 Mar 2006
  • Poruke: 3747
  • Gde živiš: 127.0.0.1

RutiX ::and for the gay who said that Password function doesnt exist, he should see the "PHP and MySQL 3dbuzz" video or this book "Wrox - Beginning PHP, Apache, MySQL Web Development - 2004 - (By Laxxuss).pdf" to see that there is a function password() and also md5 function.

I sincerely hope you meant "guy", if no, you'll see help from me no more.

Look, I do not claim that I know everything about php and mysql. There is no manual for function password() on the official php.net site, so I presume that there is no such function. Predefined by default.

You should read them (not just them), but you should try "PHP for dummies".

$query="SELECT username,password FROM 'table' WHERE username='".$_POST['username']."' and password = md5('".$_POST['password']."') ";

so this is not working, and you want user authentication script? why didnt you used search on this forum?

you have 100% working script on http://www.mycity.rs/PHP/php-sesije_3.html (written by me, who else?)

<?php session_start(); $connect = mysql_connect($dbhost, $dbuser, $dbpass) or die(mysql_error());    mysql_select_db($dbname, $connect) or die(mysql_error());    if (isset($_POST['logmein'])) {       $usr_pass = md5($_POST['password']);       $usr_user = $_POST['username'];           $respass2 = mysql_query("SELECT password FROM ime_tabele WHERE username='$usr_user'");       $row = mysql_fetch_array($respass2);          if ($usr_pass == $row{'password'}) {          $_SESSION['username'] = $usr_user;          $_SESSION['password'] = $usr_pass;          echo "<script>location.href='index.php';</script>";          die();          }          else {             echo "<script>location.href='login.php';</script>";             die();             }    } $username=$_SESSION['username']; $password=$_SESSION['password']; if ($username != "" and $password != "") {        $respass = mysql_query("SELECT password FROM ime_tabele WHERE username='$username'");    $row = mysql_fetch_array($respass);        if ($password != $row{'password'}) {           $_SESSION['username'] = "";    $_SESSION['password'] = "";    echo "<script>location.href='login.php';</script>";    die();    }    } else {          echo "<form action='login.php' method='post'><input type='text' name='username' value='username' onfocus=\"document.forms[0].elements[0].value=''\"><br><br><input type='password' name='password' value='password' onfocus=\"document.forms[0].elements[1].value=''\"><br><br><input type='submit' name='logmein' value=\"Pristupi\" ></form>";       die();    } ?>



offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

Rastafarii ::RutiX ::and for the gay who said

I sincerely hope you meant "guy", if no, you'll see help from me no more.


loooooool man.Now i saw that.I m not too weird to mean that. It's mistake.
Really sorry.

I will check the hole code and if i find something strange i will post it.

Dopuna: 09 Maj 2007 20:47

i found the error.
the problem was in the creating table
here is the query that i use for creating the table
create table user (id int unsigned auto_increment primary key, username varchar(20), password varchar(20));

and the right query that i use now and it's working
CREATE TABLE user ( id int(10) NOT NULL auto_increment, username varchar(20) NOT NULL, password varchar(20) NOT NULL, PRIMARY KEY (id) );

So now both password() and md5() functions works fine.

Ko je trenutno na forumu
 

Ukupno su 898 korisnika na forumu :: 44 registrovanih, 4 sakrivenih i 850 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: A.R.Chafee.Jr., Acivi, aleksandarbl, bato, bestguarder, bigfoot, BlekMen, Boris90, BraneS, ccoogg123, darios, Dimitrije Paunovic, Djokislav, gmlale, havoc995, hyla, ILGromovnik, Istman, Ivica1102, ivica976, Kriglord, Kubovac, kunktator, Lubica, mgolub, Misirac, Ne doznajem se u oružje, nemkea71, NoOneEver Dreams, ObelixSRB, oganj123, Panter, shone34, slonic_tonic, srbijaiznadsvega, Srky Boy, stegonosa, t.mile, theNedjeljko, trajkoni018, virked, Vlajman1957, wolf431, šumar bk2