Cytat(ARJ @ 2004-10-19 13:19:45)
skrypt dałeś niepełny ale chyba wiem o co chodzi. w środkowym kawałku kodu zaprezentowałeś link, link ten powinien być wstawiony w funkcje while z pierwszego kawałka. bo jeśli niejest to może dlatego jest taki błąd.
mam nadzieję że o to chodzi.
EH, sorry za zamieszanie. Dzieki postowi Fibolg'a sprawdzilem w bazie czy czasem id tego ostatniego newsa i pierwszego nie sa takie same i okazalo sie ze byly:P (ale juz takiej sytuacji nie bedzie, gdyz pole to ustawilem na UNIQUE).
Dzieki za wszystko.
------------------------------
Przy okzji zamiast robic nowy temat napisze tu to. Juz kiedys na forum webhelp.pl o tym pisalem ale rozwiazania prolemu nie otrzymalem. Otoz problem jest z skryptem logowania. Wpisuje dane, ktore zgadzaja sie z tymi ktore sa w bazie i mimo to skrypt generuje komunikat, ze "logowanie nie powiedlo sie ..."
pozniej kod skryptu:
<?
include(\"common.php\");
log_form();
}
else {
$usernick = auth_u($user_nick, $user_password);
if(!$usernick) {
echo \"Logowanie nieudane.\" . \"Musisz podać poprawny nick oraz hasło. \" .
\"Spróboj jeszcze raz się zalogować. <br>n\";
echo \"<a href=\"$PHP_SELF\">Logowanie</a><br>\"; }
else
$id_polaczenia = db_connect();
function in_use($user_nick) {
$query = \"SELECT user_nick FROM $user_tablename WHERE user_nick = '$user_nick'\";
else return 1;
}
function reg_form() {
html_header();
?>
</TR>
<TR>
<TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>Dodaj nowego użytkownika</b></center></TD>
</TR>
</table>
<TABLE cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1000\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">
<TR>
<TD valign=\"top\" align=\"center\" bgcolor=\"#414141\" colspan=\"3\">
<br>
<form method=\"post\" enctype=\"multipart/form-data\" action=\"
<?php echo $PHP_SELF ?>\">
<input type=\"hidden\" name=\"action\" value=\"register\">
<table border=\"0\" cellpadding=\"1\" cellspacing=\"0\" width=\"95%\" height=\"70%\" align=\"center\" valign=\"top\">
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Nick:</th>
<td width=\"70%\"> <input type=\"text\" size=\"20\" maxlength=\"20\" name=\"nick\" class=\"pollItem\"></td>
</tr>
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Wybrane hasło:</th>
<td width=\"70%\"> <input type=\"password\" name=\"userpassword\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td>
</tr>
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Powtórz hasło:</th>
<td width=\"70%\"> <input type=\"password\" name=\"userpassword2\" size=\"20\" maxlenght=\"20\" class=\"pollItem\"></td>
</tr>
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Email:</th>
<td width=\"70%\"> <input type=\"text\" name=\"usermail\" size=\"20\" maxlenght=\"40\" class=\"pollItem\"></td>
</tr>
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">O sobie:</th>
<td width=\"70%\"> <textarea rows=\"5\" cols=\"40\" name=\"userprofile\" class=\"pollItem\"></textarea></td>
</tr>
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Sprzęt:</th>
<td width=\"70%\"> <input type=\"text\" name=\"userhardware\" size=\"20\" maxlenght=\"40\" class=\"pollItem\"></td>
</tr>
<tr>
<th width=\"30%\" NOWRAP><font style=\"font-family: Verdana; font-size: 10px; color: gray;\">Admin:</th>
<td width=\"70%\"> <select name=\"admin\" size=1 class=\"pollItem\">
<option selected value=\"NIE\">NIE</option>
<option value=\"TAK\">TAK</option>
</select>
</td>
</tr>
<tr>
<th width=\"30%\" colspan=\"2\" NOWRAP>
<input type=\"submit\" class=\"pollButton\" value=\"Rejestruj\" onmouseover=\"this.className='pollButton-over'\" onmouseout=\"this.className='pollButton'\">
<input type=\"reset\" class=\"pollButton\" value=\"Wyczysc\" onmouseover=\"this.className='pollButton-over'\" onmouseout=\"this.className='pollButton'\"></th>
</tr>
</table>
</table>
</form>
<?php
html_footer();
}
function register_user() {
global $nick, $userpassword, $userpassword2, $usermail, $userprofile, $userhardware, $admin; global $default_db, $user_tablename; $awatar = \"obrazki/users/none.jpg\";
mailcheck($usermail);
if(empty($userprofile)) error_message
(\"Brak komentarza!\"); if(empty($usermail)) error_message
(\"Brak adresu email!\"); if(empty($nick)) error_message
(\"Brak nicku!\"); if(empty($userpassword)) error_message
(\"Brak hasla!\"); if(empty($userpassword2)) error_message
(\"Musisz powtórzyć hasło!\"); if($userpassword!=$userpassword2)
error_message(\"Podane hasła nie są identyczne\");
if(in_use($nick))
error_message(\"Wybrany nick jest już zajęty, proszę wybrać inny\");
$query = \"INSERT INTO users VALUES(NULL, '$nick', password('$userpassword'), '$usermail', '$userprofile', curdate(), NULL, '$userhardware', '$awatar', '$admin')\";
if(!$wynik) error_message(sql_error());
html_header();
?>
<TR>
<TD WIDTH=\"100%\" HEIGHT=\"16\" background=\"layout/belka2.gif\" style=\"border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black;\"><center><font style=\"font-family: Times New Roman; font-size: 8pt;\"><b>Dodaj nowego użytkownika</b></center></TD>
</TR>
</table>
<TABLE cellpadding=\"1\" cellspacing=\"0\" WIDTH=\"100%\" HEIGHT=\"1000\" BGCOLOR=\"#000000\" style=\"border-left: solid; border-left-width: 1px; border-left-color: black; border-bottom: solid; border-bottom-width: 1px; border-bottom-color: black; border-right: solid; border-right-width: 1px; border-right-color: black;\">
<TR>
<TD valign=\"top\" align=\"center\" bgcolor=\"#414141\" colspan=\"3\">
<br>
<font style=\"font-family: Verdana; font-size: 9pt; color: gray;\"><b>Użytkownik
<?php echo $nick ?> został zarejestrowany</b><br>
</tr>
</table>
<?php
html_footer();
}
switch($action) {
case \"register\":
register_user();
break;
default:
reg_form();
break;
}
}
function auth_u($user_nick, $user_password) {
$id_polaczenia = db_connect();
$query = \"SELECT user_nick FROM users WHERE user_nick = '$user_nick' AND user_pass = '$user_password' AND admin = 'TAK'\";
else {
return $query_data[1];
}
}
?>
Wersja druga sesji (i gdy uruchamiam skrypt w wersji ponizej, juz nie pisze ze logowanie nie powiodlo sie, tylko zawsze ponownie wyswietla mi formularz logowania):
<?
include(\"common.php\");
if(!$_SESSION['user_nick']) {
log_form();
}
else {
$_SESSION['user_nick\", \"user_password'];
$usernick = auth_u($user_nick, $user_password);
if(!$usernick) {
unset($_SESSION['user_nick']); unset($_SESSION['user_password']); echo \"Logowanie nieudane.\" . \"Musisz podać poprawny nick oraz hasło. \" .
\"Spróboj jeszcze raz się zalogować. <br>n\";
echo \"<a href=\"$PHP_SELF\">Logowanie</a><br>\"; }
else
....
?>
Ten post edytował Majcok12 19.10.2004, 16:14:38