[英]PHP: Validate form on a page and then send data to another php page
<input id="username" name="username" class="required" type="text">
<input id="email" name="email" class="required" type="text">
I am trying to validate user input on the same page using <form action="<?php $_SERVER['SELF']; ?>"
and then if the input is correct I need to send the input values + 2 additional variables to another php page, let's just call them: 我正在尝试使用
<form action="<?php $_SERVER['SELF']; ?>"
在同一页面上验证用户输入,然后如果输入正确,我需要发送输入值 + 2个附加变量另一个php页面,让我们打电话给他们:
<?php
$var1 = "var1";
$var2 = "var2";
?>
I need a way to pass them over to the next page without using sessions/get/javascript. 我需要一种方法将它们传递到下一页而不使用sessions / get / javascript。 Is there a way?
有办法吗?
Without sessions/get/javascript I guess your only 2 option might be 没有session / get / javascript我想你唯一的选择可能是
header("location:your_next_page?var1=$var1&var2=$var2");
Must be used before any output 必须在任何输出之前使用
Or 要么
Form page: 表单页面:
setcookie("var1", $var1, 0, '/');
setcookie("var2", $var2, 0, '/');
//load next page
Next page: 下一页:
$var1 = $_COOKIE['var1'];
$var2 = $_COOKIE['var2'];
您可以使用cookie或localStorage在浏览器上保存价值并从其他页面检索它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.