當前位置:首頁 » 編程語言 » 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>

熱點內容
linux源碼目錄 發布:2025-09-13 12:07:02 瀏覽:214
2014計算機二級考試c語言 發布:2025-09-13 11:59:23 瀏覽:757
想玩人渣最低什麼配置 發布:2025-09-13 11:27:17 瀏覽:868
搶抖幣腳本 發布:2025-09-13 11:27:14 瀏覽:802
長虹電視存儲空間不足 發布:2025-09-13 11:11:39 瀏覽:97
捷達手動風尚有什麼配置 發布:2025-09-13 11:01:50 瀏覽:794
華三配置保存在哪個文件 發布:2025-09-13 11:00:07 瀏覽:752
耦合java 發布:2025-09-13 10:46:50 瀏覽:162
cs15免費腳本 發布:2025-09-13 10:35:44 瀏覽:798
c文件上傳 發布:2025-09-13 10:33:23 瀏覽:678