2017-04-06 35 views
0

我在這裏有兩個文件作爲測試,第一個是下面這個,當我單擊提交它時,假設在動作接下來的頁面,但我想知道如何檢索動作php文件athe $生命變量,並把它在正常的HTML文件如何從動作表單中獲取php變量並將其用於激活動作的表單中

<!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"; 
?> 
+0

你的問題不明確。你想在提交後在第一個文件中顯示$ life變量? –

+0

你的問題有點普遍,你會發布完整的代碼請 – Amin

+0

你的表單不會發送任何數據到profileAction.php。那麼你期望成爲什麼? – fefe

回答

0

檢查這個代碼。你需要在服務器

<!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> 

運行這段代碼,這是你包括edit.php

<?php 
$life = 'Ok'; 
?> 

那麼你的第一個文件顯示OK,當你運行該代碼

相關問題