Jump to content

Php Status Update


cazconv

Recommended Posts

Hi, im building a social networking site for my dissertation and im having a little trouble with one part updating the status's I can get it updated in the database but I cant figure out how to have a user to a status, I have a table of :

 

CREATE TABLE Dis_Status

(username varchar(255), StatusID INT (2) NOT NULL AUTO_INCREMENT,

Status Varchar(255),

PRIMARY KEY (StatusID),

FOREIGN KEY (username) REFERENCES Dis_Teen(username));

 

Heres my Profile Page

 

<?php

session_start();

 

require_once('dbconnect.php');

 

if (isset($_SESSION["username"])) {

    $username = $_SESSION['username'];

 

} else {

    // not logged in so redirect

    header("location: login.php");

    exit;

}

 

if (isset($_SESSION["password"])) {

    $password = $_SESSION['password'];

 

} else {

    // not logged in so redirect

    header("location: login.php");

    exit;

}

 

if (isset($_SESSION["fullname"])) {

    $First_Name = $_SESSION['fullname'];

}

if (isset($_SESSION["gender"])) {

    $Gender = $_SESSION['gender'];

}

if (isset($_SESSION["group"])) {

    $GroupCode = $_SESSION['group'];

}

if (isset($_SESSION["surname"])) {

    $Surname = $_SESSION['surname'];

}

?>

 

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>

<link rel="stylesheet" type="text/css" href="style2.css" />

<title>TASN - Talk, Play, Share</title></head>

<body>

<h2> Talk, Play, Share </h2>

<div class = "Logo"> <img src = "logo.png" height = "50px" width = "150px" />

</div>

<div class = "logout">

<a href = "logout.html">

Logout

</a>

</div>

<hr>

<h1>

<?php

echo $First_Name . "s";

echo " ";

echo "Profile Page";

?>

</h1>

<h3>

 

<div class = "StatusPost">

<form action="status.php" method="post">

Status: <input type="text" name="Status"/><br>

<input type="Submit" value="Post" style="background-color:#3300CC; color: #ffffff;"/>

</form>

 

</div>

<?php

 

$result = mysql_query("SELECT Group_Name FROM Dis_Group WHERE Group_Code='$GroupCode'");

 

echo "<div class = \"ProfileInfo\">";

echo "Name:";

echo " ";

echo $First_Name." ".$Surname;

echo "<br>";

echo "Status:";

echo "<br>";

echo "Group:";

echo " ";

while ($row = mysql_fetch_array ($result)) {

echo $row[0];

}

 

echo "</div>";

 

if ($Gender == "Female") {

    echo "<div class = \"profilepic\">";

    echo '<img src = "girl.png" width = "150px" height = "150px">';

    echo "</div>";

} else {

    echo "<div class = \"profilepic\">";

    echo '<img src = "boy.png" width = "150px" height = "150px">';

    echo "</div>";

}

?>

</h3>

</body>

</html>

 

And heres Status.php

 

<?php

require_once('dbconnect.php');

 

include 'Profile.php';

 

$Status=$_POST['Status'];

$Status = stripslashes($Status);

$Status = mysql_real_escape_string($Status);

 

//if username is

 

$sql="INSERT INTO Dis_Status(Status)

VALUES

('$_POST[status]'.'$_POST[status]')";

 

if (!mysql_query($sql))

  {

  die('Error: ' . mysql_error());

  }

 

  echo $Status

 

?>

 

How can i insert the username of the person already logged in into the status table along with thier status??? Sorry if im not making much sense im not used to asking questions on forums.

Link to comment
https://forums.phpfreaks.com/topic/191973-php-status-update/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.