當前位置:首頁 » 編程語言 » php表單如何提交

php表單如何提交

發布時間: 2023-03-06 08:33:51

1. 如何用php實現表單提交

創建go.php,代碼如下

<?php

@$username = $_POST['name'];
@$usermessage = $_POST['message'];
if(!empty($username) || !empty($usermessage)){
echo "您的姓名:".$username.",您的留言內容:".$usermessage;
}else{
echo '<form action="go.php" method="post">
您的姓名:<input type="text" name="name"><br><br>
留言內容:<input type="text" name="message">
<button>提交</button>
</form>';


案例截圖:

2. 關於php中表單按鈕提交

你所發上來的代碼是沒有問題的,請留下你的QQ,我加你遠程幫你看看。


——————


你所發上來的代碼是沒有問題的,請留下你的QQ,我加你遠程幫你看看。


你這樣吧,把你的script起始標簽改成如下:

<scripttype="text/javascript">


然後再將script標簽提到form表單前面去,也就是將你的代碼改成如下結構嘗試一下:、

<!doctypehtml>
<html>
<head>
<metacharset="utf-8">
<title>無標題文檔</title>
</head>

<body>
<scripttype="text/javascript">
functionsub(){
varf=document.getElementById("form");
f.submit();
}
</script>
<formid="form"action=""method="post">
<inputonclick="sub()"type="button"value="提交">
</form>
</body>
</html>

____


如果接下來還是不行,就把sub()這個函數的名字改了,要知道sub是JS一個內置函數,可能是這里沖突也說不定


————

如果還是不行,你將form命名一個name,寫成如下形式:


<scripttype="text/javascript">
functionsub(){
varf=document.myForm;
f.submit();
}
</script>
<formname="myForm"id="form"action=""method="post">
<inputonclick="sub()"type="button"value="提交">
</form>

3. php表單怎樣提交到當前頁面,並用$_POST獲取其值

按照這樣輸入:

<?php

$username=$_POST['username'];

?>

<form action="" ><input type="text" name="username"><input type="submit" name="submit" value="提交"></form>

熱點內容
如何設置html密碼框 發布:2025-09-13 10:16:06 瀏覽:580
linux解鎖 發布:2025-09-13 10:10:48 瀏覽:638
android自定義導航欄 發布:2025-09-13 10:10:47 瀏覽:396
拼多多買的智能手錶密碼是多少 發布:2025-09-13 10:10:35 瀏覽:54
安卓手機4g在哪裡打開 發布:2025-09-13 10:05:58 瀏覽:585
伺服器硬碟什麼格式 發布:2025-09-13 09:46:03 瀏覽:989
如何更改配置顯示 發布:2025-09-13 09:43:33 瀏覽:43
去除idea反編譯注釋 發布:2025-09-13 09:43:31 瀏覽:936
android開發權威指南 發布:2025-09-13 09:25:02 瀏覽:238
64加密狗驅動 發布:2025-09-13 09:23:24 瀏覽:487