How to Generate URL-encoded Query String using PHP
Submitted by nurhodelta_17 on Sunday, April 8, 2018 - 22:39.
Setting up our Data
First, are going to set up the data that we are gonna be using as a sample to build our url-encoded query string. Create a new file, name it as index.php and paste the codes below.- <?php
- 'id' => 1,
- 'firstname' => 'neovic',
- 'lastname' => 'devierte',
- 'address' => 'silay city'
- );
- echo "
- <br><br>
- <a href='goto.php?".$url_encoded."'>Send to URL</a>
- ";
- ?>
Creating our Goto Page
Next, we create the goto page where we retrieve our url-encoded query string. Create a new file, name it as goto.php and paste the codes below.- <?php
- echo "
- <h4>Displaying the URL Encoded Data</h4>
- <p>ID: ".$_GET['id']."</p>
- <p>Firstname: ".$_GET['firstname']."</p>
- <p>Lastname: ".$_GET['lastname']."</p>
- <p>Address: ".$_GET['address']."</p>
- ";
- ?>
Add new comment
- 115 views