MySQLi的HTML表单插入数据库 无法写入不知道是哪里变量值问题
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>MYZTGAME</title>
</head>
<style>
.header {
position: absolute;
top: 0px;
left: 0px;
right: 0px;
height: 60px;
background-color: #009aff;
color: #fff;
}
.content {
margin-top: 100px;
}
.greenbg {
width: 100%;
background-color: #0f0;
}
.greenbr {
text-align: center;
border: solid;
border-radius: 8px;
border-color: #f00;
color: #000;
}
.submit {
height: 45px;
}
.fit {
width: 100%;
text-align: center;
border-radius: 5px;
border-color: #f00;
color: #000;
}
.row {
margin-top: 10px;
}
.panal {
width: 80%;
margin: 0 auto;
margin-bottom: 20px;
}
.box {
margin-bottom: 20x;
}
</style>
<script>
function CheckInput(){
if(document.getElementById("account").value == ""){alert("请输入您的游戏账号!");document.getElementById("account").focus();return false;}
if(!isPhoneAvailable(document.getElementById("account").value)){alert("游戏账号必须是邮箱地址!");document.getElementById("account").focus();return false;}
if(document.getElementById("POINT").value == ""){alert("请输入充值数量!");document.getElementById("POINT").focus();return false;}
if(document.getElementById("POINT").value.length<7){alert("最少充值数量100锭起步!");document.getElementById("POINT").focus();return false;}
return true;}
var mailReg = /^[a-zA-Z0-9]{3,16}[a-zA-Z0-9]@[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;function isPhoneAvailable(phonevalue){if(mailReg.test(phonevalue)){return true;}else{return false;}}
function getByClass(parent, cls) {
if (parent.getElementsByClassName) {
return parent.getElementsByClassName(cls);
} else {
var res = [];
var reg = new RegExp(' ' + cls + ' ', 'i')
var ele = parent.getElementsByTagName('*');
for (var i = 0; i < ele.length; i++) {
if (reg.test(' ' + ele[i].className + ' ')) {
res.push(ele[i]);
}
}
return res;
}
}
function get(index) {
var choose = getByClass(document, 'greenbr');
for (let i = 0; i < choose.length; i++) {
choose[i].style.backgroundColor = "#fff";
choose[i].style.color = "#000";
}
choose[index].style.backgroundColor = "#f00";
choose[index].style.color = "#fff";
var count = document.getElementById("count");
if(index == 1) { POINT = 4000000; } else
if(index == 2) { POINT = 8000000; } else
if(index == 3) { POINT = 15000000; } else
if(index == 4) { POINT = 35000000; } else
if(index == 5) { POINT = 60000000; } else
{ POINT = 2000000; }
POINT.value = POINT;
}
</script>
<body>
<div class="header text-center" style="text-align:center;color:#000"">
<h3>游戏充值系统</h3>
</div>
<div class="content">
<div class="panal">
<div class="row">
<div class="col-xs-5 greenbr" onclick="get(0)" style="background-color:#f00;color:#fff">
<strong>建议售价:100.00元宝</strong>
<br>200锭金子</br>
</div>
<br>
<div class="col-xs-offset-2 col-xs-5 greenbr" onclick="get(1)">
<strong>建议售价:200.00元宝</strong>
<br>400锭金子</br>
</div>
<br>
<div class="col-xs-5 greenbr" onclick="get(2)">
<strong>建议售价:300.00元宝</strong>
<br>800锭金子</br>
</div>
<br>
<div class="col-xs-offset-2 col-xs-5 greenbr" onclick="get(3)">
<strong>建议售价:500.00元宝</strong>
<br>1500锭金子</br>
</div>
<br>
<div class="col-xs-5 greenbr" onclick="get(4)">
<strong>建议售价:1000.00元宝</strong>
<br>3500锭金子</br>
</div>
<br>
<div class="col-xs-offset-2 col-xs-5 greenbr" onclick="get(5)">
<strong>建议售价:1500.00元宝</strong>
<br>6000锭金子</br>
</div>
</div>
</div>
<hr>
<form class="form panal" method="get" onSubmit="return CheckInput();" action="?action=save">
<div class="form-group row box">
<label for="account" class="col-xs-3 control-label">游戏账号:<font color="#FF0000">*</font></label>
<div class="col-xs-9">
<input type="text" class="form-control" id="account" name="account" size="36" placeholder="请输入需充值的邮箱账号">
</div>
</div>
<div class="form-group row box">
<label for="POINT" class="col-xs-3 control-label">金子数量:(文)<font color="#FF0000">*</font></label>
<div class="col-xs-9">
<input type="text" class="form-control" id="POINT" name="POINT" size="36" placeholder="请选择充值金额" readonly value="">
</div>
</div>
<br>
<div class="form-group row box">
<label for="codes" class="col-xs-3 control-label">验证码:<font color="#FF0000">*</font></label>
<div class="col-xs-9">
<input type="text" name="codes" id="codes" size="12">
<img src="code.php" onclick="this.src='code.php?'+new Date().getTime();" width="150" height="50">
</div>
</div>
<br>
<div class="form-group row box">
<div class="col-xs-12 fit">
<button type="submit" style="background-color:#f00;color:#fff" class="btn btn-success fit">立即充值</button>
<p>温馨提示:1<font color="#FF0000">0000</font>文=1锭金子</p>
</div>
</div>
</form>
</div>
</body>
</html>
<?php
$dbConf= array(
'host'=>'127.0.0.1',
'user'=>'MYZTsunify00',
'password'=>'ns3ZS4a5shhKZ6shWwHPf',
'dbName'=>'MYZTsunifgy00',
'charSet'=>'utf8',
'port'=>'3306');
function openDb($dbConf){$conn=mysqli_connect($dbConf['host'],$dbConf['user'],$dbConf['password'],$dbConf['dbName'],$dbConf['port']) or die('打开失败');mysqli_set_charset($conn,$dbConf['charSet']);return$conn;}
function closeDb($conn){mysqli_close($conn);}$conn=openDb($dbConf);
if(isset($_GET["action"])){session_start();$codes = $_POST["codes"];
if(strtolower($_SESSION["captcha"]) != strtolower($codes))
{echo "<h1>验证码错误!</h1>";$_SESSION["captcha"] = "";}
else{if($_GET["action"]=="save"){$account=$_POST["account"];$POINT=$_POST["POINT"];
$sql="UPDATE POINTBONUS0000 set POINT=POINT+'$POINT' where ACCOUNT='$account'";
$rs=$conn->query($sql);echo "<h1>注册成功!请妥善保管。游戏账号:".$account."</h1>";}}}closeDb($conn);
?>
上一篇: curl获取结果乱码
下一篇: Windows12网