0

I have a preview page or an email that is created with html and php. So basically on this page there is a big $body string that can contain any html and php. But I want to send this string to another page with a link:

echo '<a href="[theURL]?body='.htmlentities($body).'">Click here</a>';

the link goes to a second php page that should display everything the same was as on the first page:

<?php
    if(isset($_GET["body"])){
        echo html_entity_decode($_GET["body"]);
        //echo htmlspecialchars_decode($_GET["body"]);
    }
?>

the second page gets the string in the url, but remain empty. so either it's not decoding it right or i missed something simple? the url looks something like this: %20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20

%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20

Is there a better way to do this than $_GET? I tried to use a form instead of a link and use post, but it didn't seem to work.

7
  • 2
    urlencode() is what you should actually be using. urls have length limits, so if body is large you should not use this apporach Commented Jan 8, 2018 at 1:40
  • yup i got a Request-URI Too Long error for some emails. gonna need to send the body string with something other than $_GET, and $_POST didn't seem to work :S Commented Jan 8, 2018 at 2:35
  • I tried to create a form inside the email that puts the body in a hidden input and a submit button instead of the link, but clicking it does nothing: $body .= '<form method="post" action="'.$email_view.'" enctype="multipart/form-data"> <input type="hidden" name="email_body" value="'.urlencode($body).'"/> <input style="'.$email_link.'" type="submit" name="submit" value="Click here"/> </form>'; Commented Jan 8, 2018 at 2:46
  • 1
    you cant put a form in an email and im not sure ehy you are trying to Commented Jan 8, 2018 at 3:30
  • 1
    i think we may be using email in a different context. if you are just trying to send a string from one page to another, and its to large for the url, post is a good option; otherwise you need to store it locally in a db or a file at least temporarily Commented Jan 8, 2018 at 20:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.