简体   繁体   English

单击提交按钮后重定向到另一个页面并传递变量

[英]Redirecting to another page and passing variables after clicking a submit button

I have script that has a form that is self submitting.我有一个具有自我提交表单的脚本。 And on that php script I insert the data into the database.在那个 php 脚本上,我将数据插入到数据库中。 I would like to store the last inserted id using mysql_insert_id() and use it in another form that is also self submitting.我想使用 mysql_insert_id() 存储最后插入的 id,并以另一种同样是自我提交的形式使用它。

What i want to do is after the submission of form 1, store the last inserted id, reload the page and pass the last inserted id in the url (reload using javascript).我想要做的是在提交表单 1 后,存储最后插入的 ID,重新加载页面并在 url 中传递最后插入的 ID(使用 javascript 重新加载)。 www.web.com?inserted_id=12312 www.web.com?inserted_id=12312

and get that id and use it in another form.并获取该 ID 并以另一种形式使用它。

How am i going to do that?我该怎么做?

I can't load using jquery, here's my code in reloading the page:我无法使用 jquery 加载,这是我重新加载页面的代码:

window.location = '<?php echo $_SERVER["REQUEST_URI"]?>'

What i want to do is after the submission of form 1, store the last inserted id, reload the page and pass the last inserted id in the url.我想要做的是在提交表单 1 后,存储最后插入的 ID,重新加载页面并在 url 中传递最后插入的 ID。

---Use PHP sessions to save the last inserted id. ---使用PHP session保存最后插入的id。 then you can use it wherever you want.然后你可以在任何你想用的地方使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM