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
https://forums.phpfreaks.com/topic/174263-variable-tracing-back-to-echo-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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