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 Code:<?php
session_start();
?>
<html>
<head>
<title>J~Net Guestbook</title>
<link rel="stylesheet" type="text/css" href="../css/style.css" />
</head>
<?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 "<tr>";
echo " <td>".$info['user_name'] . "</td> ";
}
$username = $_SESSION['visited_profile'];
$yourname = $info["user_name"];
$message = strip_tags($_POST['message']);
if (isset($_POST['submit']))
{
if (!$message)
{
echo "<P><center>Please Enter A Message!";
echo "$yourname";
echo "<FORM><INPUT TYPE='button' VALUE='Go back' onClick='history.go(-1);return true;'> </FORM>";
exit;
}
else{}
$query = mysql_query("INSERT INTO guestbook (username, message, name) VALUES ('$username','$message','$yourname')") or die(mysql_error());
echo "<center>Your Message Was Posted Sucsessfuly!<br /><a href='guestbook.php?" . $_SESSION['visited_profile'] . "'>Continue</a></center>";
}
?>


Reply With Quote
Bookmarks