In Chapter 3, HTML Forms and PHP, Exercise 7: Manually Sending Data to a Page demonstrated how to use the thinking behind the GET method to send data to a page by appending it to the URL. You used this technique to send a variable with a single word value. But what if you want to pass several words as one variable value?
In these instances you can use the urlencode() function. As its name implies, this function takes a string and encodes it (changes its format) so that it can properly be passed as part of a URL. The function replaces spaces with plus signs (+) and translates special characters (for example, the apostrophe) into less problematic versions. The syntax for this function is:
In this exercise you will rewrite the handle_post.php page, adding a link that passes the user’s name and email address to a third page. Then you will create a new page called thanks.php.
Just in case it is not clear, we will now quickly write the thanks.php page to which users are directed when they click the link in handle_post.php (see Figure 5-12).
Links
[1] https://www.studyanywhere.ca/advanced-courses/intro-php/chapter-5/using-strings/exercise-5
[2] https://www.studyanywhere.ca/advanced-courses/intro-php/chapter-5/using-strings/exercise-5#open_here
[3] https://www.studyanywhere.ca/advanced-courses/intro-php/chapter-1/getting-started-with-php/exercise-1#anchor
[4] https://www.studyanywhere.ca/advanced-courses/intro-php/chapter-5/using-strings