-1

Hello I am trying to use $_GET to pass a variable over to the contact.php page mentioned, but the outcome is:

/contact.php?firstname=

this is the link that im clicking to send the variable:

echo '<a href="contact.php?name="' . $email . '">';

This is the code to get the variable on the other side:

 <?php
      $name = $_GET['name'];
      echo $name ;
    ?>
Ciaran Beatty
  • 35
  • 1
  • 7

1 Answers1

0

You are closing the href attributes value before you should be.

echo '<a href="contact.php?name="' . $email . '">';
                                ^ 

You need to remove that double quote so the value comes out in the attribute. As written currently your HTML will be:

<a href="contact.php?name=" email@example.com">

so use:

echo '<a href="contact.php?name=' . $email . '">';
chris85
  • 23,846
  • 7
  • 34
  • 51