

//formsubmit.html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>表單提交</title>
</head>
<body>
<fieldset style="width: 800px;margin: 0 auto;font-size: 14px;">
<legend>用戶注冊</legend>
<form action="../js22\php\postformdata.php" method="post">
<p><label for="">用戶名:</label><input type="text" name="username"></p>
<p><label for="">密 碼:</label><input type="text" name="password"></p>
<p><label for="">郵 箱:</label><input type="text" name="email"></p>
<input type="submit" value="https://bbs.csdn.net/topics/注冊">
</form>
</fieldset>
</body>
</html>
//postformdata.php
<?php
// include "common.php"; //引入資料庫連接
header('content-type:text/html;charset=utf-8');
define('HOST', 'localhost'); //設定主機名
define('USERNAME', 'root'); //設定用戶名
define('PASSWORD', '123'); //設定密碼
define('DBNAME', 'js22'); //設定資料庫名稱
$common = new mysqli(HOST, USERNAME, PASSWORD, DBNAME); //連接資料庫的物件
if ($common->connect_error) {
die('資料庫連接失敗' . $conn->connect_error); //輸出資訊并退出
}
//die ("資料庫連接成功");
if (isset($_POST['username']) && isset($_POST['password']) && isset($_POST['email'])) {
$user = $_POST['username'];
$pass = $_POST['password'];
$email = $_POST['email'];
//echo "我的姓名是:$user,密碼是:$pass,郵箱是:$email";
$common->query("insert into registry values(null,'$user','$pass','$email',NOW())");
echo "注冊成功";
} else {
exit('非法操作');
}
//echo $user;
//代碼和路徑應該沒有問題,代碼也沒有報錯,
uj5u.com熱心網友回復:
if 條件不滿足吧,這個是php代碼吧,怎么發到js論壇轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/253731.html
標籤:JavaScript
下一篇:LayUI時間選擇框下側寫入文字
