Jump to content

kney

Members
  • Posts

    140
  • Joined

  • Last visited

    Never

Posts posted by kney

  1. kney's reply is syntactically correct, but a more appropriate way will be this:-

     

    $titles = array('Home', 'About Us', 'Registration', 'Sitemap', 'Contact Us', 'Useful Links', 'Feedback');
    
    if (in_array($this->getTitle(), $titles))
    {
        $this->publicSite() = true;
    }
    
    else
    {
        $this->publicSite() = false;
    }
    

     

    Thanks :)..

    I didn't know how to use arrays anymore, that's why the 'crappy' reply :P

  2. Hi,

     

    Here's my problem:

     

    The first 5 or 10 tries it should say "file not found".

    After the 10th try it should automatically say "file found".

    BUT it should also time out after like 50 tries and it hasn't found the file.

    But i don't know how to do this..

     

    I currently have this code:

     

    <?php
    
    function respond_xml($status, $message)
    {
        $out = new XMLWriter();
        $out->openURI("php://output");
        $out->setIndent(true);
    
        $out->startDocument("1.0", "ISO-8859-1");
    
        $out->startElement("statuscheck");
        $out->writeElement("status", $status);
        $out->writeElement("message", $message);
        $out->endElement();
    
        $out->endDocument();
        
        $out->flush();
    }
    
    function main()
    {
        header("Content-type: text/xml");
    
        if (!isset($_GET["file"]))
            respond_xml("ERROR", "File parameter missing");
        else if (file_exists($_GET["file"]))
                respond_xml("OK", "File exists");
        else
               respond_xml("NOT OK", "File does not exist");
    }
    
    main();
    
    ?>

     

    This code works and gives a correct XML response when you type in for example "http://localhost:8080/php/script.php?file=test" it's says:

    <statuscheck>
    <status>NOT OK</status>
    <message>File does not exist</message>
    </statuscheck>
    

     

    Now, I need it to be able to check it every 5 seconds so i've use this code

    header("Refresh: 5; URL=http://localhost:8080/php/script.php?file=test");

  3. Just an example

    You have certain newsposts in ur database with fields (newsID, date, title, content).

    You will also have to have a table with the preferences (so wether you like something or not).. with fields (preferenceID, userID, newsID, like)

    The standard value for like = 0..

    whenever you press a like button it remembers the user who clicked it, the post itself and changes like to 1.. etc

     

    i hope that helps

  4. yep it's just 

     

    <?php
    // Gotta put this on top of every page btw
    session_start();
    ?>
    <form action="startregprocess.php" method="post">
    username:<input type="text" name="username">
    telephone<input type="text" name="telephone"
    <input type="submit" name="submit">
    </form>
    <?php
    srand ((double) microtime( )*1000000);
    $random_number = rand( );
    echo $random_number;
    
    // just use the new variable on the other page
    $_SESSION["randomnumber"] = $random_number;
    ?>
    

     

    and do this on the other page to get it 

     

    <?php
    session_start();
    
    echo $_SESSION["randomnumber"];
    ?>
    

     

     

     

     

  5. Hi,

     

    I currently have this code:

     

    <?php
    
    function respond_xml($status, $message)
    {
        $out = new XMLWriter();
        $out->openURI("php://output");
        $out->setIndent(true);
    
        $out->startDocument("1.0", "ISO-8859-1");
    
        $out->startElement("statuscheck");
        $out->writeElement("status", $status);
        $out->writeElement("message", $message);
        $out->endElement();
    
        $out->endDocument();
        
        $out->flush();
    }
    
    function main()
    {
        header("Content-type: text/xml");
    
        if (!isset($_GET["file"]))
            respond_xml("ERROR", "File parameter missing");
        else if (file_exists($_GET["file"]))
                return respond_xml("OK", "File exists");
        else
               return respond_xml("NOT OK", "File does not exist");
    }
    
    main();
    
    ?>

     

    This code works and gives a correct XML response when you type in for example "http://localhost:8080/php/script.php?file=test" it's says:

    <statuscheck>
    <status>NOT OK</status>
    <message>File does not exist</message>
    </statuscheck>
    

     

    Now, I need it to be able to check it every 5 seconds so i've use this code

    header("Refresh: 5; URL=http://localhost:8080/php/script.php?file=test");

     

    Here's my problem:

     

    The first 5 or 10 tries it should say "file not found".

    After the 10th try it should automatically say "file found".

    BUT it should also time out after like 50 tries and it hasn't found the file.

    But i don't know how to do this..

     

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