<?php
$db_user = 'tipleague';
$db_pass = '********';
$user_name = $_POST['user_name'];
$password = $_POST['password'];
//connect to the DB and select the "tipleague" database
$connection = mysql_connect('localhost', $db_user, $db_pass) or die(mysql_error());
mysql_select_db('tipleague', $connection) or die(mysql_error());
//set up the query
$query = "SELECT * FROM users
WHERE user_name='$user_name' AND password='$password'";
//run the query and get the number of affected rows
$result = mysql_query($query, $connection) or die('error making query');
$affected_rows = mysql_num_rows($result);
//if there's exactly one result, the user is validated. Otherwise, he's invalid
if($affected_rows == 1) {
$_SESSION['user_name'] = $user_name;
print 'validated';
}
else {
print 'not valid';
}
?>
E sad da li kada pravim registraciju radim isti proces selektiram iz baze podataka gdje je username - post username i password = post password da bih provjerio da li to korisnicko ime vec postoji, ili ima neki bolji nacin da se ovo odradi...
[Ovu poruku je menjao 01011011 dana 16.07.2005. u 09:58 GMT+1]