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'];

Link to comment
Share on other sites

<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//-->

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.