Jump to content

HTTP GET not working.


KyleVA

Recommended Posts

Alright, I have two pages within the same directory.

 

test.htm

<body>
<a href="test.php?data1=Test">Test</a>
</body>

 

test.php

<body>
<?php
$data1 = $_get['data1'];
?> 
</body>

 

It simply displays nothing on test.php - any ideas as to why this won't work?

Link to comment
Share on other sites

echo $data1;

 

try this

 

<?php
$data1 = $_GET['data1'];
echo $data1;
?>

 

Both of you, worked like a charm.

 

I appreciate the quick response, I'm new to PHP so maybe you guys can assist me with problems in the future.

 

:thumbs up:

 

$data1 = $_GET['data1']; is an assignment statement. The output to the browser by the original code is <body></body>. What were you expecting to be displayed?

 

Ahh, makes sense - the $_GET tells the browser to grab the information from the URL and the echo displays it. When is it appropriate to use print vs echo?

Link to comment
Share on other sites

echo $data1;

 

try this

 

<?php
$data1 = $_GET['data1'];
echo $data1;
?>

 

Both of you, worked like a charm.

 

I appreciate the quick response, I'm new to PHP so maybe you guys can assist me with problems in the future.

 

:thumbs up:

 

$data1 = $_GET['data1']; is an assignment statement. The output to the browser by the original code is <body></body>. What were you expecting to be displayed?

 

Ahh, makes sense - the $_GET tells the browser to grab the information from the URL and the echo displays it. When is it appropriate to use print vs echo?

perhaps you should read up a little on echo and print.

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.