Shaun13
Members-
Posts
61 -
Joined
-
Last visited
Never
Everything posted by Shaun13
-
same thing. :'( ~Shaun
-
Here we go: ~Logged In~ Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/=P/shaunsboards/index.php:3) in /var/www/=P/shaunsboards/index.php on line 4 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/=P/shaunsboards/index.php:3) in /var/www/=P/shaunsboards/index.php on line 4 Welcome Resource id #4 | Logout ~Logged Out~ Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /var/www/=P/shaunsboards/index.php:3) in /var/www/=P/shaunsboards/index.php on line 4 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /var/www/=P/shaunsboards/index.php:3) in /var/www/=P/shaunsboards/index.php on line 4 You have encountered an error.
-
Logged out I get: Notice: Undefined index: myusername in /var/www/=P/shaunsboards/index.php on line 21 You have encountered an error. Logged in I get: Notice: Use of undefined constant myusername - assumed 'myusername' in /var/www/=P/shaunsboards/index.php on line 27 Welcome Resource id #4 | Logout Whats it all mean, lol. ~Shaun
-
That seemed to have done something, but for some odd reason, it says: Welcome 0 | Logout Any ideas why? By the way thanks so much for helping me out, I appreciate it. ~Shaun
-
Ok, it got rid of the "Resource id #4, but now it doesn't say anything it just says: Welcome | Logout :'( ~Shaun
-
Ok, thanks for the tip. I only used $_SESSION because I don't know how to call session_register from the next page? Do you know? In other words, on index.php I have $myusername=$_SESSION['myusername']; How would i set up the variable for session register? Would it be: $myusername=sessionregister['myusername'] ??? ~Shaun
-
Aww man. Still came up with the same thing. I will post both the login.php and index.php files. login.php: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>~ShaunsBoards~Login</title> </head> <center> <table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC"> <tr> <form name="form1" method="post" action="checklogin.php"> <td> <table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCDDCC"> <tr> <td colspan="3" align="center"><strong><font color="#336633">ShaunsBoards Login </font></strong></td> </tr> <tr> <td width="78">Username</td> <td width="6">:</td> <td width="294"><input name="myusername" type="text" id="myusername"></td> </tr> <tr> <td>Password</td> <td>:</td> <td><input name="mypassword" type="password" id="mypassword"></td> </tr> <tr> <td> </td> <td> </td> <td><input type="submit" name="Submit" value="Login"> </td> </tr> <tr> <td align="center" colspan="4"><a href="register.php">Register</a></td> </tr> </table> </td> </form> </tr> </table><br /><br /><br /> </center> </body> </html> checklogin.php: <?php $host="localhost"; // Host name $username="=P"; // Mysql username $password="=P"; // Mysql password $db_name="=P"; // Database name $tbl_name="members"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); // username and password sent from signup form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row if($count==1){ // Register $myusername, $mypassword and redirect to file "login_success.php" session_register("myusername"); session_register("mypassword"); session_register("myusername"); header("location:index.php"); $_SESSION['myusername']=$myusername; } else { echo "Wrong Username or Password"; } ?> index.php: <?php session_start(); $host="localhost"; // Host name $username="=P"; // Mysql username $password="=P"; // Mysql password $db_name="=P"; // Database name $tbl_name="posts"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <center> <?php $tbl_name2="members"; $myusername=$_SESSION['myusername']; $mydn="SELECT displayname FROM $tbl_name2 WHERE username = '$myusername'"; $mydisplayname=mysql_query($mydn); if (mysql_num_rows($mydisplayname)>0) { while ($row = mysql_fetch_assoc($mydisplayname)) { extract($row); if(session_is_registered(myusername)){ echo "Welcome ".$mydisplayname." | <a href='logout.php'>Logout</a>"; } else { echo "<a href='login.php'>Login</a> | <a href='register.php'>Register</a>"; } } } ?> </center> <br /><br /> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="40%" align="center" bgcolor="#CCDDCC"><strong>Topic</strong></td> <td width="20%" align="center" bgcolor="#CCDDCC"><strong>Author</strong></td> <td width="15%" align="center" bgcolor="#CCDDCC"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#CCDDCC"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#CCDDCC"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['title']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['author']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['views']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['posts']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#CCDDCC"> <? if(session_is_registered(myusername)){ echo "<a href='create_topic.php'><strong>Create New Topic</strong> </a>"; } else { echo "<a href='login.php'>Login</a> to start topics!"; } ?> </tr> </table> Feel free to change some things around and try. I really need this fixed. Thanks in advance. ~Shaun
-
Nope, didn't work either. I got this: Welcome Resource id #4 | LogoutWelcome Resource id #4 | Logout Here is the PHP of the whole page: <?php session_start(); $host="localhost"; // Host name $username="=P"; // Mysql username $password="=P"; // Mysql password $db_name="=P"; // Database name $tbl_name="posts"; // Table name // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name ORDER BY id DESC"; // OREDER BY id DESC is order result by descending $result=mysql_query($sql); ?> <center> <?php $tbl_name2="members"; $myusername=$_SESSION['myusername']; $mydn="SELECT displayname FROM $tbl_name2 WHERE username = '$myusername'"; $mydisplayname=mysql_query($mydn); if (mysql_num_rows($mydisplayname)>0) { while ($row = mysql_fetch_assoc($result)) { extract($row); if(session_is_registered(myusername)){ echo "Welcome ".$mydisplayname." | <a href='logout.php'>Logout</a>"; } else { echo "<a href='login.php'>Login</a> | <a href='register.php'>Register</a>"; } } } ?> </center> <br /><br /> <table width="90%" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC"> <tr> <td width="40%" align="center" bgcolor="#CCDDCC"><strong>Topic</strong></td> <td width="20%" align="center" bgcolor="#CCDDCC"><strong>Author</strong></td> <td width="15%" align="center" bgcolor="#CCDDCC"><strong>Views</strong></td> <td width="13%" align="center" bgcolor="#CCDDCC"><strong>Replies</strong></td> <td width="13%" align="center" bgcolor="#CCDDCC"><strong>Date/Time</strong></td> </tr> <?php while($rows=mysql_fetch_array($result)){ // Start looping table row ?> <tr> <td bgcolor="#FFFFFF"><a href="view_topic.php?id=<? echo $rows['id']; ?>"><? echo $rows['title']; ?></a><BR></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['author']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['views']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['posts']; ?></td> <td align="center" bgcolor="#FFFFFF"><? echo $rows['datetime']; ?></td> </tr> <?php // Exit looping and close connection } mysql_close(); ?> <tr> <td colspan="5" align="right" bgcolor="#CCDDCC"> <? if(session_is_registered(myusername)){ echo "<a href='create_topic.php'><strong>Create New Topic</strong> </a>"; } else { echo "<a href='login.php'>Login</a> to start topics!"; } ?> </tr> </table>
-
Nope, sorry about double post too. When I use the variable $myusername instead of $mydisplayname it works fine. Is there a problem in the MySQL stuff? ~Shaun
-
Anybody that could help me out with this would be lovely.
-
Hi, this is a snipet from my newest project ShaunsBoards. It is some simple forum software. <? $tbl_name2="members"; $myusername=$_SESSION['myusername']; $mydn="SELECT displayname FROM $tbl_name2 WHERE username = '$myusername'"; $mydisplayname=mysql_query($mydn); if(session_is_registered(myusername)){ echo "Welcome ".$mydisplayname." | <a href='logout.php'>Logout</a>"; } else { echo "<a href='login.php'>Login</a> | <a href='register.php'>Register</a>"; } ?> This is a small snipet from my forums index. The $myusername variable is taken from the session cookie and that is in the mysql database. What I want it to do is get the persons username ($myusername) in the mysql table and get their display name which is also in that table. Now, when I leave it as "welcome.$myusername" it works fine, but right now I get this: Welcome Resource id #4 | Logout What am I doing wrong? ~Shaun