Pass Data from one page to another

  • STEP

    Option1: Query string in URL

    Eg
    
                          https://example.com?id=1
    
                          https://example.com?utm_campaign=sale&utm_medium=social&utm_source=twitter
                        

    1. We can pass data using '?'

    2. Note =, it is used for separating parameter name and parameter value

    3. We can pass multiple values. & is used for separating variables

    How to generate query string

    1. Using a href
    
                          <a href="https://example.com?id=1">View</a>
                          <a href="https://example.com?utm_campaign=sale&utm_medium=social&utm_source=twitter">View</a>
                       
    2. Using form tag with get method
    
                          
                        <form method="GET">
                              <input type="text" name="id">
                              <input type="text" name="utm_campaign">
                              <input type="text" name="utm_medium">
                              <input type="text" name="utm_source">
                        </form>
    
                       

    How to read the query parameters in the url and use it in the controller