Jump to content
php.lv forumi

Logoshanaas iekshaa


SkyD

Recommended Posts

Index.php ir forma, kur ieraksta loginu un paroli, ja logins un parole ir pareiza iet uz main.php

 

main.php:

<?php

//headers make the page refresh, not just take the old page

header("Cache-Control: must-revalidate, post-check=0, pre-check=0");

header("Cache-Control: private");

//start or continue a session

session_start();

// If there is no uname in post or session, the user needs to log in

//the user is directed to the log in page

//the @ sign suppresses any errors

if(!@$_POST['logins'] && !@$_SESSION['logins'])

header("location: chek.php?notlogin=1");

else{

//if there is a session, then the user is directed to the user area

//more checks could be done here, if more security is required

if(@$_SESSION['logins']){

header("location: lapa.php");

}

//if there is a uname in POST, then but not in session, we check the

//user details

else{

// Get the posted username and password

$logins = $_POST['logins'];
$parole = $_POST['parole'];

$q = mysql_query("SELECT COUNT(*) FROM admini WHERE logins='$logins' AND parole=MD5('$parole')");
list($skaits) = mysql_fetch_row($q);
if ($skaits==0) {


$_SESSION['logins']=$logins;

$_SESSION['logins']=$logins;

header("location: lapa.php");

}

else

{

//otherwise we send the user to the log in page

//using javascript here is just an example of using javascript

//you should normally use the "header" (as above) to redirect the user

//because if the user has javascript turned off

//the code below won't work

?>

<script language="javascript">

<!--

location.href="chek.php?fail=1";

-->

</script>

<?php

}

}

}

?>

<?php

}

}

}

?>

 

chek.php

<script language="php">

if(@$_GET["fail"])

echo "<span class='msg'>Incorrect username or password</span>";

elseif(@$_GET["logout"])

echo "<span class='msg'>Successfully logged out</span>";

elseif (@$_GET['notlogin'])

echo "<span class='msg'>Please log in</span>";

elseif (@$_GET['refuse'])

echo "<span class='msg'>You must log in to access confidential pages</span>";

</script>

 

Un man visu laiku izmet Please log in ... Varbūt kāds var šito izlabot, un tad viss būtu ok=]~~

Link to comment
Share on other sites

es tomēr palasiju :)

 

1) neveiksmīgi esi labojis citu cilvēku taisītu scriptu

 

2) apvienoti ir vairaaku cilveeku taisiiti scripti

 

2) scriptā nedz par index.php , nedz main.php nekas nav runāts

 

4) dažās vietās viena un tā pati darbība tiek veikta divas reizes, pietam ar perfekti vienu un to pašu skriptu, t.i. pardaudz saspaidijies copy/paste

 

īsāk sakot taisi vien no jauna to briinumu un varbuut iepostē kodu ieksh http://paste.php.lv/, kā arī varbūt uzliec kautkur visiem apskatīšanai to php darbībā.

Link to comment
Share on other sites

×
×
  • Create New...