Jump to content

glassfish

Members
  • Posts

    119
  • Joined

  • Last visited

Posts posted by glassfish

  1. cyberRobot,

     

    The problem I have had with that is that I may have to use "../../" to go "up" with the directories.

     

    And "for some reason" I have had issues with this, when for example including the stylesheet file in the header file and the header file gets included in a sub-directory.

  2. For the includes I use the following:

     include($_SERVER['DOCUMENT_ROOT'] . "/cms/includes/connection.php");
    

    And for these following examples I use "http://localhost/":

    <img class="header_image" src="http://localhost/cms/assets/image/capture.png" />
    <script type="text/javascript" src="http://localhost/cms/jquery/jquery.js"></script>
    <link rel="stylesheet" type="text/css" href="http://localhost/cms/assets/style.css" />
    

    With these examples I use "http://localhost/" because "$_SERVER['DOCUMENT_ROOT']" is not working with these above.

     

    My Question:

    Is there a function I could be using and replace it with "http://localhost/"?

     

    I am looking to have it like following: When I upload the web app onto the web server it still should be working out.

     

     

    EDIT:

     

    "Un-linking" those links which happen did not work.

  3. Well I found a good tutorial series on YouTube out of those multiple ones which are there. And I haven gotten into OOP and bind parameters ("PDO"). And I am quite liking it, it looks like that one is indeed typing less and one has set up a blog ("CRUD") quite quickly. Before that I have had also suspected the less amount of code with OOP, I was not quite sure when it comes to this, I thought maybe the request calls are written a bit shorter and that may be it when it comes to this.

     

    I feel like I could be learning from "full" blog web apps written with OOP and bind parameters, yet I also feel a bit sad about it, that I am not coming across a bunch of scripts on the internet. I will look a bit later on Themeforest for this.

     

    I still would appreciate suggestions on this. I am really looking to know OOP with bind parameters better.

  4. Well, it was said there would be more jobs in programming, and I was wondering "how it may have to look like" when it comes to the skills and when looking to apply for the "Carrers" link.

     

    With "bind parameters" I mean "secure" programming, for example secured of "SQL injection".

     

    Well, after you have said "those", I could be getting into those, I was not necessarily looking to "apply" now.

     

    I was also looking for something "exact".

     

    I also think, that when it comes to getting into those you have had mentioned I may be better off with OOP instead of "continuing" the "procedural style".

  5. I have looked around. And what I came across was not necessarily what I was looking for.

     

    I was wondering if somebody can recommend a good tutorial for building a blog in PHP OOP?

     

    Also, I was wondering if somebody perhaps knows a good blog app written in PHP OOP, where I could be learning from  the script files?

  6.  

    Easiest way would be to move the files outside of your sites root folder. Files outside of the root folder will not be accessible from a URL. This will not prevent PHP from accessing files.

     

    Or place a .htaccess file inside the folders you don't want allow access to with the following

    Deny from all

    Thanks for the answer, I will try that in a minute.

    I will try to have "those" script files inside an "includes" folder.

    Can I just have that "line" you have there inside the ".htaccess" file and nothing else to it?

  7. I have around 14 script files for an admin page.

     

    I am looking to block the access to 10 of them with .htaccess, so they can not get called up through the URL with the web browser, by for example guessing the name.

    <Files index.php>
        Order Allow,Deny
        Allow from all
    </Files>
    

    How to set up, so I can have "those" 10 files in there?

     

    Also, when comes to having an admin page and blocking the access to "those" script files is this the proper way to do it?

     

    I would appreciate the suggestions a lot!

  8. I am looking to use this for an admin panel.

     

    session_start.php

    "session_start()"
    "if statement" where it checks if a successful login is given
    

    Is it necessary to include "session_start.php" into the top of each script file?

     

    If I just include "session_start.php" into the top of the "main" file where the other script files are included inside of the "main" as well, then I have it in ways where the other script files could get called up through the URL.(?)

     

    I thought it is a bit too much to include "session_start.php" into each script file.

     

    Is there a way where this can be done with more simple ways?

     

    I would appreciate the suggestions a lot.

  9. Script:

    <?php
    
        $tqs_admin_flag = "SELECT * FROM `flags`";
        $tqr_admin_flag = mysqli_query($dbc, $tqs_admin_flag) or die(mysqli_error($dbc));
    
    while($row_admin_flag = mysqli_fetch_array($tqr_admin_flag)){
    
            //print_r($row_admin_flag);
    
            $tqs_admin_flag_thread = "SELECT * FROM `thread` WHERE `id` = '" . $row_admin_flag['thread_id'] . "' ORDER BY `date_created` DESC";
            $tqr_admin_flag_thread = mysqli_query($dbc, $tqs_admin_flag_thread) or die(mysqli_error($dbc));
    
        while($row = mysqli_fetch_assoc($tqr_admin_flag_thread)){
    
            include($_SERVER['DOCUMENT_ROOT'] . "/gallerysite/admin_flag_thread.php");
    
    
        }
    }
    
    ?>
    

    This in comparison works:

    $tqs_admin_flag_thread = "SELECT * FROM `thread` ORDER BY `date_created` DESC";
    

    I would appreciate suggestions for which reasons the above script (the way it is) may not work.

     

    With the above script the querying and printing on screen does happen, though the "ordering by DESC" does not happen.

  10. It is used for a SQL update query, if I would not do this check all of the "entries" would get updated in the table (with the "for" loop), even though no modifications have been. Does this clarify?

     

    So basically, "check the checkbox", "modify the entry", and then have only those in the table updated where the modification has been done (where the checkbox is checked).

  11. Script:

    <?php
    
    // For example, the entries in the table.
    $entry1 = "text1";
    $entry2 = "text2";
    $entry3 = "text3";
    
    // For example, the ID numbers in the table.
    $value1 = "140";
    $value2 = "141";
    $value3 = "142";
    
    echo "<form method='POST' action='" . $_SERVER['PHP_SELF'] . "'>";
    echo "<input type='checkbox' name='hashtag_modify_checkbox[]' value='" . $value1 . "' />";
    echo "Modify";
    echo "<input type='text' name='hashtag_name[]' value='" . $entry1 . "' />";
    
    echo "<input type='checkbox' name='hashtag_modify_checkbox[]' value='" . $value2 . "' />";
    echo "Modify";
    echo "<input type='text' name='hashtag_name[]' value='" . $entry2 . "' />";
    
    echo "<input type='checkbox' name='hashtag_modify_checkbox[]' value='" . $value3 . "' />";
    echo "Modify";
    echo "<input type='text' name='hashtag_name[]' value='" . $entry3 . "' />";
    
    echo "<input type='submit' name='submit' />";
    echo "</form>";
    
    
    // Here, only store those hashtag names where the "modify" checkbox is checked.
    
    
    ?>
    

    This is used for the admin panel.

     

    It is a form where the input fields hold the text ("hashtags") already inside of them.

     

    Basically, one would have to check the "modify checkbox" to modify a hashtag, then only the modified hashtags should get stored into an array.

     

    How to have those hashtags stored in the array with the checked checkbox as the factor?

     

    The suggestions are much appreciated.

  12. Addendum:

    <?php
    if(isset($_POST['submit'])){
    
        if(isset($_POST['hashtag'])){
            $hashtags = $_POST['hashtag'];
        }
    
        print_r($hashtags);
    }
    
    ?>
    

    Both, "isset" and "!empty" is printing the following:

     

    I would appreciate suggestions on this one:

    Array ( [0] => test [1] => test [2] => test [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => )
     
    

    Note:

    With this I am using "hashtag[]" in the form.

  13. Addendum:

    Okey I have tried it with this.

    <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <?php
            for($i = 0; $i < 12; $i++){
               echo "<input type='text' name='hashtag" . $i . "' />";
            }
        ?>
        <input type="submit" name="submit" />
    </form>
    
    <?php
    
    if(isset($_POST['submit'])){
    
        $hashtags = array();
        for($i = 0; $i < 12; $i++) {
    
            if(!empty($_POST["hashtag$i"])){
                $hashtags[] = $_POST["hashtag$i"];
            }
    
        }
    
        print_r($hashtags);
    
    }
    ?>
    

    This works.

     

    Though, I have to specifically use "!empty", any reasons why?

     

    If I use "isset" I get this:

    Array ( [0] => test [1] => test [2] => [3] => [4] => [5] => [6] => [7] => [8] => [9] => [10] => [11] => ) 
    

    Thanks for the answer!

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