Jump to content
php.lv forumi

login


beryoza

Recommended Posts

Sveiki.

 

Lieta tāda pabeidzu šodien Login,logout,register. utt...

 

Tad sāku taisīt sākuma lapu un taisot to lapu nonācu pie secinājuma ka kkas nav pareizi.

 

jo kad tu ieraksti Username un Login tevi aizmet uz konkrētu lapu pienemsim 127.0.0.1/sakums.php

bet ja es nēsmu reģistrējies tad ierakstot manaip/sakums.php ari tevi laiž tajā lapa vaj manaip/galerijas.php utt...

 

Jautājums - ka lai uztaisa lai cilvēks ienākot manā weblapa bez login nevarētu iet piem uz 127.0.0.1/sākums.php

 

kā draugiem.lv ja tu ieraksti draugiem.lv/galery tev tikuntā atverās logs kur ierakstīt username un pasword un tikai kad tu to esi izdarījis tev lauj iet tālāk.

 

Ceru ka sapratāt ko es domāju.

Link to comment
Share on other sites

varbūt tav parādi savu funkcionējošo login skriptu?

 

<?php
session_start();
// Check if he wants to login:
if (!empty($_POST[username]))
{
require_once("connect.php");

// Check if he has the right info.
$query = mysql_query("SELECT * FROM members
						WHERE username = '$_POST[username]'
						AND password = '$_POST[password]'")
or die ("Error - Couldn't login user.");

$row = mysql_fetch_array($query)
or die ("Error - Couldn't login user.");

if (!empty($row[username])) // he got it.
{
	$_SESSION[username] = $row[username];
	echo "Welcome $_POST[username]Dodieties uz sakumu <a href='sakums.php'><b>Sakums</b></a>.";
	exit();
}
else // bad info.
{
	echo "Error - Couldn't login user.<br /><br />
		Please try again.";
	exit();
}
}

?>

<html>
<head>
	<title>Login</title>
</head>
<body>
	<form action="login.php" method="post">
		 <br>
		 <br>
		 <br>
		 <br>
		 <center><tr>
		  <br>
		  <br>
				Usename<br/><input type="text" class="inp" name="username" size="30" value="" /><br />
			</tr>
			<tr>password<br/><input type="password" onKeyPress="return capsLock(event)" class="inp" name="password" size="30" autocomplete="off" /><br />
       <td width="100%"><input type="submit" value="Ienakt!"></td>
			</tr><center>
			</table>
	</form>
</body>

<a id="nav_main" href="register.php">Registracija</a


 

šādi

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...