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

熱點內容
資料庫邏輯存儲結構 發布:2025-07-10 09:26:56 瀏覽:917
密碼編譯找規律 發布:2025-07-10 09:18:10 瀏覽:511
電影視頻緩存後 發布:2025-07-10 09:16:48 瀏覽:892
伺服器搭建需要哪些東西 發布:2025-07-10 09:15:23 瀏覽:801
無限密碼怎麼改 發布:2025-07-10 09:14:32 瀏覽:104
coc按鍵精靈腳本 發布:2025-07-10 09:12:40 瀏覽:311
excel表格ftp函數 發布:2025-07-10 09:05:50 瀏覽:276
u2game的解壓密碼 發布:2025-07-10 09:05:14 瀏覽:597
c語言編譯器ide蘋果下載 發布:2025-07-10 09:05:13 瀏覽:294
andftp埠 發布:2025-07-10 08:57:04 瀏覽:607