Jump to content
php.lv forumi

login skripts


Visurgaajeejs

Recommended Posts

shis man ir index.php lapaa

<?php

session_start();

require_once('db.php');

 

if($_SESSION['login'] != '1')

{

echo '

<table border="0" bgcolor="#99FF99" align="center">

<tr>

<td align="center">

<form method="POST" action="login.php">

<input type="text" name="username" size="20"><br>

<input type="password" name="password" size="20"><br>

<input type="submit" value="login" name="login">

</form>

</td>

</tr>

</table>';

}

 

else {

require_once('header.php');

}

?>

###########################################

shis ir login.php

<?php

session_start();

require_once('db.php');

 

if(isset($_POST['login']))

{

$username = $_POST['username'];

$password = md5($_POST['password']);

 

 

$query = mysql_query("SELECT * FROM user WHERE username = '$username' AND password='$password'");

 

if (mysql_num_rows($query) == 0) {

 

$_SESSION['login'] = '0';

header('Location: index.php');

}

 

else {

$_SESSION['login'] = '1';

header('Location: index.php');

 

}

}

?>

#####################################

un plus veel ir db.php kur ir

mysql_connect

mysql_select_db

kur izveelas aatieciigo datubaazi.

 

Kad es ierakstu attieciigo username un paroli man izmet shaadu pazinjojumu:

Warning: Cannot modify header information - headers already sent by (output started at c:\easyphp1-8\www\db.php:7) in c:\easyphp1-8\www\login.php on line 21

Link to comment
Share on other sites

×
×
  • Create New...