http://www.volny.cz/peter.mlich/www.htm#msub13
# peter-mlich.wz.cz PHP+MySQL minichat (5k 1 soubor) (POST,SESSION)
# www.volny.cz/peter.mlich (zdroj: minichat.txt)
# www.volny.cz/peter.mlich (zdroj: minichat.sql)
a muzes si to upravit na vzkazy misto chatu
jenom tam schazi registrace a kontrola existence uzivatele, ktera muze vypadat nejak takto:
<?php
//--- login ---
@session_start(); //spust session; pokud je, nezobraz chybu
$a = "login"; $x = isset($_GET[$a]) ? $_GET[$a] : ( isset($_POST[$a]) ? $_POST[$a] : (isset($_SESSION[$a]) ? $_SESSION[$a] : "") );
$Ulogin = $x;
$a = "password";$x = isset($_GET[$a]) ? $_GET[$a] : ( isset($_POST[$a]) ? $_POST[$a] : (isset($_SESSION[$a]) ? $_SESSION[$a] : "") );
$Upassword = $x;
$logged = 0;
if ($Ulogin!=="" && $Upassword!=="")
{
$dotaz = "SELECT * FROM users WHERE `login`='$Ulogin' AND `password`='$Upassword' LIMIT 1";
$vysl = mysql_query($dotaz);// or die("<hr>Err: $dotaz<hr>".mysql_error());
$pocet = ($vysl>0) ? mysql_num_rows($vysl) : 0;
if ($pocet>0)
{
$logged= 1;
$row = mysql_fetch_array($vysl);
$uid = $row['id'];
$admin = $row['admin'];
$a = "login"; $_SESSION[$a] = $row[$a];
$a = "password"; $_SESSION[$a] = $row[$a];
}
}
if ($logged!==1)
{
$Ulogin = "";
$Upassword = "";
$admin = 0;
}
//zakomentovat
//$logged = 1;
//$admin = 1;
//$uid = 1;
$Sname = session_name();
$Sid = session_id();
$Slink = $Sname."=".$Sid;
//print_r($_SESSION);
function loginForm($Xdir,$Xpage1,$Xpage2)
{
$t='
<form name="flogin" action="'.$Xdir.'login-ad.z.php" method="post" enctype="multipart/form-data">
<fieldset>
<legend>Přihlášení</legend>
<input type="hidden" name="page1" value="'.$Xpage1.'"/>
<input type="hidden" name="page2" value="'.$Xpage2.'"/>
<table>
<tbody>
<tr> <td><label for="log_name">Jméno</label></td>
<td align="right"><input type="text" name="log_name" id="log_name" class="text" tabindex="0"/></td></tr>
<tr> <td><label for="log_pass">Heslo</label></td>
<td align="right"><input type="password" name="log_pass" id="log_pass" class="text"/></td></tr>
<tr> <td> </td>
<td><input type="submit" class="butt" value="Ok"/></td></tr>
</tbody>
</table>
</div></div></div>
</fieldset>
</form>
';
return $t;
}
?>
mam i vzkazovnik, ale ten je napojeny na registraci. V podstate neni odlisny od toho chatu, jenom je mozne vzkazy mazat a oznacovat jako neprectene.
jinak viz
interval.cz - PHP - clanky
jakpsatweb.cz - Ostatni - PHP - clanky
root.cz
abclinux.cz
...