Index.php do ktorego includowany jest add.php:
<?
ob_start();//Tworzenie sesji i sprawdzanie czy user zalogowal sie
if(isset($HTTP_POST_VARS['user']) && isset($HTTP_POST_VARS['pass'])) {
// Skrypt sprawdzajacy prawdziwosc danych podczas logowania
$user = $HTTP_POST_VARS['user'];
$pass = $HTTP_POST_VARS['pass'];
$zapytanie = 'select * from admins '
."where user='$user' "
." and pass='$pass'";
{
// Jezeli dane sa prawdziwe nastepuje zarejestrowanie identyfikatora usera
$HTTP_SESSION_VARS['prawid_uzyt'] = $user;
}
}
?>
<html>
<head>
<title>Portal Newsowy - v 1.0.</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<META name="keywords" content="Skrypt, BalonNews, Balon, News">
<META name="description" content="Skrypt, BalonNews, Balon, News">
<META name="author" content="Krzysztof Jagiello">
</head>
<body>
<table border="0" height="25" width="600" align="center" cellpadding="0" cellspacing="0">
<tr><td width="100%" height="100%"></td></tr>
<table border="0" height="50" width="600" align="center" cellpadding="0" cellspacing="0">
<tr><td width="100%" height="100%"></td></tr>
</table>
<?
// sprawdzanie istnienia sesji
if(isset($HTTP_SESSION_VARS['prawid_uzyt'])) {
// includowanie podstron
if($co=="main") { include "inc/main.php"; }
elseif($co=="add") { include "inc/add.php"; }
elseif($co=="edit") { include "inc/edit.php"; }
else { include "inc/main.php"; }
//dalsza czesc uwierzytelniania
}
else
{
{
// jezeli proba logowania nie powiodla sie
echo '<table bgcolor=3e3e3e border=0 width=600 align=center cellpadding=0 cellspacin
g=0>'; echo '<tr><td bgcolor=505050 width=100% height=25 class=news valign="middle"><b>Panel Admina - NewsCenter</b></td></tr>'; echo '<tr><td bgcolor=3e3e3e width=100% class=news>'; echo '<center><br><b>Zalogowanie niemozliwe.</b></center><br />'; }
else
{
// Albo nastapilo wylogowanie albo nie bylo wogole proby logowania sie
echo '<table bgcolor=3e3e3e border=0 width=600 align=center cellpadding=0 cellspacin
g=0>'; echo '<tr><td bgcolor=505050 width=100% height=25 class=news valign="middle"><b>Panel Admina - NewsCenter</b></td></tr>'; echo '<tr><td bgcolor=3e3e3e width=100% class=news>'; echo '<center><br><b>User niezalogowany.</b></center><br />'; }
// tworzenie formularza logowania
echo '<table bgcolor=3e3e3e border=0 width=600 align=center cellpadding=0 cellspacin
g=0>'; echo '<tr><td bgcolor=505050 width=100% height=25 class=news valign="middle"><b>Panel Admina - NewsCenter</b></td></tr>'; echo '<tr><td bgcolor=3e3e3e width=100% class=news>'; echo '<form method="post" action="index.php">'; echo '<table border="0" class="news" align="center">'; echo '<tr><td>Login</td><td><input type="text" name="user" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td></tr>'; echo '<tr><td>Haslo</td><td><input type="text" name="pass" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td></tr>'; echo '<tr><td></td><td><input type="submit" value="Loguj" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td></tr>'; echo '<table border="0" width="600" align="center" cellpadding="0" cellspacing="0"> <tr>
<td class="news">
</td>
</tr>
</table>
</table>
</td></tr>
</table><br>';
}
?>
</body>
add.php
<tr><td bgcolor=3e3e3e width=100% class=news>
<?
$adm = $HTTP_SESSION_VARS['prawid_uzyt'];
if (isset($HTTP_POST_VARS['title']) && isset($HTTP_POST_VARS['autor']) && isset($HTTP_POST_VARS['tresc'])) { $title=$HTTP_POST_VARS['title'];
$autor=$HTTP_POST_VARS['autor'];
$tresc=$HTTP_POST_VARS['tresc'];
if (!$title || !$autor || !$tresc)
{
echo 'Wypelnij wszystkie pola!';
}
$zapytanie = "INSERT INTO `newsy` ( `id` , `title` , `autor` , `tresc` )
VALUES ('', '$title', '$autor', '$tresc');";
if ($wynik) {
echo "News zostal dodany"; }
}
?>
<? if(isset($HTTP_SESSION_VARS['prawid_uzyt'])) {?>
<form action="index.php?co=add" method="post">
<table border="0" align="center" class="news">
<tr>
<td>Tytul:</td>
<td><input type="text" name="title" size="15" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td>
</tr>
<tr>
<td>Tresc:</td><td><TEXTAREA name="tresc" rows="8" cols="70" wrap="virtual" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></TEXTAREA><BR></td></tr>
<tr>
<td><input type="reset" value="Resetuj" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"></td>
<td><input type="submit" value="Dodaj" style="font-family:verdana, tahoma, sans-serif; font-size:11px; color:#000066; border: 1px solid #000066"><input name="autor" value="<? $HTTP_SESSION_VARS['prawid_uzyt'] ?>" type="hidden"></td>
</tr>
</table>
</form>
<? } ?>
</td></tr>
</table><br>
I chce zeby do value
Kod
<input name="autor" value="<? $HTTP_SESSION_VARS['prawid_uzyt'] ?>" type="hidden">
zostal wrzucony identyfikator sesji ktorym jest nazwa usera... tylko ze nie dzieje sie tak jak bym chcial i value jest puste... prosze o pomoc...