[英]How to get php variable from an action form and use it in the form thats activating the action
我在這里有兩個文件作為測試的第一個文件,這是下面的文件,當我單擊“提交”時,它想在下一頁上執行操作,但是我想知道如何從操作php文件中檢索$ life變量並放入在普通的html文件中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form class="" action="../logic/profileAction.php" method="post">
<label for=""></label>
<button type="submit" name="button">Submit</button>
</form>
</body>
</html>
第二個文件是php文件:
<?php
$life ="Yo";
?>
檢查此代碼。 您需要在服務器中運行此代碼
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<?php
include_once 'edit.php';
echo $life;
?>
<form class="" action="../logic/profileAction.php" method="post">
<label for=""></label>
<button type="submit" name="button">Submit</button>
</form>
</body>
</html>
這是您的include edit.php
<?php
$life = 'Ok';
?>
然后當您運行此代碼時,您的第一個文件顯示為OK
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.