Jump to content

[HELP] Variable in Url


justinede

Recommended Posts

Ok so I was working on this code for a friend and I ran into a problem.

 

The first page, the user submits their email address.

The second page, the email is added to a survey link as a subid.

(ex. http://jptvjwg.com/click/?c=59065&s=31492&[email protected])

and the third page would be the survey with the email already being filled in by email.

 

My friend wanted the cut out the middle step. So once the user hit submit when filling out their email address it goes to http://jptvjwg.com/click/?c=59065&s=31492&email=$email with the email already filled in. Here is what I have so far and it isnt working.

 

Page 1

<form action="email.php" method="post">
  <p>
    Email:
      <input name="email" type="text" id="email" />
  </p>
  <p>
    <label>
    <input type="submit" name="button" id="button" value="Submit">
    </label>
  </p>
</form>

 

Page 2

<?php  

Receiving variables  

@$email = addslashes($_POST['email']);  

header('Location: http://jptvjwg.com/click/?c=59065&s=31492&email=$email');  

?>

 

Here is the code for the 3 step process.

 

Page 1 is the same.

And, Page 2 is:

<?php
// Receiving variables
@$email = addslashes($_POST['email']);

// echo"Complete each survey.<br>
// You may have to use a different email for each survey.<br>
// Also make sure you dont use your own email address.<br>
// But the email that you choose has to be valid.<br>
// ONLY FILL OUT THE FIRST PAGE (ex. email or zip).<br>
// DONT USE YOUR CREDIT CARD FOR ANY OF THESE.<br><br>";

echo"<a href='http://jptvjwg.com/click/?c=59065&s=31492&email=$email' target='_new'>Survey</a><br>";


?>

 

If im not clear on what i want. Please post for more info. Thanks for any help. :)

Link to comment
https://forums.phpfreaks.com/topic/117669-help-variable-in-url/
Share on other sites

That's because you are using single quotes in your header argument. Variables do not expand in single quotes, only double quotes.

 

Thus, try

 

<?php  

//Receiving variables  

@$email = addslashes($_POST['email']);  

header("Location: http://jptvjwg.com/click/?c=59065&s=31492&email=$email");  

?>

Link to comment
https://forums.phpfreaks.com/topic/117669-help-variable-in-url/#findComment-605266
Share on other sites

lol wow. thanks! im so stupid. been puzzling at this for a while. thanks =P

SOLVED

 

No, that is an easy mistake. Making mistakes is how you learn. Pardon the old cliche.

 

FYI. You CAN use single quotes with variables but you have to use the concatenation operator (dot)

 

Like ....

 

<?php
header('Location: http://jptvjwg.com/click/?c=59065&s=31492&email=' . $email);
?>

 

By the way, I'm new to this forum, but there is probably a "resolve" link somewhere that you can mark this thread resolved.

 

Link to comment
https://forums.phpfreaks.com/topic/117669-help-variable-in-url/#findComment-605290
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.