Jump to content
php.lv forumi

LOGIN problema/jautajums


CGCX

Recommended Posts

Beidzot man izdevas izveidot login lapu, bet es velos uzzinat kodu kas veiktu sadu darbibu

ejot uz lapas linku piem http://majaslapa.oo.lv paradisies lapa login bet ja jau esi ielogojies tad vina neradas (radas tikai tad kad Nēsi ielogojies) un nebutu iespejams tikt citas lapas ieksa
~ ka draugie**.*v

Ludzu palidziet busu pateicigs

Edited by CGCX
Link to comment
Share on other sites

//index.php lapa, so lapu nevar redzet bez ielogosanas
<?
include("login_check.php");
?>
un te bus index.php lapas saturs, viss ko velies.

 

//login_check.php, parbaudam vai lietotajs ir ielogojies, ja ir ielogojies, lai turpina, ja nav ielogojies, metam uz login
<? 
session_start();
if(!isset($_SESSION['lietotajvards']) || (trim($_SESSION['lietotajvards']))== '') {
header( 'Location: login.php' );
	exit();
} 
?>

 

//login.php
include("login_check2.php");
login lapas saturs te, vajadzetu ari ielikt lietu, kad ielogojas, tad $_SESSION['lietotajvards'] = $_POST['lietotajvards'];

 

//login_check2.php, parbaudam vai lietotajs ir ielogojies, ja ir ielogojies, metam uz index
sis fails satur to pasu, kas ir login_check.php, tiaki visu japarveido preteji, to lausu izdarit tev

 

 

Ceru ka palīdzēju

-Shizo0

Edited by m8t
Link to comment
Share on other sites

Es nesapratu tos pedejos 2 ar pirmajiem 2 vis kartiba ka iet uz linku iemet lapa bet es nesapratu

//login.php

include("login_check2.php");

login lapas saturs te, vajadzetu ari ielikt lietu, kad ielogojas, tad $_SESSION['lietotajvards'] = $_POST['lietotajvards'];

piem tad login.php jabut ta ?

<?
include("login_check2.php");
?>

vai jatstaj vecais kods un kkur jaiestarpina ?

un par to otru

tiaki visu japarveido preteji, to lausu izdarit tev

ludzu vari izveidot ka tas ir ,jo es noteikti kko ne ta daru

Link to comment
Share on other sites

Iedošu tev savu login scriptu, sapratu ka tev tāds nav

 

//login.php
include("config.php");
$ad = $_GET['id'];
<? if ($ad == 1) {
if(!session_id())
session_start();

if(isset($_POST['login']) && isset($_POST['pass']))
{

$conn=mysql_connect($host, $user, $pwd, $pict) or die(mysql_error());
mysql_select_db($db, $conn);

$_POST['login']=mysql_real_escape_string(strip_tags(trim($_POST['login'])));
$_POST['pass']=mysql_real_escape_string(strip_tags(trim($_POST['pass'])));

$q=mysql_query("SELECT * FROM TAVAMYSQLTABULATE WHERE username='{$_POST['login']}' AND password='{$_POST['pass']}'",$conn) or die(mysql_error());
if(mysql_num_rows($q) > 0)
{

$_SESSION['lietotajvards'] = $_POST['login'];
header('Location: index.php');
	function checkLogin(){
  if($_SESSION['login'] = $_POST['lietotajvards']){
  }else{
  return false;
  }
}
$logged_in = checkLogin();

}
else
{
$teksts='Error';
}

mysql_close($conn);

}

echo $teksts;
} else { ?>
<form method="post" action="login.php?id=1" >
Lietotājvārds:<br />
<input type="text" name="login" /><br />
Parole:<br />
<input type="text" name="pass" /><br />
<input type="submit" value="Ienākt" /><br />
<p align="center"><a href="reg.php">Reģistrēties</a></p>
</form>
<? } ?>

 

//config.php, uzliec host, username, password, database pec saviem mysql uzstadijumiem
$host = "host";
$user = "username";
$pwd = "password";
$db = 'database';
$conn = mysql_connect($host, $user, $pwd, $pict) or die(mysql_error());
mysql_select_db($db, $conn) or die(mysql_error());

 

Ja vajag vēl ko, prasi - centīšos palīdzēt.

 

 

Ps.- Tas include("login_check.php"); , vai include("login_check2.php"); var būt jebkurai lapai virspusē. include("login_check.php"); - norādīs uz to ka bez login nevarēs apskatīt lapu, include("login_check2.php"); - norādīs uz to, ka tikai neielogojies varēs apskatīt lapu, tikai login_check2.php tev būs jāuzstāda maliet savādāk nekā login_check.php.

 

ps2.- Te būs maziņš DEMO, manam skriptam (nav uzlikts ka tie kas ir ielogojusies nevar apskatit login/reg lapu) - http://draugi.comze.com/lpp/ Username: 123, Pass: 123

Edited by m8t
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...