Jump to content
php.lv forumi

Admin sistema


SkyD

Recommended Posts

<?
$hostname="localhost";
$mysql_login="root";
$mysql_password="";

if ($db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password"))
{
echo "<br>";
}
else {
echo "<br>";
}

if (!(mysql_select_db("admin",$db)))
{
echo "nav kaartiibaa ar DB<br>";
}
else {
$q = "SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')"
var $chek = 0;
if ($chek == 0) {
echo "nepareizi";
}
else {
header("Location: main.php");
}
}
?>

 

saka:

Parse error: parse error, unexpected T_VAR in D:\lapa\adm\php21D.tmp on line 28

 

28liinija: var $chek = 0;

Link to comment
Share on other sites

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

aa nu tag ir... bet:

...
$q = "SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')";
$chek=0;
if ($chek == 0) {
echo "nepareizi";
}
else {
header("Location: main.php");
}
....

 

Ierakstiju loginu un paroli pasaka "nepareizi" ... a kaa var paarliecināties ka logins un parole ir datu baazee?

Link to comment
Share on other sites

$q = mysql_query("SELECT COUNT(*)...");
list($skaits) = mysql_fetch_ro($q);
if ($skaits==0) {
 echo 'tu esi ļaunais haxorz';
} else {
 echo 'welcome to mai page!';
}

Edited by bubu
Link to comment
Share on other sites

pilniiigs vaaX... ir šita:

<?
$hostname="localhost";
$mysql_login="root";
$mysql_password="";

if ($db = mysql_connect("$hostname", "$mysql_login" , "$mysql_password"))
{
echo "<br>";
}
else {
echo "<br>";
}

if (!(mysql_select_db("admin",$db)))
{
echo "nav kaartiibaa ar DB<br>";
}
else {
$q = mysql_query("SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')");
list($skaits) = mysql_fetch_row($q);
if ($skaits==0) {
echo 'tu esi launais haxorz ';
} else {
echo 'welcome to mai page!';
}
}
?>

neko neievadot abos laukos un nospiežot PIEVIENOTIES, man izmet nevis "welcome..." nevis "tu esi launais.." ... Lūdzu izlabojiet šito štelli un būs ok..

Link to comment
Share on other sites

ja logins vai parole tuks, nemaz ij nevajag paarbaudit kaut ko ieks db, bet uzreiz teikt ka kaut kas nav labi. ja nu jaaraksta prieksaa tad

 

if(trim($logins) == '' || trim($parole) == '')
{
die('kaut kas nav labi'); // vai pareizak met atpakal uz login formu un radi paskaidrojumu
} else {
.. konektejies pie db
.. parbaudi
.. utt
}

Link to comment
Share on other sites

Nu nekad, nekad nedariet šitā:

        $check = mysql_query('SELECT username FROM users WHERE username=\'' . $user . '\'');
        if(mysql_num_rows($check) == 0) {

Vai tad tik grūti to countu izselektēt?

        $check = mysql_query("SELECT COUNT(username) FROM users WHERE username='$user'");
        list($count) = mysql_fetch_row($check);
        if($count == 0) {

Edited by bubu
Link to comment
Share on other sites

Jā, tas ir lēnāk. Padomā pats - vai mysql vajag skaitu (vienu skaitli) tikai dabūt un iedot php, vai arī vajag visus username datus izlasīt no db un pārsūtīt php.

Edited by bubu
Link to comment
Share on other sites


×
×
  • Create New...