i am having trouble passing variables in the URL... I have simlified the problem here:

index.php contains the code:

<?
$var = "smile";
echo $var;

echo "<a href=\"index.php?var=notworking\">Change_Var</a>";

?>

and for whatever reason this does not change the value of var?

    <?php
    $var = "something";
    
    echo '<a href="index.php?var='.$var.'">The Link</a>';
    ?>

      <?

      echo $_GET['var'];

      $var = "smile";
      echo $var;

      echo "<a href=\"index.php?var=notworking\">Change_Var</a>";

      ?>

        
        
         if (!isset($_GET['var']))
         {
        $var = "something";}
        else{
         $var = $_GET['var'];}
         echo $var." <p>";
        
        
        
        echo '<a href="index.php?var=hello">The Link</a>'; 
        
        
        
          4 days later

          Himnbandit

          Are you passing variables Out of a PHP script appended to a URL? looks like it.

          I can't seem to find anyone understanding well enough to give advice. I get hints like $_GET, but no examples.

          Do you have this working?

          Thanks for any bones...

            Rhonda02 wrote:

            Himnbandit

            Are you passing variables Out of a PHP script appended to a URL? looks like it.

            I can't seem to find anyone understanding well enough to give advice. I get hints like $_GET, but no examples.

            Do you have this working?

            Thanks for any bones...

            No examples? Look at the post right above yours. Perfect example.

              a month later

              put the $ sign before print a variable

              <?
              $var = "smile";
              echo $var;

              echo "<a href=\"index.php?$var=notworking\">Change_Var</a>";

              ?>

                Time to end this thread...

                <?php
                
                  //set the variable that you want to pass in the URL
                  $var = "smile";
                
                  //build the link
                  //remember that ? tells the browser that there are global variables coming
                  //var is the name of the value's key, and whatever comes after
                  //the = sign is the value.  So ... smile
                  //will be placed in the $_GET global array under the 
                  //key name 'var'.  Accessing it via $_GET['var']
                  echo '<a href="'.$_SERVER['PHP_SELF'].'?var='.$var.'">Click Me</a>';
                
                  //this portion below will load if the link has been clicked  
                //make sure that $_GET['var'] is not empty if(!empty($_GET['var'])) echo $_GET['var']; //this outputs "smile" without quotes //hope that helps. //if not, let me know and I can try again ?>
                  Write a Reply...