Pass values from one page to another without form and without passing in URL

前端 未结 5 1306
时光说笑
时光说笑 2021-01-26 22:45

I am working on a project where i need to access clean URL\'s always i.e no parameters can be passed in the URL for getting values on another page.

Can anyone please sug

相关标签:
5条回答
  • 2021-01-26 22:59

    Sessions can help, or ajax call.

    0 讨论(0)
  • 2021-01-26 23:00

    For Clean URL's i prefer you may use HTTP POST Method. Hope that helps.

    <form name="frmApp" method="POST" action="/action.php">
    </form>
    

    Else, you can use AJAX with jQuery to submit the values to another page.

    $.ajax({url:"action.php",success:function(result){
      $("div").html(result);
    }}); 
    

    Check out w3schools to get started with AJAX : http://www.w3schools.com/jquery/jquery_ajax.asp

    No support for SESSION since i don't like writing php code inside my web page.

    0 讨论(0)
  • 2021-01-26 23:03

    Use $_SESSION for this purpose.

    Using $_SESSION you can use variable in multiple pages wherever you want.

    // assigning variable

    $_SESSION['name']="variable";

    //retrieving

    echo $_SESSION['name'];

    write session_start() at the top of page wherever you want $_SESSION variable

    0 讨论(0)
  • 2021-01-26 23:10

    for using clean url you can use post method in form

     <form name='' method='POST' action=''>
    
    0 讨论(0)
  • 2021-01-26 23:12

    You can try mapping resources to the url.

    Suppose you want to get mailing address of a customer then you can write.

    http://[baseurl]/[customerId]/mailingaddress.

    Read more here

    0 讨论(0)
提交回复
热议问题