Jump to content

PrinceTaz

Members
  • Posts

    63
  • Joined

  • Last visited

Posts posted by PrinceTaz

  1. Hi there, I'm looking to get a script developed and I wanna know if I should get it developed with Wordpress or custom. What would be the pros and cons of each besides cost?

    [link]

    That is the link to the proposal. The website is going to be similar to ggboost.com

  2. 8 hours ago, requinix said:

    Sessions are for sharing data between pages. This does not involve sharing data between pages. Sessions are not appropriate.

    Don't get ahead of yourself. You're imagining stuff that does not need to exist. Breadcrumbs for a user CP page? You don't need anything "universal" to do that. It's Forum -> User CP. That's it. There's nothing fancy there: just a link, an arrow, and some text. You can write exactly that on your page.

    Breadcrumbs for things like threads and lists are potentially trickier because you don't always know the hierarchy. Threads are in subforums, but what are subforums in? Other subforums? You don't have that information ahead of time.

    Don't bother with anything universal. You don't need it. Just get breadcrumbs on thread pages working.

    I'll do that, thank you!

  3. 24 minutes ago, requinix said:

    It's fine, don't mind it.

    Sounds like the breadcrumbs for thread #3 would be: Name of your site or Forums or something > Whatever the name of the parent thread list #1 is > The title of thread #3.

    If thread list #1 was contained inside another list then it would go: Name of the site or whatever > Name of the grandparent thread list > Name of the parent thread list #1 > Title of the thread #3.

    Would sessions be best for the job? Because also I want this to be a universal breadcrumb. So lets say I go to usercp, it would be Forum-> usercp. Would it be smart to use a conditional statement for when im browsing through threads and / or other website features i:e, memberlist or something. 

  4. 3 hours ago, requinix said:

    Ah, okay, wrong "folders". Forget those. And don't mind what the URL looks like. But the link could be useful.

    You've got a topic #3. Does it belong in a forum? What is it part of? That thing is going to be part of the breadcrumb.

    Can you combine this post with the one up there?

  5. So topic 3 is viewthread?id=3 which is part of the threadlist for id=1 which is part of the forum (home page). Reply would be part of viewthread which is part of threadlist which is part of the forum. 

  6. 7 minutes ago, requinix said:

    I think you have your cause and effect backwards. You shouldn't be starting with "I want breadcrumbs" and then deciding "I should make folders for it". You need to consider whether you want folders in the first place.

    Given that you're working with some kind of forum thing, you probably do.

    Get those folders up and working first, add breadcrumbs to your pages second.

    Okay so the forum is already pretty built and operating. If you want a link for reference, I can provide it. 

    I do have a folder structure but very basic, admin, includes, styles. It's just I'm having a hard time understanding the logic that goes behind making breadcrumbs made for a forum. I've seen other tutorials but they use folders for the url whereas I use "id=". For example, here its "topic/311379-php-breadcrumbs-for-forum". Mine would simply be, viewtopic?id=3. 

  7. 6 hours ago, requinix said:

    Your breadcrumb is based on browsing history. Are you sure that's what you want? Because I really doubt it is. And if it is then you should really reconsider because that's not how they're supposed to work.

    Unlike the kind you hear about in stories, page breadcrumbs are not history but about location. For example, look at the breadcrumbs for this page (just above the page header): this page is located in PHP Coding Help, which is a subforum of PHP Coding, which is one of the main categories for the whole site.

    I see, when you put it that way, I've been thinking about it all wrong the whole time. 

    I want it to work exactly how this breadcrumbs on this forum does. So you're saying I should set up some sort of hierarchical system for the folders?

  8. 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. 

  9. 8 hours ago, requinix said:

    Not sure I would call a registration and login system less complex than threads and posts, but I guess it depends...

    I suggest you take a look at MariaDB's knowledge base section on database theory.

    Well only reason its less complicated to me is simply because I've done it so many times :P. I'll take a look at that.

     

    So my other idea was to create a tuple relating to each individual table. For example, for each forum, create a forum_cat attribute to define which category it belongs to. Same with topics/replies. 

  10. 18 minutes ago, requinix said:

    Do you have already have a concept of posts inside threads? How did you manage that?

    I don't yet, I created the least complex stuff first. Like dynamically displaying forum and category names, registration/login system. 

  11. Hey there, so as a personal project, I've been working on creating a forum software. You can check out what I have so far here: https://www.taziamoma.com/Forum/index.php

    What I'm currently having trouble with right now is connecting a Category with a forum with the threads inside of it. For example, I have a Category that has 3 forums attached to it. How do I link that in the database and how do I indicate which threads belongs to which forums?

  12. On 6/6/2019 at 8:50 PM, kicken said:

    It's possible for $_SERVER['DOCUMENT_ROOT'] to not be what you expect, but unlikely.   Any issue with it would likely be due to a server configuration issue rather than an attempted attack most likely.

    dirname(__FILE__) can be replace by __DIR__ since 5.3.

    @PrinceTaz, create yourself a single file such as common.php that you can include into all your pages.  That file can then take care of setting up your environment for your scripts such as setting the include path, defining the path to your files, etc.  For example:

    
    <?php
    
    set_include_path(__DIR__.'/templates');
    
    function render($__template, $__vars){
        extract($__vars);
        require 'header.tpl';
        require $__template;
        require 'footer.tpl';
    };

    Then in your individual page files you can use __DIR__ to build a path to that common file and include it.   With the include path then configured, everything else can be included with a simple relative path.   Given a directory tree then such as:

    
    |   common.php
    |
    +---public_html
    |       about.php
    |       index.php
    |
    \---templates
        |   footer.tpl
        |   header.tpl
        |
        +---about
        |       index.tpl
        |
        \---home
                index.tpl

    Then your index.php page could be:

    
    <?php
    
    require __DIR__.'/../common.php';
    
    render('home/index.tpl', ['PageTitle' => 'Home']);

    And about.php page could be:

    
    <?php
    
    require __DIR__.'/../common.php';
    
    render('about/index.tpl', ['PageTitle' => 'About me']);

     

    What if I'm including from multiple directories? Such as includes and templates? Also can you explain what the "render" function is doing?

  13. Also i want to know this. 

    So I made a template file called viewthread_layout.php. Now I want to create the logic file, viewthread.php that is actually going to run everything. How do I link the two? I want to include the viewthread_layout.php inside viewthread.php because when they click the thread, the url will be /viewthread.php but in layout.php, the content will depend on the scripts in viewthread.php. How do I link each other?

  14. 4 hours ago, cyberRobot said:

    I should mention that you'll need to use something like $_SERVER['DOCUMENT_ROOT'] to reference the root value when importing code with things like "require" and "include". For example

    
    require "{$_SERVER['DOCUMENT_ROOT']}/style/navbar.php";

    Without the $_SERVER variable, you'll get an error. Also, I just tried using an absolute link (e.g. https://www.yourdomain.com/style/navbar.php). Apparently, my server is configured to disallow URLs within things like "require" and "include". I don't know if that's a common configuration, but it's something to be aware of.

    Also, I've read a number of recommendations saying that PHP code should be stored outside of the root. Of course, that's not possible for all PHP since something needs to import the code into your web pages. However, code like your includes seem like perfect candidates for things to store outside the root. I don't know if it's possible to point absolute paths to something outside the root. I know that root-relative links can. In case you're interested, here's one explanation for storing PHP scripts outside the root.
    https://www.php.net/manual/en/security.php#33627

    Here is my code: 

    <?php
    define("BASE_URL", "/Forum");
    define("ROOT_PATH", $_SERVER["DOCUMENT_ROOT"] . "/Forum/");

    But when I use BASE_URL, it doesn't work properly when including things from "includes" and I have to use ROOT_PATH. But when I'm including things in paratheses such as in tags, only BASE_URL works. I don't understand why that works.

  15. Okay so I just finished designing a template and I want to begin coding but I want to separate the logic from the template as per suggestions I've received. Now I have the separate files that are ready to be included, but how can I include it so that it updates globally. What I mean is this for example.

    In my header.php, I have included "style/navbar.php". Now from the root directory that's fine. The problem comes when let's say I'm working inside viewpost.php that is actually inside /style and that file includes header.php which includes style/navbar.php. So now viewpost is looking for style/style.php. How do I make php know where the include files are globally and update that directory for each query? I hope I explained this properly.

  16. 51 minutes ago, requinix said:

    Okay, good, I thought the blue border was weird.

    Personally I wouldn't set a height directly on the row. What if the child is taller than expected? If you can rely on the child (er, children) being a certain height then that percentage height on the row can be just as easily converted to a percentage padding-top and -bottom. Which will get you centering.

    So I should just do it manually using padding percentages? On the blue box to center it?

    https://taziamoma.com/Forum/

    That is where it's uploaded.

  17. 30 minutes ago, requinix said:

    That may be, but when I look at your screenshot I see two blue boxes with empty space below them. That means the parent is too tall, perhaps being forced by margins or padding or a tall descendant element, but tall nonetheless.

    Centering the blue box inside the row will create half the space above and below it, which IMO is going to look a bit odd.

    Ah okay I see what you mean. So the blue border was only added so I could show you guys what needed to be centered, it won't be there for the live copy. Once the blue box is centered inside the white parent box, I'll vertically center the content inside the blue box as well. The gray parent box below it will act the same way, the only difference is the shading of the parent background. Essentially, it's a forum layout. 

  18. 1 hour ago, maxxd said:

    Not as it is now - if you want to tell the user which is taken you'll have to update the query. Right now it just returns a count of records that match either the username or the email. You'll have to actually select both and then check in PHP which one matches, or rewrite the query to return the offending column.

    However, I'd recommend just letting people know that one of the two has been taken. That way you're not confirming to an outside party which of the two actually exists in the database - a hacker that knows for a fact a username exists has less work to do and can focus only on figuring out a correct password.

    Wow, I never thought of it like that. I've always wondered why big websites don't have that feature, I always thought it was because it would be too complicated to attempt.

  19. 8 hours ago, kicken said:

    Your editor probably has a setting to control how wide a tab is displayed as.  That's one of the arguments in the tabs vs spaces debate when it comes to indenting code.  Maybe your editor displays a tab as 2 or 4 spaces so it looks reasonable but here in the browser it's shown very wide, making it annoying because it doesn't take long for half the line to be empty space.

    You'll have to decide for your self if you prefer tabs or spaces, just be consistent and configure your editor appropriately.  Many coding editors have a tab-inserts-spaces option so you can still hit tab to indent but it'll insert space characters rather than a tab character.

    A view is a template essentially, just another name for it.  You'd move the HTML out of your main code file into it's own file.  Limit the PHP usage in your html files to simple echo/conditional/loop statements.

    Do all your typical logic and processing code in your main PHP file and assign variables as needed for your template, then require whichever template is needed for that branch of code.

    Your common header/footer html can be in separate files then either required in from either your php code or as part of your template file.

    Ah okay thank you! Now would it be smart to move the middle area to another file as well? Like header, middle content, and then footer? Then index.php would just be three include files?

  20. 9 hours ago, requinix said:

    Isn't that just a complicated way of saying that the parent row is too tall?

    Well the blue box would be the child and the white is the parent. Now the parent is inside a container which needs to auto increase in height depending on how many of the parent loop through it.

  21. So I'm posting this in CSS because I think I'm having a CSS issue. Basically, I have this right now:

    777579609_ScreenShot2019-06-02at7_26_47PM.thumb.png.e5cfe663b68216886f0b2a1e86ba6301.png

    I'm trying to vertically center the blue box and everything inside it. I've tried line-height, vertical-align, display: inline-block, position relative and absolute. The only way that works is if I do it manually with absolute or margin. But absolute isn't responsive so that's a problem. I'm using Bootstrap from the CDN if that matters. I'm only going to include code for the first box so that it doesn't get messy. 

    HTML:

    <div class="container category-forums clearfix">
      <div class="container category-forums-wrap">
        <div class="container category-icon clearfix"></div>
        <div class="container forum-details-wrapper clearfix">
          <div class="container forum-details-container">
            <p class="forum-name">News Center</p>
            <p class="forum-desc">Stay up to date with all the latest news and, more importantly, familiarize yourself with the rules.</p>
    
            <div class="sub-forum-container container clearfix">
              <p class="sub-forums clearfix">Sub-Category 1</p>
              <p class="sub-forums clearfix">Sub-Category 2</p>
              <p class="sub-forums clearfix">Sub-Category 3</p>
            </div>
          </div>
    
        </div>
    
        <div class="container forum-threads clearfix">
          <h4>108</h4>
          <p>Threads</p>
        </div>
        
        <div class="container forum-posts clearfix">
          <h4>2000</h4>
          <p>Posts</p>
        </div>
        
        <div class="container forum-latest-posts clearfix">
          <div class="container last-avatar clearfix"></div>
          <p>Lastest thread</p>
          <p>Yesterday 3:15pm</p>
          
        </div>
      </div>
    </div>

    CSS:

    .category-forums {
    	width: 100%;
    	height: 41%;
    	background-color: #ecf0f1;
    	padding: 0;
    	border-bottom-left-radius:.25rem!important;
    	border-bottom-right-radius:.25rem!important;
    }
    .category-icon {
    	width: 7%;
    	height: 100%;
    	border-right: 1px dotted lightgray;
    	margin: 0;
    	float: left;
    	line-height: 100%;
    }
    .category-forums-wrap {
    	height: 70%;
    	width: 100%;
    	border: 1px dotted blue;
    	padding: 0;
    	display: inline-block;
    	vertical-align: middle;
    }
    .forum-details-wrapper {
    	width: 55%;
    	height: 100%;
    	border-right: 1px dotted lightgray;
    	margin: 0;
    	float: left;
    	padding: 0;
    
    }
    .forum-details-container {
    	width: 100%;
    	height: 100%;
    	border: 1px dotted gray;
    	margin: 0;
    }
    .forum-name {
    	margin: 0;
    }
    .sub-forum-container {
    	width: 100%;
    	float: left;
    	margin: 0;
    }
    .sub-forums {
    	width: 31%;
    	margin: 0;
    	float: left;
    }
    .forum-desc {
    	margin: 0;
    	font-size: 1.3rem;
    }
    .forum-threads {
    	width: 9%;
    	height: 100%;
    	border-right: 1px dotted lightgray;
    	float: left;
    	text-align: center;
    	line-height: 100%;
    }
    .forum-posts {
    	width: 9%;
    	height: 100%;
    	border-right: 1px dotted lightgray;
    	float: left;
    	line-height: 100%;
    
    }
    .forum-latest-posts {
    	width: 20%;
    	height: 100%;
    	float: left;
    }
    .last-avatar {
    	width: 25%;
    	height: 100%;
    	border-right: 1px dotted lightgray;
    	float: left;
    	text-align: center;
    	line-height: 100%;
    }

    I'm having a tough time even centering the text vertically. 

  22. On 6/1/2019 at 7:00 PM, requinix said:

    Do you know what maxxd's code is? Can you describe what it does?

     

    18 hours ago, gizmola said:

    The point is, that Maxxd's query does exactly what you are asking for.  It checks if a particular row has a matching username OR a matching email.  

     

    A better question would have been, do I create an elseif but with "$row[''email"] > 0"?

  23. 20 hours ago, benanamen said:

    "Variable for nothing"

    
    $task = $_POST['task'];

    There is no change or transformation of the data. The $task variable is for nothing. You already have the POST variable, just use it.

     

    "Internal System Error"

    
    echo $sql. "<br>". $e->getMessage();

    That info is completely useless to the user unless they are a hacker.

     

    Okay awesome, thank you!
     

    18 hours ago, gizmola said:

    Benanamen had good coverage already.  I'm repeating a few of his points I'm sure.  For a first project, it is not bad.  You are doing some good things including the use of prepared statements, although you neglected to use them for your insert.  Be consistent!  All SQL DML (insert, update, delete) should use prepared statements, and in most cases so should your select.  Always treat user input as suspect.

    I posted in your other thread, so I'm repeating myself now----

    Why are you using ob_start()?  That is an advanced feature that is not warranted here, nor appropriate.  Remove ob_start().

    Use require_once() not include_once().  Look at what the functions do.  Ask yourself this question:  Does my script REQUIRE  connection.php to work, or would it be ok if it wasn't loaded?   It's pretty clear here that you need the script to be loaded for anything to work, so you should require it.  I never use include_once, nor should you.  

    Again repeating myself, remove the closing php tag from connection.php.

    Standard indentation would be 4 spaces.  You are indenting like 8 spaces --- it's crazy ?

    The next thing I'd suggest would be to move all the markup into separate files that you include.  This would start you towards templates/views.  This is essentially the idea behind "separation of logic and presentation".  

    Again for a first project, you are doing great.  I've seen some "professional" projects where the code wasn't as good.  Nice work, and continue to ask for clarifications when you aren't clear about the advice being given.

     

     

    Okay I'll keep that in mind. I'll switch to require_once(). Also, by separation of files, you're referring to moving things like the header html to a separate file and just including it? Or should I require it? I understand "templates" but what do you mean by views? Also, I normally indent to know what is nested into each other and I normally just press the tab key. Should I just use the space bar or just not indent as much?

    I appreciate you for your honesty and your criticism :D

  24. 1 hour ago, benanamen said:

    There are a few things. From the top down..

    $errors should be an array.
    You need to check the REQUEST METHOD, not the name of a button.
    You need to use Prepared Statements
    You need to kill the script after header redirects
    Do not output internal system errors to the user
    Do not create variables for nothing
     

     

    What do you mean by outputing internal system errors? Also what do you mean by creating variables for nothing.

    10 minutes ago, mac_gyver said:

    your INSERT query is open to sql injection. anyone can cause that query to insert data from any of your database tables, especially since you are using the 'root' user, and the rest of your code on this page will happily show the content that was just inserted from the other database/tables.

    i recommend that you take this code off of a live/public site until you actually secure it against sql injection, don't use the 'root' user in you applications, create a user that has just the database permissions you need, your delete operation should use a post method form, and in real life data isn't actually deleted, it is updated to indicate it is not in use, in case it ever needs to be recovered.

    The "root" is just dummy data I used when I uploaded. What should I use instead of INSERT? Also, by not deleting the code, how do you manage it being getting so large?

×
×
  • 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.