Jump to content

Ch0cu3r

Staff Alumni
  • Posts

    3,404
  • Joined

  • Last visited

  • Days Won

    55

Posts posted by Ch0cu3r

  1. The contents of the page your want to "password protect" need to go where this line is  <!-- normal page content -->, Example

    <html>
    
    <head> 
    	<title> Basisschool De Regenboog </title>
    			<style>
    img {
    	position: absolute;
    	left: 60%;
    }
    			</style>
    </head>
    	<body>
    			
    		<script>
    
    		</script>	
    <!-- header of your page, up until the content area -->
    <?php if (!isset($_POST["password"]) || $_POST["password"] != "123") { // no password or wrong password ?>
    <form action="" method="post">
    <p>Password: <input type="password" name="password"> <button type="submit">Enter</button></p>
    </form>
    <?php } else { // correct password ?>
    <!-- normal page content -->
    <a href="http:/www.youtube.com"><img src="Plaatjes/youtube.png" /></a>
    <?php } ?>
    <!-- footer of your page -->
    	</body>
    </html>
    

    If the user has not submitted the correct password then the login form will show. Only until the user has entered the correct password (currently 123) then the youtube link will display.

  2.  

     

    However, as soon as I save the page the code automatically changes to:

    <!--?php include("Navbar.php); ?-->

    This must be down to your editor. PHP will not change the source code for no reason. Can you explain how you are editing/saving your .php files?

  3.  

    2) I need to display the file as hyperlink

    Start with using glob to list files in a directory. Outputting each file in HTML anchor tag, in the url for each link pass the filename as a querystring parameter

     

     

    3) Clicking on hyperlink should open the file in the same window

    Use $_GET superglobal variable to get the filename from the querystring. Checking to make sure the file exists. if the file does exist use then usefile_get_contents to output the contents of the file. You may to use header for setting the correct mime type in order for the browser to display the contents of the file properly.

  4.  

     

    I tried having the form post to php but this resets the page which then goes to the customer info tab so im guessing this will have to be done with

    jquery and ajax.

    Doesn't have to be. 

     

    If the the form is submitting to itself then in the forms action add a hash, eg

    <form action="#invoice" method="post">
    ... form ields ...
    </form>
    

    When the page loads, in javascript use  window.location.hash  to get the hash value, it it is equal to #invoice then have the invoice tab be the active tab rather than the customer tab. Judging by your screenshot you are possibly using Bootstrap tabs component? Looking at the documentation you should be able to call the .show() method on your invoice tab to set as active, eg

    if(window.location.hash == '#ivoice') {
        $('#invoiceTabIdHere').tab('show'); // should make the invoice tab active
    } 
  5. First you need to use the following xpath query.

    $rows = $xpath->query('//table[@id="r"]/tbody[@class="table-text"]/tr');
    

    As your HTML table is not syntax formatted then the following lines will no longer work.

        // explode on each newline character in nodeValue (note the HTML tags are stripped out, leaving just the text inside the td tags)
        // and merge with the $defaults array
        $values = array_replace($defaults, explode("\n", trim($row->nodeValue)));
        // remove any whitespace before or after each value
        $values = array_map('trim', $values); 

    Instead replace them with the following

        // get the values for the child "td" tags in the row
        $values = getChildNodeValues($row->childNodes, 'td');
    

    And add the following function before the foreach loop

    function getChildNodeValues(&$nodeList, $nodeName)
    {
        $values = array();
        foreach($nodeList as $node)
        {
            if($node->nodeName == $nodeName)
                $values[] = trim($node->nodeValue);
        }
    
        return $values;
    }
    
    • Like 1
  6. Hello, Welcome to PHPFreaks please note  the PHP Help forum is for getting help with PHP code not CSS, we have a dedicate forum section for this. I have moved the topic for you.

     

     

    I am having trouble trying to change the height of a container. I want to shrink the whole thing down.

    It would be helpful if you could post your HTML (or link to your webpage). What do you mean by "I want to shrink the whole thing down"?

  7. Rather than use regex to try to and parse the HTML table to find your values, instead use DOMXpath to get the data inside the table

    $html = <<<HTML
    <table>
    <tr class="row-border-top marked-row">
      <td>13 Dec 15, Sun</td>
      <td>OFF(Z)</td>
      <td>DOZ</td>
      <td>:    </td>
      <td>:    </td>
      <td></td>
    </tr>
    <tr class="row-border-top marked-row">  
      <td>12 Dec 15, Sat</td>
      <td>B/HOL(Z)</td>
      <td>DOZ</td>
      <td>:    </td>
      <td>:    </td>
      <td></td>
    </tr>
    <tr class="marked-row">
      <td>8 Dec 15, Tue</td>
      <td>3329</td>
      <td>RZS</td>  
      <td>17:20</td>
      <td>21:55</td>
      <td>DOZ</td>
    </tr>
    </table>
    HTML;
    
    
    $doc = new DOMDocument();
    $doc->loadHTML($html);
    
    $xpath = new DOMXPath($doc);
    // use xpath to find all <tr> tags that has the class "marked-row"
    $rows = $xpath->query('//tr[contains(@class,"marked-row")]');
    
    // fill an array with 6 empty values
    $defaults = array_fill(0, 6, '');
    
    // loop over each row found by xpath
    foreach($rows as $row)
    {
        // explode on each newline character in nodeValue (note the HTML tags are stripped out, leaving just the text inside the td tags)
        // and merge with the $defaults array
        $values = array_replace($defaults, explode("\n", trim($row->nodeValue)));
        // remove any whitespace before or after each value
        $values = array_map('trim', $values);
    
        // use dateTime to parse the date
        $dt = new DateTime($values[0]);
    
        // convert date to d/m/Y format
        $date = $dt->format('d/m/Y');
    
        // using the same dateTime object to convert the date to Y/m/d format
        $sectordate = $dt->format('Y/m/d');
    
        // set rest of values 
        $duty = $values[1];
        $dep = $values[2];
        $begin = $values[3];
        $end = $values[4];
        $arr = $values[5];
    
        // insert values into database here
    }
    
    • Like 2
  8. Yes, default is set to not expire

     

    You can set your own session settings using the php.ini or using ini_set. The following page outlines all the runtime settings for sessions

    http://php.net/manual/en/session.configuration.php

     

    You will need do this before calling session_start()

     

     

    Is session_start() written at top of php scripts or ini_set() function?

    session_start() is a function, which you must call at the of all pages that uses sessions.

  9. If you dont want to rotate the text then you will have to resort to using line breaks after every character

    <p>
      H<br />e<br />l<br />l<br />o
    </p>
    

    Or write each character on its own line and apply  white-space: pre  

    <style>
    .vert-text {
        white-space: pre;
    }
    </style>
    
    <p class="vert-text">H
    e
    l
    l
    o</p>
  10.  

    How would I get access to the pgp.ini file though if I'm having my files run by a hosting company? Wouldn't / shouldn't these setting then already have been applied?

    You wouldn't need to do that, your webhost will have everything setup for you. Unless you have dedicated hosting.

  11. That error is caused because have a variable scope issue.

     

    You are trying to bind $path to the :image_path placeholder. Problem is $path is defined inside the resize() function. Functions have their own variable scope. Meaning variables defined inside them are not accessible outside of them, unless you define them as global - WHICH YOU SHOULD NOT DO

     

    The resize function is returning the path for thumbnail it has created. You would need to execute the prepared statement inside the foreach loop if you want to store the path for each thumbnail being created. Each thumbnail will be inserted as a new row.

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