i have a login system in place, i decided it may be a good idea to have a news section, which i can update from my admin login.

I created a row called 'tdanews'. now i have manually inserted some info into it, and echo'd it into the users login, it works fine, now i have tried to make a script so i can submit a form from my admin page to updte it, but i cant get it to work, any advice?

my code..

<?php
session_start();
if (!isset($_SESSION)) {
echo 'Please <a href="login.php">log in</a> to access your account';
exit();
}
include_once "connection.php";
// Place Session variable 'id' into local variable
$id = $_SESSION;
// Process the form if it is submitted
if ($_POST) {
$tdanews = $_POST;
$sql = mysql_query("UPDATE thedriving3 SET tdanews='$newtdanews' WHERE id='$id'");
echo 'Your account info has been updated, visitors to your profile will now see the new info.';
exit();
}
else
echo "error";// close if post
?>
<?php
// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM members WHERE id='$id' LIMIT 1");
while($row = mysql_fetch_array($sql)){
$tdanews = $row["tdanews"];
}
?>

thanks

Member Avatar for rajarajan2017
$newtdanews

Where this coming from? I think your statement should like this

[B]$newtdanews[/B] = $_POST['tdanews'];
$sql = mysql_query("UPDATE thedriving3 SET tdanews='$newtdanews' WHERE id='$id'");
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.