Jump to content

doddsey_65

Members
  • Posts

    902
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by doddsey_65

  1. also by using a text editor such as notepad++ it makes things like this easier as when you select <div> it highlights it and the ending div so you know where it closes. This makes it easier to see which one is missing.
  2. even setting: setcookie('remember', 'Remember me', time() + 99999999); the cookie is still deleted when the browser session finishes. I tried setting the cookie path in php ini but that broke the sessions. Sessions werent being strored properly for some reason, so i got rid of the change(c:/wamp/cookies) and the sessions started working again. But i cant get the cookies to work.
  3. add the current time stamp to the end of the files before they are moved from the tmp directory to your upload area: $currentTime = time(): @move_uploaded_file( $file_Temp , $uploadFile . "_" . $currentTime);
  4. I have made a small class to learn how to do them. This basically adds the new user to the database upon registration. I would like to know if i am doing things right or if there is a better way. Also can anyone tell me why i would use this class? Previously I just included the insert query and if statements in my main register.php page and everything worked fine. what are the advantages to using it in a class? Here is the class: <?php define ("NO_USERNAME", "Please Enter A Username"); define ("NO_PASSWORD", "Please Enter A Password"); define ("NO_EMAIL", "Please Enter An Email Address"); define ("SUCCESFULL_REGISTRATION", "Done"); define ("NO_MATCH", "Your Passwords Did Not Match"); define ("UNKNOWN_ERROR", "An Unknown Error Occured"); class User { public $user_name; public $password; public $email_address; public $password_confirm; public $processed; public $error; function user_create($user_name, $password, $email_address, $password_confirm) { if (empty($user_name)) { $this->error = NO_USERNAME; } elseif (empty($password)) { $this->error = NO_PASSWORD; } elseif (empty($email_address)) { $this->error = NO_EMAIL; } elseif ($password != $password_confirm) { $this->error = NO_MATCH; } else { $this->error = NULL; } if ($this->error == NULL) { echo "Username: " . $user_name . "<br />"; mysql_query("INSERT INTO test_members (user_name, password, email_address) VALUES ('$user_name', '".md5($password)."', '$email_address')") or trigger_error("SQL", E_USER_ERROR); $this->processed = TRUE; } } public function encryptPassword($password) { $password = sha1(md5(md5(sha1(sha1($this->password))))); } } ?>
  5. i meant $_COOKIE['remember']
  6. also when i echo $_COOKIE['remember_me'] i get an undefined error
  7. Was just about to say that. Instead of using: echo "<input type=text value=$result_row[project_name] readonly></include>"; use: echo "<input type="text" value="'.$result_row['project_name'].'" readonly></include>";
  8. Okay im having a problem with cookies so if anyone can help i would be grateful. When you login you can choose how long to stay in for. For testing purposes the choices are: Forever 1 Hour 1 Day Never Based on your choice i am setting the cookie expiration as follows: if ($_POST['remember_me'] == '1') { setcookie('remember', time() + 99999999999999); } elseif ($_POST['remember_me'] == '3600') { setcookie('remember', time() + 3600); } elseif ($_POST['remember_me'] == '84600') { setcookie('remember', time() + 84600); } elseif ($_POST['remember_me'] == '0') { setcookie('remember'); } echo $_COOKIE['remember']; } Then for testing I am echoing the cookie at the head of the document: echo "Cookie: " . @$_COOKIE['remember']; The problem is that when the browser is closed the cookie is gone. Only the last option "never" is set as a session cookie which means the others should stay active even when the browser is closed shouldnt they? Anything i have missed here?
  9. doddsey_65

    Div height

    No matter what i do i cant get my icon div to be the same height as the rest of the divs in the row. My code is: <div class="forum_row"> <div class="icon"> <p class="icon"> SOME TEXT </p> </div> and my css is: div.forum_row { width: 99.3%; display:inline-block; height:auto; } div.icon { width:4%; height:inherit; float:left; margin-top:5px; margin-right: 5px; border:1px solid #888; background: #b0bde2; -moz-border-radius-topleft:5px; -moz-border-radius-topright:5px; -webkit-border-top-left-radius:5px; -webkit-border-top-right-radius:5px; -moz-border-radius-bottomleft:5px; -moz-border-radius-bottomright:5px; -webkit-border-bottom-left-radius:5px; -webkit-border-bottom-right-radius:5px; } p.icon { height:100%; } but the icon div is never the full height of the forum row. In needs to be as there are other divs inside forum_row div which are variable in height and can push the forum div beyond its normal height. So i need the icon div to go with it. Any ideas?
  10. the problem lied in: WHERE t.forum_id = '$forum_id' ".$sort_by . ' ' . $order_by."") it should have been: WHERE t.forum_id = '$forum_id' '".$sort_by . ' ' . $order_by."'") I just removed the two single quotes around the sort and it worked.
  11. I am attempting to order the results of a query using the get value but they wont order. here is the form: echo "<form name=\"order_form\" action=\"{$site_root}/index.php\" method=\"GET\">"; echo "<input type=\"hidden\" value=\"{$forum_id}\" name=\"forum\" />"; echo "<select name=\"order_by\" style=\"margin-left:5px;\">"; echo "<option value=\"asc\" name=\"order_option\" />Order By: Ascending</option>"; echo "<option value=\"desc\" name=\"order_option\" />Order By: Descending</option>"; echo "</select>"; echo "<select name=\"sort_by\" style=\"margin-left:5px;\">"; echo "<option value=\"topic_name\" name=\"sort_option\" />Sort By: Topic Name</option>"; echo "<option value=\"topic_poster\" name=\"sort_option\" />Sort By: Topic Author</option>"; echo "<option value=\"topic_time_posted\" name=\"sort_option\" />Sort By: Time Posted</option>"; echo "<option value=\"topic_views\" name=\"sort_option\" />Sort By: Topic Views</option>"; echo "<option value=\"topic_replies\" name=\"sort_option\" />Sort By: Topic Replies</option>"; echo "<option value=\"topic_last_poster\" name=\"sort_option\" />Sort By: Last Poster</option>"; echo "<option value=\"topic_last_post_time\" name=\"sort_option\" />Sort By: Last Post Time</option>"; echo "</select>"; echo "<input type=\"submit\" value=\"Order\" />"; echo "</form>"; here is the query: $topic_info_query = $db->query("SELECT f.forum_id, f.forum_name, m.user_id, m.user_username, m.user_group, t.thread_topic_id, t.topic_name, t.topic_poster, t.topic_time_posted, t.topic_views, t.topic_replies, t.topic_last_poster, t.topic_last_post_time, t.topic_locked, t.topic_sticky, t.topic_edited, t.topic_last_poster_id, t.topic_last_poster_group, t.topic_icon FROM ".DB_PREFIX."topics as t LEFT JOIN ".DB_PREFIX."members as m ON t.topic_poster = m.user_username LEFT JOIN ".DB_PREFIX."forums as f ON t.forum_id = f.forum_id WHERE t.forum_id = '$forum_id' '".$sort_by . ' ' . $order_by."'") and here is where $sort_by and $order_by are defined: if (isset($_GET['order_by'])) { $order_by = mysql_real_escape_string($_GET['order_by']); $order_by = strtoupper($order_by); } if (isset($_GET['sort_by'])) { $sort_by = 'ORDER BY t.'.mysql_real_escape_string($_GET['sort_by']); } when i echo '".$sort_by . ' ' . $order_by."' which is how it appears in the query i get: t.topic_last_post_time DESC which is exactly right. But the results are not being sorted. The echoed variables change as does the url but no sorting happens. any ideas?
  12. any tips on how to do that?
  13. yes i am using session_start(); could it be something to do with the onClick function? It stores the session fine when i am taken to the login page but when i submit the form it destroys it.
  14. ok here is the form html when viewing source: <form name="order_form" action="http://localhost/myforum/index.php" method="GET"> <input type="hidden" value="1" name="forum" /> <select name="order_by" style="margin-left:5px;"> <option name="order_by_option" value="Array"/> Order By: Ascending </option> <option name="order_by_option" value="Array"/> Order By: Descending </option> </select> <input type="submit" value="Order" /> </form> Basically all i want to do is have Order By: Ascending and the relevent option value to be asc or Order: By Descending and its option value to be desc. I thought I could use an array like: $order_name = array('Ascending', 'Descending'); $order_value = array('asc' => 'Ascending', 'desc' => 'Descending'); and then have a foreach loop to echo the options for how ever many there are in the array like so: foreach ($order_name as $i) { echo "<option name=\"order_by_option\" value=\"{$order_value}\"/>"; echo "Order By: {$i}"; echo "</option>"; } the order by is fine, it lists the options Ascending and Descending. but it doesnt give them the proper values (asc, desc). instead it just assigns the value array.
  15. i am saving the url to a session and when it redirects me to the login page i am echoing thesession for debugging and it looks fine. It displays the url. However when i login the session is destroyed and echoes nothing. Thus my header redirect does nothing. Any ideas why the session is being destroyed? This is an example of a link that you can click which needs you to be logged in. If you arent then you are redirected to the login page where i am echoing the session: <a href="'.$site_root.'/profile.php?user='.$forum_info->user_id.'" title="Visit '.$forum_info->user_username.'\'s Profile" onClick="'.$_SESSION["clicked_link"] = $site_root.'/profile.php?user='.$forum_info->user_id.'">'.$forum_info->user_username.'</a>
  16. that is because they are using mod rewrite in a htaccess file to rewrite the urls to make them more seo(search engine optimization) friendly. for instance look at the url when i am adding o this topic: http://www.phpfreaks.com/forums/php-coding-help/redirection-query/?action=post;num_replies=0 this suggests that i am in a folder called redirection-query but there is no such folder on the server. the actual url would not be seo friendly thus mod rewrite is used to change it in such a way that it is
  17. i am trying to create a combo box so the user can order topics by asc or desc. The problem is trying to get the name of the option to Ascending or Descending and the value to asc or desc. Heres what i have so far: $order_name = array('Ascending', 'Descending'); $order_value = array('asc' => 'Ascending', 'desc' => 'Descending'); echo "<div style=\"float:right;\">"; echo "<form name=\"order_form\" action=\"{$site_root}/index.php\" method=\"GET\">"; echo "<input type=\"hidden\" value=\"{$forum_id}\" name=\"forum\" />"; echo "<select name=\"order_by\" style=\"margin-left:5px;\">"; foreach ($order_name as $i) { echo "<option name=\"order_by_option\" value=\"{$order_value}\"/>"; echo "Order By: {$i}"; echo "</option>"; } echo "</select>"; when i try to order them the GET value is Array. Any ideas?
  18. Ok so a user tries to access a part of the site that requires them to login. So they are taken to the login page. but when they login I want them transfered to the page they were going to. So i thought of something like: <a href="securepage.php" onClick="<?php echo $_SESSION['clicked_link'] = $site_root.'securepage.php'; ?>"> Click Here </a> But when I echo $_SESSION['clicked_link'] not only am i getting the url i am getting the content after. echoed it looks like: http://www.thevault.cz.cc/securepage.php">Click Here So is there a better way to do it? if not what would i need to do to remove everything after the " ?
  19. thanks, i already have the column but didnt know you could order by 2 columns. Sorry I also just noticed that i provided the wrong query lol.
  20. I am creating a sticky topic feature for my forum and dont know how to keep all topics marked sticky at the top of the list generated by the while loop. Any one have any ideas? They are ordered by the post date column. Here is the query: $posts_info_query = $db->query("SELECT p.post_id, p.topic_id, p.forum_id, p.post_poster, p.post_subject, p.post_content, p.post_time, p.post_edit_by, p.post_edit_date, p.post_edit_num, p.post_approved, p.post_quoting, m.user_id, m.user_username, m.user_group, m.user_regdate, m.user_birthday, m.user_online, m.user_sex, m.user_location, m.user_show_sex, m.user_show_location, m.user_show_status, m.user_avatar, m.user_sig, m.user_posts FROM ".DB_PREFIX."posts as p LEFT JOIN ".DB_PREFIX."members as m ON p.post_poster = m.user_username WHERE p.topic_id = '$topic_id' ORDER BY p.post_time ASC LIMIT $start, $limit") or trigger_error("SQL", E_USER_ERROR); Thanks
  21. while ($topic_info = mysql_fetch_object($topic_info_query)) { $thread_topic_id = $topic_info->thread_topic_id; ?> <script type="text/javascript"> var defaultMenuWidth="150px" //set default menu width. var linkset=new Array() //SPECIFY MENU SETS AND THEIR LINKS. FOLLOW SYNTAX LAID OUT linkset[0]='<a href="index.php?forum=<?php echo $forum_id; ?>&topic=<?php echo $thread_topic_id; ?>">View Topic</a>' linkset[0]+='<a href="">View Newest Post</a>' linkset[0]+='<a href="">Subscribe</a>' ////No need to edit beyond here var ie5=document.all && !window.opera var ns6=document.getElementById if (ie5||ns6) document.write('<div id="popitmenu" onMouseover="clearhidemenu();" onMouseout="dynamichide(event)"></div>') function iecompattest(){ return (document.compatMode && document.compatMode.indexOf("CSS")!=-1)? document.documentElement : document.body } function showmenu(e, which, optWidth){ if (!document.all&&!document.getElementById) return clearhidemenu() menuobj=ie5? document.all.popitmenu : document.getElementById("popitmenu") menuobj.innerHTML=which menuobj.style.width=(typeof optWidth!="undefined")? optWidth : defaultMenuWidth menuobj.contentwidth=menuobj.offsetWidth menuobj.contentheight=menuobj.offsetHeight eventX=ie5? event.clientX : e.clientX eventY=ie5? event.clientY : e.clientY //Find out how close the mouse is to the corner of the window var rightedge=ie5? iecompattest().clientWidth-eventX : window.innerWidth-eventX var bottomedge=ie5? iecompattest().clientHeight-eventY : window.innerHeight-eventY //if the horizontal distance isn't enough to accomodate the width of the context menu if (rightedge<menuobj.contentwidth) //move the horizontal position of the menu to the left by it's width menuobj.style.left=ie5? iecompattest().scrollLeft+eventX-menuobj.contentwidth+"px" : window.pageXOffset+eventX-menuobj.contentwidth+"px" else //position the horizontal position of the menu where the mouse was clicked menuobj.style.left=ie5? iecompattest().scrollLeft+eventX+"px" : window.pageXOffset+eventX+"px" //same concept with the vertical position if (bottomedge<menuobj.contentheight) menuobj.style.top=ie5? iecompattest().scrollTop+eventY-menuobj.contentheight+"px" : window.pageYOffset+eventY-menuobj.contentheight+"px" else menuobj.style.top=ie5? iecompattest().scrollTop+event.clientY+"px" : window.pageYOffset+eventY+"px" menuobj.style.visibility="visible" return false } function contains_ns6(a, b) { //Determines if 1 element in contained in another- by Brainjar.com while (b.parentNode) if ((b = b.parentNode) == a) return true; return false; } function hidemenu(){ if (window.menuobj) menuobj.style.visibility="hidden" } function dynamichide(e){ if (ie5&&!menuobj.contains(e.toElement)) hidemenu() else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget)) hidemenu() } function delayhidemenu(){ delayhide=setTimeout("hidemenu()",100) } function clearhidemenu(){ if (window.delayhide) clearTimeout(delayhide) } if (ie5||ns6) document.onclick=hidemenu </script> <?php $topic_time_posted = date('F j, Y, g:i a', strtotime($topic_info->topic_time_posted)); $topic_url_name = $topic_info->topic_name; $topic_url_name = str_replace(' ', '_', $topic_url_name); echo "<div class=\"forum_row\">"; echo "<div class=\"icon\"><img src=\"images/default_icon.png\" alt=\"thread\" /></div>"; echo "<div class=\"icon2\"><img src=\"images/topic_icon.png\" alt=\"thread\" /></div>"; echo "<a href=\"index.php?forum={$forum_id}&topic={$topic_info->thread_topic_id}\" onMouseover=\"showmenu(event,linkset[0])\" onMouseout=\"delayhidemenu()\">"; that is the code for starting the while loop and is shown up until the part where i use the javascript in the html.
  22. function logout () { //session must be started before anything session_start (); //if we have a valid session if ( $_SESSION['logged_in'] == TRUE ) { //unset the sessions (all of them - array given) unset ( $_SESSION ); //destroy what's left session_destroy (); } //It is safest to set the cookies with a date that has already expired. if ( isset ( $_COOKIE['cookie_id'] ) && isset ( $_COOKIE['authenticate'] ) ) { /** * uncomment the following line if you wish to remove all cookies * (don't forget to comment ore delete the following 2 lines if you decide to use clear_cookies) */ //clear_cookies (); setcookie ( "cookie_id", '', time() - KEEP_LOGGED_IN_FOR, COOKIE_PATH ); setcookie ( "authenticate", '', time() - KEEP_LOGGED_IN_FOR, COOKIE_PATH ); } //========================================================= //ADD YOUR QUERY HERE BEFORE THEY ARE REDIRECTED TO YOUR LOGOUT PAGE. //========================================================= //redirect the user to the default "logout" page header ( "Location: " . REDIRECT_ON_LOGOUT ); }
  23. I have a problem where i am including javascript in a while loop but the id for the link always stays the same. start while loop..... $thread_topic_id = $topic_info->thread_topic_id; <script type="text/javascript"> link[0] = '<a href="index.php?forum=<?php echo $forum_id; ?>&topic=<?php echo $thread_topic_id; ?>">View Topic</a>' </script> the $thread_topic_id variable is always the last record to be displayed. I have 5 records pulled. how would i get it to display the correct id?
  24. Trying to make it simpler: Basically i could create three extra database tables for child forums, child topics and child posts. But i dont want this. It is alot more work and it can get very confusing. What i want is something like an extra column of two in the forum table. Like child_id and forum type. Where child id stays at 0 if its not a child and forum type is 'f'. But if it is a child then child id is the id and forum type is 'c'. Then in the code which displays the topics within the forum i need to display all of the topics but i also need to display the child boards within that forum. So something like: if ($forum_type == 'c') { loop through the records for all child boards with the forum id of the forum } it sounds simple enough but im struggling, especially when i have to work it into my existing code. attached is a copy of topics.php which displays all the topics once someone clicks on a forum. I also added an sql dump of the tables needed to make this page work incase you want to test it. [attachment deleted by admin]
  25. I wil ltry and explain this the best i can so please bare with me if it doesnt come out right first time lol. I am making a forum and as we all know forums have subforums or child boards that are within the forums themselves. Like php freaks has the forum php coding and then a sub forum within it for php regex. Im having trouble coding this though. Anyone have any tips on code and database structure that could help? I was thinking of making three new database tables for child forums, child topics and child posts but im sure there is an easier way. something like a column within the main forum table which defines wether the forum is a child or not. But then how would i link this child forum with the forum that its supposed to be in. Any advice is greatly appreciated. Thanks.
×
×
  • 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.