Jump to content
php.lv forumi

Kļūda kkur, palīdziet


kristapuciits

Recommended Posts

1.kārt jau tam postam vajag escape stringu uzmest.

un 2kārt. $_POST["nick"] ar $niks=$_POST["nick"] nav nekāda atšķirība.

 

Ir, tikai atkarīgas kādās pēdiņās lieto iekļaujot stringā :)

 

Kvērijā bija single quote, tas ir, apostrofs. Notestējiet:

<?php
$a = 123;
echo 'Mainigais satur: $a';

?> 

Edited by briedis
Link to comment
Share on other sites

<?
session_start();
mysql_connect("host","user","pass") or die(mysql_error());
mysql_select_db("database");
$key = md5("mykey");
if(isset($_COOKIE[$key])){
$user_id = $_COOKIE[$key];
}
if(!isset($user_id)){
if(is_array($_POST["login"])){
if(count($_POST["login"])==3){
	$user = stripslashes(strip_tags($_POST["login"][0]));
	$pass = stripslashes(strip_tags($_POST["login"][1]));

	$query = mysql_query("select id from users where nick='{$user}' and pass='{$pass}'");
	if(@mysql_num_rows($query)){
		$id = mysql_fetch_array($query);
		setcookie($key,$id["id"],3600);
		Header("Location: ?");
	}else $error = 'login neizdevās';
}else $error = 'aizpildi visus laucinjus';
}
?>
<html>
<body>
<?=($error?"<br><center>{$error}</center><br>":"")?>
<form method="post">
Lietotajvards<br>
<input type="text" name="login[]"><br>
Parole<br>
<input type="password" name="login[]"><br>
<input type="subnit" name="login[]">
</form>
</body>
</html>
<?}else{
$user = mysql_fetch_array(myqsl_query("select * from users where id='{$user_id}'"));
?>
<html>
<body>
Čau <?=$user["nick"]?>!!
</body>
</html>
<?}?>

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