PHP - Include A Forum In Your Template..
Hi!! I have create a template with a menu bar in the top of it. Now i want to install i forum board but i prefer this forum to belong in the template i create.. When you visit the forum board to be able to see the top menu bar..
Something like with this site.. As you can see we have access with the top menu bar in Home , Forums , Chat , Help ... and so on.. How can i do something like this ? Thanks! Similar TutorialsCode: [Select] $query = mysql_query("SELECT DISTINCT subtype FROM business WHERE type ='Restaurant' ORDER BY name"); echo mysql_error(); while($ntx=mysql_fetch_row($query)) $nt[] = $ntx[0]; $i = -1; foreach($nt as $value) {$i++; echo "<a href='" . str_replace(' ','_',$nt[$i]) . ".html'>" . $nt[$i] . "</a>" . "<br/>"; $FileName = str_replace(' ','_',$nt[$i]) . ".html"; $FileHandle = fopen($FileName, 'w') or die("cant open file");} fclose($FileHandle); ?> When a page is opened using fopen i would like the file menu.php to be written to the file created. To do this would I need to do somthing like; Code: [Select] $FileHandle = fopen($FileName, 'w', include ("menu.php")) or die("cant open file");} Im not sure about the correct use of syntax here. Any ideas? Before, if I wanted to send a welcome letter when a user registers i'd do this. $body = "<inserted html code>"; mail('email@email.com', 'Subject', $body, $headers); Now that I am advancing in PHP, I was trying a different method, because when I did the above method, I would have to take all the HTML out of the variable to change something, like an image link, etc... I have tried doing another method, where I can actually leave all the HTML code in a separate file, so that I can easily edit it, and tried 3 things... This one works, but it doesn't pass variables: $body = file_get_contents("emailTemplate.inc.php"); mail('email@email.com', 'Subject', $body, $headers); When I do this one, the page actually just shows on the current page (naturally): $body = include("emailTemplate.inc.php"); mail('email@email.com', 'Subject', $body, $headers); Of course, this has the same effect as the include function: $body = require("emailTemplate.inc.php"); mail('email@email.com', 'Subject', $body, $headers); So my question is, how do I send a formatted HTML email, and pass variables to it, so I can personalize it by the persons name, etc, without adding the HTML to a variable, and so that I can easily update the page whenever I want, and without taking it out of the variable, and sticking back in the edited code? Any help would be appreciated! I would also like to say that I am using this code for the $headers variable too: $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: from@email.com <email@email.com>' . "\r\n"; Thank you in advanced! Hi Guys.. Merry Christmas Im kinda new to this fantastic world of PHP and i have a little problem i hope you can help me with. Im trying to build a website where I use include() to genereate my content. On my index.php i have a menu which includes content in a content div from external .php pages, my structure kinda goes like this.. (simplified) site/ index.php content/ fronpage.php products.php contact.php The HTML looks like this. <div id="menu"> <ul> <li><a href="index.php?page=frontpage">frontpage</a></li> <li><a href="index.php?page=products">frontpage</a></li> <li><a href="index.php?page=contact">frontpage</a></li> </ul> </div <div id="main"> <?php include('/content/'.$_GET['page'].'.php'); ?> </div> This all works very fine, but my problem is, can I have a include inside an already included page? I would like to have a menu on my products.php site, but that page is already included from above, and i would like the menu on the products.php site to stay as the content from the nested include changes with input from the /products folder. my idea was something like this. site/ index.php content/ frontpage.php products.php contact.php products/ product1.php product2.php the HTML on the index.php is the same as above and then i would add the include() on the products.php page, so its kinda the same thing, but one inside the other. HTML inside the products.php folder <div id="sub_menu"> <ul> <li><a href="#">frontpage</a></li> <li><a href="#">frontpage</a></li> <li><a href="#">frontpage</a></li> </ul> </div <div id="sub_main"> <?php include('/content/products'.$_GET['#'].'.php'); ?> </div> I dont know how to link to the new files so they will be included while the first include still stays on the page. Any of you know how and if this can be done? Or maybe at better way to do it? Hope this made sense, my first PHP question Thanks CanI put one INCLUDE statement INSIDE of another INCLUDE statement? Hi Still a new comer when it comes to PHP. I have a situation where I want to use an include within an include and I am having trouble with my file paths. My main header include, includes everything for each page of my site, beyond the opening of the body to incorporate my navigation etc conditionally loading in css, and loading in titles and meta data etc depending on the page in question. This header needs to reference another include called the-pod.php which is required for every page, the only trouble is I want to use / to reference the root of the server and this is breaking my code. I can't use ../../ etc as its a different path depending on where the master file is located. So my question is how do I get around this? Can the root of the server or path to the root be stored in a variable? and if so how would I write this. Any tips / advice will be greatly appreciated. When I put this above all else in my document and test it offline, all I see is code in the browser. But when I test it on my web server, I can view the markup and whatnot. Does anyone know why this is? Okay I am making a forum and it is almost finished. The only thing is, I am stuck on how to get the most updated topics to appear at the top of the list. Like on every forum there is a new forum post that you havent visited yet. They are at the top of the list. How would I do that??? Hello all,
I am working on my own PHP project where I can build myself my own forum just like how this site functions.
I would like to have user accounts and when you log in have a list of bulletin topics that you can choose from and then post your own question or topic and then other users can go to your post and write answers to it. I know there are many forums out there that you can make and set up to use but I would like to have my own so I can customize it any way I want.
Could I get some ideas on where I should start with this. I have been working on a website with a login functionality and I almost have that set up, then my next steps will be making it so users will be able to post topics.
I been doing google research trying to get some tutorials on this but I haven’t found one that is much help. I will be using phpmyadmin database and I plan on writing my sql as mysqli.
Thank you.
Hello everybody, am a bit new here. My question is, if I am on the right place here? I feel like been in the wrong place. Am looking for some forum where I can ask or find about "General questions" I have about PHP sometimes. Am not sure, if I am on the right "Forum" or if this is the "right category" Thank u! I need to figure out how to give this input a name so when i submit it i can get the data from it.
<!doctype html> <html> <head> <meta charset="utf-8"> <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/ui-lightness/jquery-ui.css" type="text/css" rel="stylesheet"/> <style> input{font-size:1.3em;} #log{position: absolute; top: 10px; right: 10px;} span{color:blue; text-decoration: underline; cursor: pointer;} </style> </head> <body> <div id="inputs"></div> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js" type="text/javascript"></script> <script src="jquery.googleSuggest.js" type="text/javascript"></script> <script> $.each("web".split(" "), function(i, v){ var div = $("<div>").appendTo("#inputs") , input = $("<input>").appendTo(div) , span = $("<label>").text(v).appendTo(div); input.googleSuggest({ service: v }); }); </script> </body> </html> Site Name: Forum Pioneer Link to site: http://forumpioneer.com/ (Down Currently) Positions Available: 2 Admin Super and Normal Moderators phpBB Support Team MyBB Support Team IPB Support Team vBulletin Support Team XenForo Support Team Forum Pioneer is a resource site and webmasters central for forum software. I intend for it to be a collection of the best and the most useful modifications that forum owners need. Pm me for more info. We are currently on phpBB, but I intend to migrate to IPB when the forum gets bigger. here is my code which is supposed to return all forums from the database and then display them in their respective categories. however it only shows one of the forums and not all of them. Anyone know why? function display_forum_list($crumbs) { global $link, $template, $settings, $lang, $config, $user; $template->replace( array( '{CRUMBS}' => display_crumbs($crumbs) ), 'index_page'); $query = $link->query("SELECT * FROM ".TBL_PREFIX."forums ORDER BY f_lid ASC"); $result = $query->fetchAll(); foreach($result as $key => $val) { if($result[$key]['f_pid'] == 0) { $cat_name = $result[$key]['f_name']; } else { $forum_name = $result[$key]['f_name']; } $forum_desc = $result[$key]['f_description']; } $template->replace( array( '{CATEGORY}' => $cat_name, '{F_ICON}' => '', '{F_NAME}' => $forum_name, '{F_DESC}' => $forum_desc, '{SITE_ROOT}' => $config['asf_root'] ), 'forum_list'); } Hello! My problem is that in my forum I want to display the picutre of their user and if they do not have a picture I want to show the standard one. I got all of this working on another part of the page but for some reason I can only get it to display the standard picture and not their custom picture... The code looks like this: Code: [Select] <?php // Now query any responses out of the database and place in a dynamic list $sqll = mysql_query("SELECT id FROM myMembers"); while($row = mysql_fetch_array($sqll)){ $id = $row["id"]; $check_pic = "..//members/$id/image01.jpg"; $default_pic = "..//members/0/image01.jpg"; if (file_exists($check_pic)) { $user_pic = "<img src=\"$check_pic\" align=\"left\" width=\"80px\" border=\"0\" />"; // forces picture to be 120px wide and no more } else { $user_pic = "<img src=\"$default_pic\" align=\"left\" width=\"80px\" border=\"0\" />"; // forces default picture to be 120px wide and no more } } $all_responses = ""; $sql = mysql_query("SELECT * FROM forum_posts WHERE otid='$thread_id' AND type='b'"); $numRows = mysql_num_rows($sql); if ($numRows < 1) { $all_responses = '<div id="none_yet_div">No respond has been posted yet.</div>'; } else { while($row = mysql_fetch_array($sql)){ $reply_author = $row["post_author"]; $reply_author_id = $row["post_author_id"]; $date_n_time = $row["date_time"]; $convertedTime = ($myAgoObject -> convert_datetime($date_n_time)); $whenReply = ($myAgoObject -> makeAgo($convertedTime)); $reply_body = $row["post_body"]; $all_responses .= '<div class="response_top_div"> ' . $thread_title . ' | ' . $whenReply . ' <a href="../profile.php?id=' . $reply_author_id . '">' . $reply_author . '</a> said:</div> <div class="response_div" style="padding-left:20px; vertical-align:text-top;">' . $user_pic . ' <div style="padding-left:117px;"> ' . $reply_body . '</div></div>'; } } ?> Please help me if you can! Thank you! Is it just me or is anyone else having problems with the site? When I make a reply to a post and submit it, my post is added but it also appears as an edit window still below my just-posted post. Also - when I try and edit my post the edit window opens up but the text of my post flashes by and does not show. If I re-type the entire post with my edits and save it, the edits do not appear. This has been happening for 3-4 days now. Edited by ginerjm, 30 December 2014 - 01:33 PM. Hi can anyone help this is my forum reply code: <?php include "connect.php"; // Get value of id that sent from hidden field $id=$_POST['id']; // Find highest answer number. $sql="SELECT MAX(a_id) AS Maxa_id FROM reply WHERE question_id='$id'"; $result=mysql_query($sql); $rows=mysql_fetch_array($result); // add + 1 to highest answer number and keep it in variable name "$Max_id". if there no answer yet set it = 1 if ($rows) { $Max_id = $rows['Maxa_id']+1; } else { $Max_id = 1; } // get values that sent from form $a_name=$_POST['a_username']; $a_answer=$_POST['a_reply']; // Insert answer $sql2="INSERT INTO reply(question_id, a_id, a_username, a_reply, a_date, a_time)VALUES('$id', '$Max_id', '$a_username', '$a_reply', CURDATE(), CURTIME())"; $result2=mysql_query($sql2); if($result2){ echo "Successful<BR>"; echo "<a href='viewtopic.php?id=".$id."'>View your answer</a>"; // If added new answer, add value +1 in reply column $sql3="UPDATE topic SET reply='$Max_id' WHERE id='$id'"; $result3=mysql_query($sql3); } else { echo "ERROR"; } mysql_close(); ?> and this is the error message anyone know why it gives this Thanks Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fightwa1/public_html/addreply.php on line 10 please help Hey so I've been designing a custom forum script and I need help. I'm trying to create a breadcrumb that takes into account page title. My pages have an id, so for example: threadlist.php?id=1, viewthread.php?id=3 and so on. I used a tutorial to get started.This is what I have so far. This portion is in header.php to get session: $url =BASE_URL; $_SESSION['history'][$title] = $url; while(count($_SESSION['history']) > 4) array_shift($_SESSION['history']);
breadcrumbs.php <div class="container pagination"> <nav aria-label="breadcrumb"> <ol class="breadcrumb"> <?php foreach($_SESSION['history'] as $title => $url) { echo "<li class='breadcrumb-item'><a href=". $url .">". $title ."</a></li>"; } ?> </ol> </nav> </div> It works decently well. Only problem is, when I go back to the homepage, or backwards, it doesn't remove the breadcrumb. Also, I can't click on the breadcrumb because the url isn't set up right. I know I have it set to BASE_URL buts that's only cause I can't figure out how to grab the url which would be different for every section of the site I'm on. Hi, I am implementing a forum in php and mysql. I want to close forum questions / posts automatically after four days of posting. How to implement this ? Please help me. Thanks in advance. Just a general question, but could someone help me and tell me how to allow the user to enter a <br> without actually typing it. Like when they're typing in the forums, I want it to automatically go on a new line when they hit the ENTER key. Or could someone lead me to a guide? I tried searching everywhere and just can't seem to find it. we have a hacker on my forum using -1424 values as inputs how do i block and make sure the input is not anything negative? |