Pass values from one page to another without form

2019-03-02 12:43发布

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.

5条回答
劫难
2楼-- · 2019-03-02 13:16

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楼-- · 2019-03-02 13:17

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.

查看更多
Evening l夕情丶
4楼-- · 2019-03-02 13:17

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

查看更多
兄弟一词,经得起流年.
5楼-- · 2019-03-02 13:31

Sessions can help, or ajax call.

查看更多
孤傲高冷的网名
6楼-- · 2019-03-02 13:32

for using clean url you can use post method in form

 <form name='' method='POST' action=''>
查看更多
登录 后发表回答