Hi. Im getting this error:
Notice: Undefined index: message in /admin/admin.php on line 5
Notice: Undefined index: author in /admin/admin.php on line 6
Notice: Undefined index: submit in /admin/admin.php on line 7
This is my php code:
<?php
include 'database.php';
$message = $POST['message'];
$author = $POST['author'];
$submit = $_POST['submit'];
if ($submit)
submit($message,$author);
// mysql_query will send a sql query into the database. It will return either the data found, or FALSE if something went wrong with the query
function submit($message,$author)
{ $date = date("d.m.Y");
$resultat = mysql_query("INSERT INTO news (message, date, author) VALUES
('$message'), '$date', '$author', ");
if (!$resultat)
echo "Error: Nyhet ble ikke lagt til";
else
{ include 'admin.htm';
echo "Nyhet lagt til!<br>";
retrieve(); // show all posting, including the last one, stored now
}
$submit = false;
}
function retrieve()
{
// Get all the data from the "news" table
$retrieved = mysql_query("SELECT * FROM news ORDER BY date DESC") or die(mysql_error());
while($row = mysql_fetch_array( $retrieved ))
{
echo $row['message'];
echo "<br>";
echo $row['date'];
echo " - ";
echo $row['author'];
echo "<br>";
}
}
?>
Im pretty new with this, and i dont understand what can be wrong.
Would appreciate any help 🙂