Jump to content

[SOLVED] Displaying session in a form value


MySQL_Narb

Recommended Posts

Form code:

 

<form action="post.php" method="POST">
<span style='color:blue'><div class="box">Name: <input type="text" name="name" value="<?php echo $session->username ?>"><br><br>

 

And my session codes (On index, not login.php):

 

session_start();

echo $_SESSION['username'];

<font face='arial' size='2'><style type="text/css">

a:link {
color:#24374C;
text-decoration:bold;
}

a:visited {
color:#24374C;
text-decoration:bold;
}

a:active {
outline: none;
color:#24374C;
text-decoration:bold;
}

body {background-color:#b0c4de}

hr.{backround-color:#b0c4de}

div.box {
width:250px;
padding:10px;
border:3px double #000000;
margin:10px;
background-color:#74AFF2;
}
</style><p class="nub">
<center><h3><div class="box"><span style='color:blue'>Make a post/comment</span></div></h3>
<form action="post.php" method="POST">
<span style='color:blue'><div class="box">Name: <input type="text" name="name" value="<?php echo $_SESSION['username']; ?>"><br><br>
Message: <br><br><textarea rows="10" cols="27" name="message">

</textarea><br><br>
<a href="verification.php"><b>Demo ACP</b></a>
<input type="submit" value="Post it!"><a href="real_verification.php"><b>Real ACP</b></a><br /><a href="mod_verification.php"><b>Mod CP</b></a>
</form></center></p></span>
<center><div class='box'><h3>View a message</h3>
<form action='view_comment.php' method='POST'>
Message ID
<input type='text' name='id'>
<input type='submit' value='View'>
</form></div></center>
<hr>
<br>

<?php

session_start();

echo $_SESSION['username'];

//connect to database
$connect = mysql_connect("","","") or die("Connection failed!");
mysql_select_db("a") or die("Database fail!");

//extract
$extract = mysql_query("SELECT * FROM posts ORDER BY id DESC");
$numrows = mysql_num_rows($extract);

while ($row = mysql_fetch_assoc($extract))

{
       $id = $row[id]; 
   $message = $row[message];
           $name = $row[name];
           $id = $row[id];

       if ($name =="iiffii")
      $name = "<img src='crown_gold.gif'><b> <a href='master.htm'><span style='color:6D8DFF'>Master</span></a></b>";
              $message = "<span style='color:#4B729E'>$message</span>";

       if ($name =="soulze1526")
          $name = "<img src='crown_gold.gif'><b> <a href='soulze.htm'><span style='color:6D8DFF'>Soulze</span></a></b>";

       if ($name =="iluvpalol")
          $name = "<img src='mod_silver.gif'><b> <span style='color:6D8DFF'>Kadir</span></b>";

       if ($name =="palace55o7")
          $name = "<img src='mod_silver.gif'><b> <a href='palace.htm'><span style='color:6D8DFF'>Palace</span></a></b>";

   echo "<font face='arial' size='3'><center>($id) Posted by: <b>$name</b></img><br><br><b>$message</b><br /><br /></center><hr>";
   

}

?>
<!--VISISTAT SNIPPET//-->
<script type="text/javascript">
var DID=;
var pcheck=(window.location.protocol == "https:") ? "https://sniff.visistat.com/live.js":"http://stats.visistat.com/live.js";
document.writeln('<scr'+'ipt src="'+pcheck+'" type="text\/javascript"><\/scr'+'ipt>');
</script>
<!--VISISTAT SNIPPET//-->

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.