简体   繁体   English

我如何从PHP中的其他文件中检索变量值

[英]How i can retrieve a variable value from other file in php

I am getting var from 1 file to other but its reporting error as undefined var. 我正在从1个文件到另一个文件获取var,但其报告错误为未定义的var。

I used form to retrieve, using POST method what can i do to get var value. 我使用POST方法检索表单,该如何获取var值。

Form(It has $email & $str value). 表格(具有$ email和$ str值)。

<form action="resetpassword.php" method="POST">
    <input type="hidden" name="email" value="<?php $email; ?>">
    <input type="hidden" name="token" value="<?php $str; ?>">
</form>

Callinginotherfile 调用其他文件

<?php
    $email = $_POST["email"];
    $token = $_POST["token"];
?>

Please replace your code with below code. 请用以下代码替换您的代码。

<?php
    $email = (isset($_POST["email"]) ? $_POST["email"] : "");
    $token = (isset($_POST["token"]) ? $_POST["token"] : "");
?>

Actually, if you put some action to your form then its kinda easy one, but seems in your code you're trying to pass it at the back of the interfaces. 实际上,如果您对表单进行一些操作,那么它就很简单,但是似乎在您的代码中,您试图在接口的后面传递它。 Then Session can handle that one. 然后Session可以处理那个。

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

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