I have a guest book but when it completes, only the username and message part works (updates to database) however $yourname var dosn’t get put into the table “name” on the database and think its this page because if I manually add a name in the table it shows up on the guest book view page,
any ideas please anyone, i have tried all kinds to no avail.
PS yes I am logged in, and not sure why it dosn’t work as it should as the message gets in there along with the users name ($username) who the guestbook is for.
[php]<?php
session_start();
?>
J~Net Guestbook
<?php
require 'database.php';
// include '../header.php';
$id = $_SESSION['user_id'];
$_SESSION['user_id']= $id;
$yourname = $_SESSION['user_name'];
$_SESSION['user_name']= $yourname;
// $_SESSION['user_name'] = $full_name;
$_SESSION['user_level'] = $user_level;
$_SESSION['HTTP_USER_AGENT'] = md5($_SERVER['HTTP_USER_AGENT']);
$_SESSION['session_name'] = $user_name;
$_SESSION['balance']= $balance;
// Connects to your Database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("messages") or die(mysql_error());
$data = mysql_query("SELECT * FROM users where id = $id")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
echo "
";
echo " ".$info['user_name'] . " | ";
}
$username = $_SESSION['visited_profile'];
$yourname = $info["user_name"];
$message = strip_tags($_POST['message']);
if (isset($_POST['submit']))
{
if (!$message)
{
echo "Please Enter A Message!";
echo "$yourname";
echo " ";
exit;
}
else{}
$query = mysql_query("INSERT INTO guestbook (username, message, name) VALUES ('$username','$message','$yourname')") or die(mysql_error());
echo "Your Message Was Posted Sucsessfuly!
Continue";
}
?>[/php]