php入門之頁面傳值的技巧解析

零下一度
發布: 2023-03-10 19:26:02
原創
1545 人瀏覽過

本節內容:
php頁傳值的簡單範例

1,index.html
 

##複製程式碼 程式碼範例:

<html>
 <
head
> 
  <title> 留言本首页 - www.jbxue.com</title>
 <body>
  <h1>Hello,Welcome to imchaotan 留言本</h1><br />
  <h3>留下您宝贵的建议吧?</h3>
  <table align="center" vspace=80 >
   <form method="post" 
action
="post.php">
    <tr>
      <td>账户:</td>
      <td><input type="text" name="id"  /></td>
    </tr>
    <tr>
     <td>想说点什么?</td>
     <td><input type="text" name="guess" size="60" /></td>
    </tr>
    <tr>
      <td><input type="submit"  value="提交" /></td>
      <td><input type="
reset
"  value="重置" /></td>
    </tr>
   </form>
  </table>
  
   </body>
 </head>
</html>
登入後複製

2,post.php

 

複製程式碼 程式碼範例:

<? 
   if(empty($_POST[&#39;id&#39;]))
   {
    
echo
 "账户不能为空,5秒后自动返回登录界面";
    header("refresh:5;URL=&#39;index.htm&#39;");
   }
   
else
if(empty($_POST[&#39;guess&#39;]))
   {
    echo "文本不能为空,5秒后自动返回登录页面";
    header("refresh:5;URL=&#39;index.htm&#39;");
   }
     else {
      $id=$_POST[&#39;id&#39;];
      $guess=$_POST[&#39;guess&#39;];
     echo"Hello".$id."你的留言是".$guess."<br />";
     }
 ?>
登入後複製

更多php新手相關的教學課程,請參考php入門教學中介紹的更多內容。

以上是php入門之頁面傳值的技巧解析的詳細內容。更多資訊請關注PHP中文網其他相關文章!

相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!