-
Posts
10 -
Joined
-
Last visited
-
Days Won
1
Spencer last won the day on February 2 2013
Spencer had the most liked content!
About Spencer
- Birthday 05/22/1998
Contact Methods
-
Website URL
http://megabox.heliohost.org
Profile Information
-
Gender
Male
-
Location
NintendoLand
-
Interests
Old school Nintendo and Sega gaming, programming, learning how stuff works.
Spencer's Achievements
Newbie (1/14)
2
Reputation
-
Banned Users Script Makes All Users Banned? - Php / Mysql
Spencer replied to Spencer's topic in Website Management and Coding
Sweet, thanks. It works fine. Now I got to go learn how to use newer sessions instead of older versions. XP -
Banned Users Script Makes All Users Banned? - Php / Mysql
Spencer replied to Spencer's topic in Website Management and Coding
Hm... its still not working... but when you said: "Assuming you did a session_register(userlevel) so the value is set, try this:" Do you mean make it say: $row = mysql_fetch_assoc($result); session_register($row['rank']=$userlevel); session_register($userlevel) ? ( I tried that and without it and both did not work... ) Then I added this: if($_SESSION['userlevel'] == 'banned') { header("location:../banned.html"); } It didnt work and I also tried this: if($_SESSION['$userlevel'] == 'banned') { header("location:../banned.html"); } Yeah, lol. I just don't see whats wrong with my code. -
Hey. I'm trying to make a banned user script. I want it so if a banned user trys to enter the chatroom, it brings them to a new page. My problem is, it acts like every user is a banned user... o.O Here is the part in the php code that gets the users "rank" from the db when they login. $row = mysql_fetch_assoc($result); session_register($row['rank']=$userlevel); Then here is the part of the code for the chatroom that checks if the user is a banned user or not: <?php session_start(); if(!session_is_registered(myusername)){ header("location:/login/main_login.php"); //This is just checking if the user is logged in or not. } if(session_register($userlevel=='banned')) { header("location:../banned.html"); } So that's it. Thanks. ~ Spencer
-
Hello There! I am trying to get my chat room, to automatically update the messages and data. As of right now, to see a new message, you must refresh the page. ( I learned from w3schools and don't quite get AJAX as much as I want to. :/ So if I'm way off track, please tell me. ) As always, here is the code I am using: &--#60;?php session_start(); if(!session_is_registered(myusername)){ header("location:/login/main_login.php"); } $myusername = $_SESSION['myusername']; ?&--#62; &--#60;html&--#62; &--#60;head&--#62; &--#60;link rel="SHORTCUT ICON" href="http://oi46.tinypic.com/rky444.jpg"&--#62; &--#60;title&--#62;Mbox:Chat&--#60;/title&--#62; &--#60;script type='text/javascript'&--#62; function updateChat() { var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { document.getElementById("topscreen").innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET",/chat/chatroom.php?error=",true); xmlhttp.send(); } &--#60;/script&--#62; &--#60;style&--#62; /*3DS SCREEN START*/ div#topscreen { border:15px solid; border-color:#1E90FF; overflow:auto; position: absolute; top: 0px; left: 0px; height: 205px; width: 290px; background-color:#FFFFFF; z-index:2; } div#bottomscreen { position: absolute; top: 218px; left: 0px; height: 212px; width: 320px; background-color:#1E90FF; } /*3DS SCREEN STOP*/ div#taskbar { background-color:silver; width:320px; height:100px; position:absolute; top:30px; z-index:5; } &--#60;/style&--#62; &--#60;meta name="viewport" content="width=320"&--#62; &--#60;/head&--#62; &--#60;body&--#62; &--#60;body onload="setInterval('updateChat()',5000);"&--#62; &--#60;!-- TOP SCREEN --&--#62; &--#60;div id="topscreen"&--#62; &--#60;?php $db_sitename="spencer_register"; $db_hostname="localhost"; $db_username="spencer_mega"; $db_password="PASSWORD HERE"; $no_of_comments="15"; /* Leave the script below as it is */ mysql_connect($db_hostname, $db_username, $db_password); mysql_select_db($db_sitename); $pagename=md5($_SERVER['PHP_SELF']); $query=mysql_query("Select * from comments where comment_on='$pagename' ORDER BY id DESC LIMIT 0, $no_of_comments"); while($fetch=mysql_fetch_array($query)) { echo "&--#60;p&--#62;&--#60;b&--#62;&--#60;sub&--#62;".$fetch['comment_by'].": &--#60;/sub&--#62;&--#60;/b&--#62;&--#60;sub&--#62;".$fetch['comment']."&--#60;/sub&--#62;&--#60;/p&--#62;"; } mysql_close(); ?&--#62; &--#60;/div id="topscreen"&--#62; &--#60;!-- BOTTOM SCREEN --&--#62; &--#60;div id="bottomscreen"&--#62; &--#60;!-- PUT STUFF ON THE TASKBAR UNDER THE DIV ID TASKBAR --&--#62; &--#60;div id="taskbar"&--#62; &--#60;a href="../homepage.php"&--#62;&--#60;img src="http://the12.squarespace.com/storage/zzzzhome.png?__SQUARESPACE_CACHEVERSION=1356027845932" width="50px" height="50px"&--#62;&--#60;/a&--#62; &--#60;/div id="taskbar"&--#62; &--#60;!-- Send input box start --&--#62; &--#60;form action="/chat/post_chat.php" method="post"&--#62; &--#60;table&--#62; &--#60;tr&--#62;&--#60;td&--#62; &--#60;/td&--#62;&--#60;td&--#62;&--#60;input type="hidden" name="comment_on" size="" readonly="readonly" value="&--#60;?php print md5($_SERVER['PHP_SELF']); ?&--#62;"/&--#62;&--#60;/td&--#62;&--#60;/tr&--#62; &--#60;input type="hidden" name="comment_by" value="&--#60;?php echo $myusername;?&--#62;"/&--#62; &--#60;tr&--#62;&--#60;td&--#62;&--#60;input name="comment" size="33" maxlength="255" &--#62;&--#60;input type="submit" value="Send!" /&--#62;&--#60;/td&--#62;&--#60;/tr&--#62; &--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62;&--#60;br/&--#62; &--#60;tr&--#62;&--#60;td&--#62;&--#60;/td&--#62;&--#60;td&--#62;&--#60;/td&--#62;&--#60;/tr&--#62; &--#60;/table&--#62; &--#60;/form&--#62; &--#60;/div id="bottomscreen"&--#62; &--#60;/body&--#62; &--#60;/html&--#62; Yeah I know. =P Some messy coding, but I'm working on it. Alright, well thanks in advance! ~ Spencer
-
Php - Comment Section - How Display Username
Spencer replied to Spencer's topic in Website Management and Coding
Okay... I guess... It still does not work... I changed the values into the database ones too. I changed it from: VALUES ('$myusername','$comment_on','$comment')"); into: VALUES ('$comment_by','$comment_on','$comment')"); Still nothing. When you said to me: "Check to see if your database is actually saving the information you pass it." It is. I think. It saves the comment Id, comment, and comment_on. But it does not save the user who posted it. ( It used to when I made an inputbox for who is posting the comment. ) Another thing is this part in my post_comment.php: $comment_by=$_POST['$myusername']; Is this right? -
Php - Comment Section - How Display Username
Spencer replied to Spencer's topic in Website Management and Coding
The comment table and user table are both working and saving the information. You see, I think it is not working cause: $myusername is whatever the user put into the input box when logging in. So, $myusername is different on each users screen. Example when I am logged in: Welcome, Spencer! Example when my friend is logged in: Welcome, DrakeJ! So I do realize I probably should not use $myusername ( If I can still, please tell me. ) So what would I even do to make it work? o.O -
Php - Comment Section - How Display Username
Spencer replied to Spencer's topic in Website Management and Coding
Doesn't work still. It will now say: Comment By: _________ . Yeah... Nobody. Do I have to go get the user name in the table with the registered users somehow? -
Php - Comment Section - How Display Username
Spencer posted a topic in Website Management and Coding
Hey there! Recently, I have made a comment section on my website. It worked great, but to show who posted a comment, a user would have to type in who they are in the "Comment By:" inputbox. I don't want this anymore, due to users being able to impersonate one another. I want to make it show actually who posted it. ( Yes. I have a working register and login ). Here is my news:chatroom_first_priority.php code ( Note: I have removed the Comment By: inputbox and all the rest of that stuff. This is my attempted code. If needed, tell me you want to see my original code. ) : <?php session_start(); if(!session_is_registered(myusername)){ header("location:/login/main_login.php"); } $myusername = $_SESSION['myusername']; ?> <html> <head> <title>Mbox:News</title> <script> </script> <style> /*3DS SCREEN START*/ div#topscreen { position: absolute; top: 0px; left: 0px; height: 1300px; width: 320px; background-color:#1E90FF; z-index:2; } div#bottomscreen { position: absolute; top: 218px; left: 0px; height: 212px; width: 320px; background-color:#1E90FF; } /*3DS SCREEN STOP*/ /* WELCOME USERNAME STYLE START */ div#welcome_username { text-decoration:none; color:#000000; font-weight: bold; background-color:aqua; text-align:center; } /* WELCOME USERNAME STYLE STOP */ a.logout { text-decoration:underline; color:#000000; font-weight:bold; background-color:#FFFFFF; position:absolute; top:0px; left:250px; } a.home { text-decoration:underline; color:#000000; font-weight:bold; background-color:#FFFFFF; position:absolute; top:0px; left:5px; } a:link { color:#000000; text-decoration:underline; } a:visited { color:#000000; text-decoration:underline; } a:hover { color:#FF0000; text-decoration:none; } p.article_by { background-color:lime; text-align:left; font-weight:bold; } </style> <meta name="viewport" content="width=320"> </head> <body> <!-- TOP SCREEN --> <div id="topscreen"> <?php //echo "Welcome, " . $myusername . "!"; ( OLD CODE ) echo "<div id=\"welcome_username\">Welcome, $myusername ! </div>"; ?> <!-- WELCOME USERNAME PHP SCRIPT STOP --> <!-- REST OF STUFF DOWN --> <a href="../login/logout.php" class="logout">Log out</a> <a href="../homepage.php" class="home">Home</a> <!-- MAKE THE LINE BELOW THE WELCOME --> <br/> <hr/> <a href="/news/news.php"><img src="http://www.pokernewsreport.com/wp-content/uploads/2011/04/news-icon.png" style="width:75px; height:75px; position:absolute; top:60px; left:120px;"></a> <br/> <br/> <br/> <p class="article_by">Spencer:</p> <!-- ARTICLE START --> <p style="background-color:white;">This is just a test section for now</strong> <br/> <strong>~ Spencer</strong></p> <!-- ARTICLE STOP --> <hr/> <form action="/news/post_comment.php" method="post"> <table> <tr><td> </td><td><input type="hidden" name="comment_on" size="" readonly="readonly" value="<?php print md5($_SERVER['PHP_SELF']); ?>"/></td></tr> <tr><td>Comment: </td><td><textarea name="comment" cols=24></textarea></td></tr> <tr><td></td><td><input type="submit" value="Submit" /></td></tr> </table> </form> <?php $db_sitename="spencer_register"; $db_hostname="localhost"; $db_username="spencer_mega"; $db_password="PASSWORD HERE"; $no_of_comments="10"; /* Leave the script below as it is */ mysql_connect($db_hostname, $db_username, $db_password); mysql_select_db($db_sitename); $pagename=md5($_SERVER['PHP_SELF']); $query=mysql_query("Select * from comments where comment_on='$pagename' ORDER BY id DESC LIMIT 0, $no_of_comments"); echo "<hr />"; echo "<h3>Latest Comments</h3>"; while($fetch=mysql_fetch_array($query)) { echo "<p>".$fetch['comment']."<br/><sub><b>Comment by: </b>".$myusername."</sub><hr /><p>"; } mysql_close(); ?> </div id="topscreen"> <!-- BOTTOM SCREEN --> <div id="bottomscreen"> </div id="bottomscreen"> </body> </html> Here is my post_comment.php: <?php $db_sitename="spencer_register"; $db_hostname="localhost"; $db_username="spencer_mega"; $db_password="PASSWORD HERE"; /* Leave the script below as it is */ mysql_connect($db_hostname, $db_username, $db_password); mysql_select_db($db_sitename); $comment_on=$_POST[comment_on]; $comment_by=$_POST['$myusername']; $comment=$_POST[comment]; $query=mysql_query("INSERT INTO comments (comment_by,comment_on,comment) VALUES ('$myusername','$comment_on','$comment')"); if($query) { $ref=$_SERVER['HTTP_REFERER']; header("location: $ref"); } else { echo "Error when posting the comment."; } mysql_close(); ?> I actually know what I am doing wrong, but don't know how to fix it. myusername whatever the person types into the username login inputbox before logging in, to make it at the top say, Welcome, Username! So now, it will say all of the comments are posted by YOU. Thanks for the help! I appriciate it! ~ Spencer -
Hey there! I want to style an "echo" in PHP. ( You know. Make it blue, position it, ect. ) All the examples and places I have learned about this work, but this echo has a variable in it: echo '<div id="welcome_username">"Welcome, " . $myusername . "!"</div>'; The variable is $myusername ( Making it say "Welcome, Username!" =P ) Is there a different way to style an echo, when it has a variable? Thanks for your time. ~ Spencer ( If you must, here is the whole code... I do't think it is needed though. ) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ <?php session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } $myusername = $_SESSION['myusername']; ?> <html> <head> <title>Mbox:homepage</title> <script> window.setInterval(function(){ window.scrollTo(40, 220); }, 50); </script> <style> /*3DS SCREEN START*/ div#topscreen { position: absolute; top: 0px; left: 0px; height: 218px; width: 320px; background-color:#E0FFFF; z-index:2; } div#bottomscreen { position: absolute; top: 218px; left: 0px; height: 212px; width: 320px; background-color:#E0FFFF; } /*3DS SCREEN STOP*/ /* WELCOME USERNAME STYLE START */ div#welcome_username { color:#0000EE; font-weight: bold; position:absolute; top:5px; left:50px; } /* WELCOME USERNAME STYLE STOP */ </style> <meta name="viewport" content="width=320"> </head> <body> <!-- TOP SCREEN --> <div id="topscreen"> <?php echo '<div id="welcome_username">Welcome, . $myusername . !</div>'; ?> <p style="color:red; text-decoration:underline;">Homepage under construction.</p> </div id="topscreen"> <!-- BOTTOM SCREEN --> <div id="bottomscreen"> </div id="bottomscreen>" </body> </html>