Pass values from one page to another without form

2019-03-02 13:15发布

问题:

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 suggest an alternative other than 'Form Submit' method.

Thanks In Advance.

回答1:

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.



回答2:

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



回答3:

Sessions can help, or ajax call.



回答4:

for using clean url you can use post method in form

 <form name='' method='POST' action=''>


回答5:

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