dodaj.php:
Kod
<?
require('includes/sessions.php');
require('config.php');
$nazwa_uz = $_SESSION['prawid_uzyt'];
if($_POST)
{
if((trim($_POST['autor'])) && (trim($_POST['tekst'])))
{
if(mysql_query("INSERT INTO newsy VALUES('', NOW(),
'".trim(htmlspecialchars($_POST['autor']))."',
'".trim(htmlspecialchars($_POST['temat']))."',
'".trim(htmlspecialchars($_POST['tekst']))."')"))
echo 'Dodałem news o ID:'.mysql_insert_id();
else echo 'Nie mogłem dodać newsa';
}
else echo 'Nie podałeś autora lub treści newsa';
}
?>
<hr>
<form name="news" method="post" action="dodaj.php">
Treść newsa:
<textarea name="tekst" rows="5" cols="40"></textarea>
Autor:
<input type="text" name="autor">
Temat:
<input type="text" name="temat"><br
<input type="reset" value="wyczyść"> <input type="submit" value="wyslij">
</form>
W tym kodzie samemu się wpisuje autora. Chciałbym aby jak sie doda newsa to autor automatycznie się dodał. Chodzi o nazwe użytkownika zalogowanego na sesji.