MySQL_Narb Posted October 14, 2009 Share Posted October 14, 2009 How? Current code: <span style='color:blue'><div class="box">Name: <input type="hidden" name="name" value="<?php session->username ?>"><br><br> And it gives me an error all the time. :/ Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 Assuming you meant $session->username are you sure the $session object is defined? Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 Yes it's defined, I did a test for it to echo on the page without being in a form, and it worked. But when I try and add it to the form value, nothing happens. Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 As I pointed out, your code was missing the $ from the start of session. Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 Oops, it also needs to be.... <?php echo $session->username ?> not simply <?php $session->username ?> Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 Yes, and I added it. And still nothing, here, I'll repost the code: <span style='color:blue'><div class="box">Name: <input type="text" name="name" value="<?php echo $session->username ?>"><br><br> Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 See above post. Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 I edited my above post. Would it be a help to post my WHOLE code? Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 Just post the relevant form section. Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 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']; Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 As I suspected. I'm not sure the $session object is defined anywhere in your code. I'm not sure your even aware of what an object is. Try... <?php echo $_SESSION['username']; ?> within your form. Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 New code; <span style='color:blue'><div class="box">Name: <input type="text" name="name" value="<?php echo $_SESSION['username']; ?>"><br><br> Still not working. Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 Have you called session_start() ? Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 <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//--> Quote Link to comment Share on other sites More sharing options...
trq Posted October 14, 2009 Share Posted October 14, 2009 <?php session_start(); ?> Needs to go at the top of the page. Quote Link to comment Share on other sites More sharing options...
MySQL_Narb Posted October 14, 2009 Author Share Posted October 14, 2009 Lol rofl, I'm a pure idiot. Thank you for the support. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.