Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Login PHP scripta - Problem

[es] :: PHP :: Login PHP scripta - Problem

[ Pregleda: 2847 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Lavina
Perovic Vladimir
bg

Član broj: 532
Poruke: 86
*.dynamic.sbb.co.yu.

Jabber: vlad@elitesecurity.org
ICQ: 42882076
Sajt: www.vladimirperovic.com


Profil

icon Login PHP scripta - Problem29.01.2007. u 11:46 - pre 209 meseci
imam problem oko PHP Login scripte. Citajuci forum pronasao sam link ka obasnjenju http://www.devarticles.com/c/a...or-Beginners-by-a-Beginners/2/ i sve radi kada username i pass nijesu tacni ali kada ukucam tacnu prodje kroz petlju i izbaci

Success!
Warning: Cannot modify header information - headers already sent by (output started at /VDOMAINS/lavina/www/login/login.php:47) in /VDOMAINS/lavina/www/login/login.php on line 50

gdje je greska.. kod samo postovao

znam da su iskusnijim programerima ovi problemi itekako dosadili,
Unaprijed hvala na pomoci

Code:

<?PHP
//check that the user is calling the page from the login form and not accessing it directly
//and redirect back to the login form if necessary
if (!isset($username) || !isset($password)) {
header( "Location: http://www.vladimirperovic.com/login/login.html" );
}
//check that the form fields are not empty, and redirect back to the login page if they are
elseif (empty($username) || empty($password)) {
header( "Location: http://www.vladimirperovic.com/login/login.html" );
}
else{

//convert the field values to simple variables

//add slashes to the username and md5() the password
$user = addslashes($_POST['username']);
$pass = md5($_POST['password']);


//set the database connection variables

$dbHost = "";
$dbUser = "";
$dbPass = "";
$dbDatabase = "";

//connet to the database

$db = mysql_connect("$dbHost", "$dbUser", "$dbPass") or die ("Error connecting to database.");

mysql_select_db("$dbDatabase", $db) or die ("Couldn't select the database.");

$result=mysql_query("select * from users where username='$user' AND password='$pass'", $db);

//check that at least one row was returned

$rowCheck = mysql_num_rows($result);
if($rowCheck > 0){
while($row = mysql_fetch_array($result)){

  //start the session and register a variable

  session_start();
  session_register('username');

  //successful login code will go here...
  echo 'Success!';

  //we will redirect the user to another page where we will make sure they're logged in
  header( "Location: checkLogin.php" );

  }

  }
  else {

  //if nothing is returned by the query, unsuccessful login code goes here...

  echo 'Incorrect login name or password. Please try again.';
  }
  }
  ?>


edit: Nemanja: Kod u code tagove!

[Ovu poruku je menjao Nemanja Avramović dana 29.01.2007. u 17:26 GMT+1]
 
Odgovor na temu

Miroslav Ćurčić
ex mVeliki
Novi Sad

Član broj: 19034
Poruke: 1118
*.dynamic.sbb.co.yu.



+19 Profil

icon Re: Login PHP scripta - Problem29.01.2007. u 11:59 - pre 209 meseci
echo 'Success!';
header( "Location: checkLogin.php" );


Ne može zajedno i echo i header. Izbaci recimo echo.
"The quieter you become, the more you are able to hear."
Blog | PowerCMS
 
Odgovor na temu

Lavina
Perovic Vladimir
bg

Član broj: 532
Poruke: 86
*.dynamic.sbb.co.yu.

Jabber: vlad@elitesecurity.org
ICQ: 42882076
Sajt: www.vladimirperovic.com


Profil

icon Re: Login PHP scripta - Problem29.01.2007. u 12:01 - pre 209 meseci
hvala puno na brzom i tacnom odgovoru! :)

prekopirao sam sa doticnog sajta kod a nijesam bas neki znalac da primijetim spomenutu gresku
 
Odgovor na temu

Zmaj
Predrag Krstić
web developer
Zrenjanin

Član broj: 1035
Poruke: 382

Sajt: https://pkrstic.wordpress..


+4 Profil

icon Re: Login PHP scripta - Problem29.01.2007. u 14:29 - pre 209 meseci
na pocetku

if (!isset($username) || !isset($password))

ovo mi lici na register globals, moguce je da kasnijeimas problema sa ovim, pa preciziraj lokaciju gde su ti te promenljive, session, cookies ili sta vec
 
Odgovor na temu

[es] :: PHP :: Login PHP scripta - Problem

[ Pregleda: 2847 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.