-1

I'm trying to get a use php in an html box, but it isn't working. Here's what i'm putting in: (there's some javascript too)

<?php
header('content-type: application/json; charset=utf-8');
$data = json_encode($_SERVER['REMOTE_ADDR']);
echo $_GET['callback'] . '(' . $data . ');';
?>
<script>
var myip="<?php echo $data ?>"
alert(myip)
</script>

And here's what's appearing on the website:

<?php header('content-type: application/json; charset=utf-8'); 
$data = json_encode($_SERVER['REMOTE_ADDR']); 
echo $_GET['callback'] . '(' . $data . ');'; ?>

Well, that and an alert box that says:

<?php echo $data ?>
lukas293
  • 518
  • 1
  • 3
  • 15
Dudeguy21
  • 37
  • 9
  • what is the extension of the file? – JoSSte Sep 25 '15 at 13:24
  • 2
    So none of the PHP is being interpreted by the server? This probably has nothing to do with your code and more to do with the configuration of your server. Do you have PHP installed? Does your filename end with `.php`? – Tim Sep 25 '15 at 13:24
  • Oops. I did forget to use the .php extension. Thanks! *facepalm* – Dudeguy21 Sep 25 '15 at 13:48

1 Answers1

-2

You have to put a semicolon:

<?php echo $data; ?>

You want to put this into a textbox?

Do this:

<input type="text" id="someid" name="somename" value="<?php echo $data; ?>" />

Are you sure that in $data is anything?

xdevs23
  • 3,824
  • 3
  • 20
  • 33