Jump to content

Variable Tracing back to echo.... Help


Plinpod

Recommended Posts

Hello,

 

Ok so I am modifying a script and im having some trouble.

 

I created a function that will echo a java script which grabs the url that a user has just arrived from

 

here is this function.

 

function prevurl()
      {
      $language = "javascript";

       ob_start();
        echo "<script language=$language>
             document.write(document.referrer);
             </script>";
       $link =  (string)ob_get_contents();
       ob_end_clean();

       return $link;
      }

 

I later call this function and assign the return to a variable, I test the variable to make sure that is has the right content, when tested in the browser the test string displays a URL (the correct thing)

 

          $buffer = prevurl();
          $values[0] = $buffer;
         // echo "$url";
          $value = $buffer;
          echo "Checking Value: $value";  //THIS PART WORKS and displays the correct value

 

So now I need to apply this value into a form along with some other variables

 

Here is an example of how this code looks

 

$html = '<input type="text" name="' . $name . '" value="' . esc_attr($value) . '"' . $atts . ' />'; //when value is passed here it doesn't display the correct value

 

BUT the value that is now passed through $value is no longer the URL but the script that was written in the echo.

 

Instead of displaying a URL inside the form it displays this

 

<script language=$language>

document.write(document.referrer);

</script>

 

Why is this and how can I fix it, please help.

 

Thank You

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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