Parašė karolis12114· 2012 Kov. 11 18:03:03
#1
Sveiki, sukuriau
php login,registracija su
mysql ir tt. prireginu 1 usery viskas gerai eina prisijungt prireginu antra neina prisijungt. Tai va jeigu kas nors zinote kas gali buti prasau padeti.
Registracijos scriptas <?php
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("testreg");
$name = $_POST[username];
$pass = $_POST[password];
$pass_conf = $_POST[pass_conf];
$email = $_POST[email];
$ip = $_SERVER[REMOTE_ADDR];
mysql_select_db("testreg");
$sql = "SELECT * FROM user";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if($name == $row['username'])
{
echo " toks username jau naudojamas";
die (' registruokis per nauja. ' . mysql_error());
}
if($name == "" || $pass == "" || $pass_conf == "" || $email == ""){
$error="Prasome uzpildyti wisus laukus";
}
if($pass != $pass_conf){
echo "Nesutampa slaptazodziai!!!";
}
else {
$result = mysql_query("INSERT INTO user SET username ='$name' , password ='$pass', email ='$email',ip='$ip'") or die (mysql_error());
echo " Aciu uz registracija";
}
?>
Login scriptas
<?php
session_start();
$connection = mysql_connect("localhost","root","");
$db = mysql_select_db("testreg");
$name = $_POST[username];
$pass = $_POST[password];
mysql_select_db("testreg");
$sql = "SELECT * FROM user";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
if (isset($_POST['username']))
{
$username = ($_POST['username']);
$password = ($_POST['password']);
if ($username == $row['username'] && $password == $row['password'])
{
$_SESSION['username'] = $username;
echo 'Sekmingai prisijungete<br/>';
echo 'Sveikas, ' . $username;
echo '<a href = "logout.php">Logout</a>';
}
else
{
echo '<span style="color: red">Prisijungti nepavyko </span>';
echo 'username arba password neteisingas!';
}
}