Php pages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Php pages

    Please can someone code this right

    PHP Code:
    <?php
        $action 
    strip_tags(trim($_GET['action']));

    function 
    header()
        {
    echo 
    '<?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.1//EN" "http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd">
    <html>'
    ;

    }

    function 
    footer()
        {
    echo 
    '
    </body></html>'
    ;
    }

    // INDEX PAGE
    if($action == "")
        {
    echo 
    header();


    echo 
    '<p>...</p>';

    echo 
    footer();

        exit();
    }

    if(
    $action == "friends")
        {
    echo 
    header();

    echo 
    '
    Site Friends<hr/>
    <div><a href="http://">link</a></div>
    <div>&gt; <a href="http://">link</a></div>'
    ;

    echo 
    footer();

        exit();
    }
    ?>
    When in url write ie http://site.tld/index.php?action=blabla , it does not get Error 404 page, gets something blank...
    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

    #2
    blabla is not a varibile so u would end up with a blank page....
    however your not your ending up with a status code 404 error page
    which means that index.php doesnt exsist

    Comment


      #3
      Code:
      <?php 
          $action = strip_tags(trim($_GET['action'])); 
      
      /////////////////////////////////////////////////////
      
      
      echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"> 
      <html>";
      
       
      function footer() 
      { 
      echo "</body></html>";
      } 
      ////////////////////////////////////////////////////
      // INDEX PAGE 
      if($action == "") 
      { 
      
      echo '<p><a href="?action=friends">TRY ME</a></p>'; 
      
      echo footer(); 
      
          exit(); 
      } 
      
      if($action == "friends") 
          { 
      
      
      echo ' 
      Site Friends<hr/> 
      <div><a href="http://">link</a></div> 
      <div>&gt; <a href="http://">link</a></div>'; 
      
      echo footer(); 
      
          exit(); 
      } 
      ?>
      You don't need to add header() function this will show up all pages

      You can use footer() function thou as it will read it thou there...

      if you want to be smart try using include("body.php");

      then use headers and footer function !!

      But you may find a error using the name header to change it to head

      like this

      Code:
      <?php 
          $action = strip_tags(trim($_GET['action'])); 
      
      /////////////////////////////////////////////////////
      function head() 
      { 
      echo "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"> 
      <html>";
      }
       
      function footer() 
      { 
      echo "</body></html>";
      } 
      ////////////////////////////////////////////////////
      // INDEX PAGE 
      
      
      
      if($action == "") 
      {
       
      head();
      
      echo '<p><a href="?action=friends">TRY ME</a></p>'; 
      
      footer(); 
      
          exit(); 
      } 
      
      if($action == "friends") 
          { 
      
      head();
      
      echo ' 
      Site Friends<hr/> 
      <div><a href="http://">link</a></div> 
      <div>&gt; <a href="http://">link</a></div>'; 
      
      footer(); 
      
          exit(); 
      } 
      ?>
      Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
      Visit: WapMasterz Coming Back Soon!
      _______
      SCRIPTS FOR SALE BY SUBZERO
      Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
      FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
      _______
      Info & Tips
      php.net
      w3schools.com

      Comment


        #4
        Thanks Something else, thats which is what I feared because the index page is there. Is this a security whole?

        Subzero, thanks bro, I use somethong like body.php for other pages because it is with prohibition of anonymous browser, do not whant to forbidd it on index.

        Is something like this solution for all variables and if someone can code it ? :

        if ("non existent or unvalid variable")
        {
        header('HTTP/1.1 404 Not Found');
        exit();
        }

        Or something like......?
        <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

        Comment


          #5
          do you want to make a error page ??

          like i type link.com?action=admin

          it will show

          ERROR PAGE NOT FOUND!!

          or you want to block hiden browsers ?
          Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
          Visit: WapMasterz Coming Back Soon!
          _______
          SCRIPTS FOR SALE BY SUBZERO
          Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
          FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
          _______
          Info & Tips
          php.net
          w3schools.com

          Comment


            #6
            Originally posted by subzero View Post
            do you want to make a error page ??

            like i type link.com?action=admin

            it will show

            ERROR PAGE NOT FOUND!!

            or you want to block hiden browsers ?
            Yes, just to send browser to classic Not Found page if the requested variable does not exists or is undefined, not to make it my self (thats not itneresting ).

            Does if(isset) function doing something good for this? :D

            Right now I get just blank page.
            Last edited by arnage; 15.11.09, 20:08.
            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

            Comment


              #7
              DEMO http://chat4u.ath.cx/page/test.php

              PHP Code:

              <?php 
                  $action 
              strip_tags(trim($_GET['action'])); 

              /////////////////////////////////////////////////////
              function head() 

              echo 
              "<!DOCTYPE html PUBLIC \"-//WAPFORUM//DTD XHTML Mobile 1.1//EN\" \"http://www.openmobilealliance.org/tech/DTD/xhtml-mobile11.dtd\"> 
              <html>"
              ;
              }
               
              function 
              footer() 

              echo 
              "</body></html>";

              ////////////////////////////////////////////////////
              // INDEX PAGE 



              if($action == ""
              {
               
              head();

              echo 
              '<p><a href="?action=friends">TRY ME</a></p>'

              footer(); 

                  exit(); 


              if(
              $action == "friends"
                  { 

              head();

              echo 

              Site Friends<hr/> 
              <div><a href="http://">link</a></div> 
              <div>&gt; <a href="http://">link</a></div>'


              footer(); 

                  exit(); 
              }else{
              head();

              echo 
              '404 ERROR PAGE'

              footer(); 

                  exit(); 
              }

              ?>

              Do you know you can change $action = strip_tags(trim($_GET['action'])); to $_GET[action]

              like this

              if($_GET[action] == "")
              {

              head();

              echo '<p><a href="?action=friends">TRY ME</a></p>';

              footer();

              exit();
              }

              if($_GET[action] == "friends")
              {

              head();

              echo '
              Site Friends<hr/>
              <div><a href="http://">link</a></div>
              <div>&gt; <a href="http://">link</a></div>';

              footer();

              exit();
              }
              Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
              Visit: WapMasterz Coming Back Soon!
              _______
              SCRIPTS FOR SALE BY SUBZERO
              Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
              FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
              _______
              Info & Tips
              php.net
              w3schools.com

              Comment


                #8
                Thats it bro, with }else{ function is something I need. Maybe better than standard error page.

                Thanks!

                And whats the difference with
                $action = strip_tags(trim($_GET['action'])); and $_GET[action] ?
                <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                Comment


                  #9
                  Nothing really but the way i did mine if page will load if it had nomal page..
                  Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
                  Visit: WapMasterz Coming Back Soon!
                  _______
                  SCRIPTS FOR SALE BY SUBZERO
                  Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
                  FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
                  _______
                  Info & Tips
                  php.net
                  w3schools.com

                  Comment


                    #10
                    Using
                    funtion head{
                    $mime = ((stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) ? "application/xhtml+xml" : "text/xhtml");



                    $charset = "utf-8";

                    header("content-type:$mime;charset=$charset");

                    $ret = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" >";
                    $ret .= "<head>";
                    $ret .= "<title>title</title>";
                    return $ret; }
                    funtion footer{ $ret ="</body>"; $ret .="</html>"; return $ret; }
                    Last edited by joseg; 16.11.09, 05:39.

                    Comment

                    Working...
                    X