phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Just do this mysql_query("CREATE TABLE `comment`( `id_comment` INT(11) UNSIGNED AUTO_INCREMENT, `id_user` VARCHAR(225) NOT NULL, `comment` LONGTEXT NOT NULL, UNIQUE KEY(id_comment))") or die(mysql_error()); Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 Well, it works but doesnt display user.. Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 Well Try echo'ing $username = $_SESSION['username'];, and see if there is any data... You might need to be logged in first. Quote Link to comment Share on other sites More sharing options...
phpQuestioner Posted December 14, 2007 Share Posted December 14, 2007 you can also get the username value from your database field, that contains the corresponding username, for the user this is currently logged in. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 I am logged in. And It didnt display ANYTHING when I put $username O.O HUH? Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 I am logged in. And It didnt display ANYTHING when I put $username O.O HUH? Post your login script. Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 <?PHP // Connects to your Database include ('Connect.php'); include('top.php'); $submit = $_POST['submit']; //Body Settings echo "<center><font color='#AFAFAF' face='verdana' size='1'>"; //If User Is Logged In if (isset($_COOKIE['UserID'])) { //Display Message echo "Sorry, you are already logged in. Click <a href='index.php'>Here</a> to go back."; //Exit Page exit; } //If Form Is Submitted if ($submit) { // Checks if pass/user exists $usercheck = addslashes($_POST['username']); $passcheck = md5(addslashes($_POST['password'])); $Result1 = mysql_query("SELECT * FROM users WHERE username='$usercheck' AND password='$passcheck'"); $Rows1 = mysql_fetch_array($Result1); if (mysql_num_rows($Result1) == 0) { echo "Invalid Username/password."; exit; } $UserID = $Rows1['ID']; setcookie("UserID", "$UserID", time() + 9999999); echo "You have successfully logged in. <a href='index.php'>Continue</a>"; } //If Form Isn't Submitted else { echo " <form id='frm' method='POST'> <input type='hidden' name='submit' value='1'> <b>Username</b> <input type=\"text\" name=\"username\" maxlength=\"30\"> <br /> <b>Password</b> <input type=\"password\" name=\"password\" maxlength=\"25\"> <br /> <input type='submit' value='Sign In'> </form>"; } include('bottom.php'); ?> Quote Link to comment Share on other sites More sharing options...
phpSensei Posted December 14, 2007 Share Posted December 14, 2007 you are using setcookie, MEANING $_SESSION['login'] or whatever Should be $_COOKIE['UserID'] try <?php include('Connect.php'); include('top.php'); $submit = $_POST['submit']; $username = $_COOKIE['UserID']; $comment = $_POST['comment']; if ($submit) { Quote Link to comment Share on other sites More sharing options...
Xyphon Posted December 14, 2007 Author Share Posted December 14, 2007 I ahd to set another cookie on login set as UserName, or it'd display their ID. Which Im going to add, anyways. 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.