how to pass variable from one page to another

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

    how to pass variable from one page to another

    how to pass variable from one page to another page without the use of form or url.
    e.g: i have a variable
    HTML Code:
    $referer= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
    in get.php file
    and i need to pass the $referer value to click.php , then how to do it?

    #2
    Var1 change to what variables you need

    PHP Code:
    $variable_page1 $_GET['var1']; 
    Clean your var

    PHP Code:
    isset($_GET['var'])?$var=mysql_escape_string($_GET['var']):$var='SomeDefaualtValue'
    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


      #3
      Originally posted by subzero View Post
      Var1 change to what variables you need

      PHP Code:
      $variable_page1 $_GET['var1']; 
      Clean your var

      PHP Code:
      isset($_GET['var'])?$var=mysql_escape_string($_GET['var']):$var='SomeDefaualtValue'
      thank you for quick reply but i am unable and this is not what i asked,

      as per i said like i am getting the referer in get.php but i need to insert that value in DB from click.php when i am getting a real click after checking this, so need to pass the $referer without any form or using url to get function....

      Comment


        #4
        Other words,

        You want to pick up more then 1 file

        file1
        file2

        both submit same values ?

        if you trying to by pass a click to a toplist or any type from other server with out clicking does not work..
        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


          #5
          Lol use header("location: link-to-go.php");

          Comment


            #6
            there are many ways it depends on how you get from page one to page two. Via link? or do you use redirection? ... the best way would be with sessions or cookies.... or you can make it a lot easier and move the code from click.php to get.php as I said... it depends...

            or you can use the POST method... via a form and a button

            Comment


              #7
              Originally posted by jaidon20k View Post
              Lol use header("location: link-to-go.php");
              lol did u read what i wanted to know?

              Comment


                #8
                i would make a form. that was made to LOOK like a link.
                then use the input hidden to pass the data from 1 page to another.

                css to make form/button look like link
                PHP Code:
                .button-link
                {
                      
                backgroundnone;
                      
                border0;
                      
                color#65ACCA; /** #87CEEB */
                      
                text-decorationnone;
                      
                font-size100%;
                }
                .
                button-link:hover
                {
                      
                backgroundnone;
                      
                border0;
                      
                color#65ACCA; /** #87CEEB */
                      
                font-weightnormal;
                      
                font-size100%;
                }
                .
                button-link:visited
                {
                color#800080; /** Purple */
                text-decorationnone;
                }
                .
                button-link:active
                {
                color#FF0000; /** Red */
                text-decorationnone;

                then the form
                PHP Code:
                echo '<form action="TO-PHP-FILE.php" method="post">';
                echo 
                '<input type="hidden" name="referer" value="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"/>';
                echo 
                '<input class="button-link" type="submit" name="submit" value="Lets Submit The Data"/>';
                echo 
                '</form>'
                Then On File To Recieve Data.
                PHP Code:
                if(!empty($_POST['submit']))
                {
                $referer $_POST['referer'];

                i use this method to make my buttons looks like links. then pass/create the new data.


                hmm. poop. i guess i didnt read properly. you dont want to use a form.
                whats wrong with using the include(); function to include the file with the data to the file in question?
                Last edited by Ghost; 15.10.12, 20:25.
                <?php
                include ('Ghost');
                if ($Post == true) {
                echo '

                sigpic
                alt='coding-talk.com!!' />';
                echo 'Sharing Is Caring!';
                } else {
                echo '

                alt='the username GHOST has been comprimised!' />';
                echo 'OMG SOMEBODY HELP ME!!';
                }
                ?>

                Comment


                  #9
                  Originally posted by Ghost View Post
                  i would make a form. that was made to LOOK like a link.
                  then use the input hidden to pass the data from 1 page to another.

                  css to make form/button look like link
                  PHP Code:
                  .button-link
                  {
                        
                  backgroundnone;
                        
                  border0;
                        
                  color#65ACCA; /** #87CEEB */
                        
                  text-decorationnone;
                        
                  font-size100%;
                  }
                  .
                  button-link:hover
                  {
                        
                  backgroundnone;
                        
                  border0;
                        
                  color#65ACCA; /** #87CEEB */
                        
                  font-weightnormal;
                        
                  font-size100%;
                  }
                  .
                  button-link:visited
                  {
                  color#800080; /** Purple */
                  text-decorationnone;
                  }
                  .
                  button-link:active
                  {
                  color#FF0000; /** Red */
                  text-decorationnone;

                  then the form
                  PHP Code:
                  echo '<form action="TO-PHP-FILE.php" method="post">';
                  echo 
                  '<input type="hidden" name="referer" value="http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'"/>';
                  echo 
                  '<input class="button-link" type="submit" name="submit" value="Lets Submit The Data"/>';
                  echo 
                  '</form>'
                  Then On File To Recieve Data.
                  PHP Code:
                  if(!empty($_POST['submit']))
                  {
                  $referer $_POST['referer'];

                  i use this method to make my buttons looks like links. then pass/create the new data.


                  hmm. poop. i guess i didnt read properly. you dont want to use a form.
                  whats wrong with using the include(); function to include the file with the data to the file in question?
                  ghost sir your idea is very good and i also think it ago but i cannot do that as it is a advertisement system and publishers will request the page get.php from their site with our ad code so this thing can not be set there,
                  anyway thanks for suggession

                  Comment


                    #10
                    Originally posted by razor View Post
                    how to pass variable from one page to another page without the use of form or url.
                    e.g: i have a variable
                    HTML Code:
                    $referer= 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
                    in get.php file
                    and i need to pass the $referer value to click.php , then how to do it?
                    It would be much better if you post the code... Anyway you can define constant var or if it is in function in click.php define $referer global:

                    PHP Code:
                    function something() {
                    global 
                    $referer;
                    // The rest of code...

                    Or just make it $GLOBALS['referer'] and use it where you want.
                    <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                    Comment


                      #11
                      Originally posted by arnage View Post
                      It would be much better if you post the code... Anyway you can define constant var or if it is in function in click.php define $referer global:

                      PHP Code:
                      function something() {
                      global 
                      $referer;
                      // The rest of code...

                      this would of been my next suggestion. just make it a function. global $referer;
                      that would do it.

                      was expecting a reason for the include function to not be used.
                      but i guess there wasnt one lol.

                      p.s sorry for late replying. had to go shops etc. needed to get me my smokes for the night.
                      Last edited by Ghost; 15.10.12, 21:56.
                      <?php
                      include ('Ghost');
                      if ($Post == true) {
                      echo '

                      sigpic
                      alt='coding-talk.com!!' />';
                      echo 'Sharing Is Caring!';
                      } else {
                      echo '

                      alt='the username GHOST has been comprimised!' />';
                      echo 'OMG SOMEBODY HELP ME!!';
                      }
                      ?>

                      Comment


                        #12
                        If you dont want the world to change that value of the variable while transporting, then

                        PHP Code:
                        //ads.php
                        session_start();
                        $_SESSION['ref'] = 'http://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                        //Do something 
                        PHP Code:
                        //click.php
                        session_start();

                        $ref $_SESSION['ref'// value was set in ads.php
                        //Do something
                        session_destroy(); 
                        NOTE that, session still needs cookies to be enabled in end user's browser, else you need to pass the constant SID in URL
                        I need some facebook likes, can you please help me
                        http://facebook.com/softwarefreakin
                        I noticed social media is really powerful
                        Well DONE is better than well SAID

                        Comment


                          #13
                          To use the @import rule, type:
                          PHP Code:

                           
                          <style type="text/css">
                             @
                          import url("import1.css");
                             @
                          import url "import2.css";
                           </
                          style

                          The url() is not required. The double quotes are required for valid XHTML, but browsers that support url() tend to support it with or without quotes.

                          You can also include an @import rule in a style sheet with styles:

                          PHP Code:

                           
                          <style type="text/css">
                             @
                          import url("import3.css");
                             
                          color #f00; }
                           
                          </style
                          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


                            #14
                            Originally posted by softwarefreak View Post
                            If you dont want the world to change that value of the variable while transporting, then

                            PHP Code:
                            //ads.php
                            session_start();
                            $_SESSION['ref'] = 'http://' $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
                            //Do something 
                            PHP Code:
                            //click.php
                            session_start();

                            $ref $_SESSION['ref'// value was set in ads.php
                            //Do something
                            session_destroy(); 
                            NOTE that, session still needs cookies to be enabled in end user's browser, else you need to pass the constant SID in URL
                            World can't change it if its handeled properly.
                            And using sessions in this type of script where many people constantly clicks for such a small thing increases a risk of overhead.
                            <!DOCTYPE html PUBLIC "-//WAPFORUM.RS

                            Comment


                              #15
                              Originally posted by arnage View Post
                              World can't change it if its handeled properly.
                              And using sessions in this type of script where many people constantly clicks for such a small thing increases a risk of overhead.
                              Bro, if get, post, cookies are used, the value can be changed easily by an advanced end user. safe side is session only. but if an algorithm is used to encode the data instead of just base64 encoding/decoding, thats ok I guess
                              I need some facebook likes, can you please help me
                              http://facebook.com/softwarefreakin
                              I noticed social media is really powerful
                              Well DONE is better than well SAID

                              Comment

                              Working...
                              X