我对我创建的MySql查询感到困惑。运行代码时,查询无法将数据插入数据库。我想弄清楚发生了什么。当我尝试在我的localhost上运行它时,没有发现错误,插入了查询..我使用的是PHP 5.6,我的Web服务器也使用PHP 5.6。
<?php
include 'koneksi.php';
$user = $_POST['username'];
$pass = $_POST['password'];
$nama = $_POST['nama'];
$mail = $_POST['email'];
$tlp = $_POST['telp'];
$date = date("j F Y");
$invoice = mt_rand(100000, 999999);
if ($_POST['pack'] === 'Basic') {
$pack_name = 'Basic Pack';
$price = '$5';
$permiti = 'basic';
$limit = '15';
} elseif ($_POST['pack'] === 'Premium') {
$pack_name = 'Premium Pack';
$price = '$10';
$permiti = 'premium';
$limit = '20';
} elseif ($_POST['pack'] === 'Pro') {
$pack_name = 'Pro Pack';
$price = '$15';
$permiti = 'pro';
$limit = '25';
} elseif ($_POST['pack'] === 'Ultimate') {
$pack_name = 'Ultimate Pack';
$price = '$20';
$permiti = 'ultimate';
$limit = '99';
} else {
}
$permit = 'member';
$start = date("md");
$end = date("md", strtotime(date("md", strtotime($start)). " + 30 day"));
$start_date = date("j F Y");
$end_date = date("j F Y", strtotime(date("j F Y", strtotime($start_date)). " + 30 day"));
$encrypts = md5($nama);
$check = mysql_query("SELECT * FROM user WHERE username = '$user'");
if(mysql_num_rows($check) <> 0 ){
header("location:register.php?message=fail");
} else {
if(!$user || !$pass || !$mail || !$nama || !$tlp){
echo 'Terdapat data yang kosong<br/>';
echo '<a href="register.php">Back</a>';
} else {
$save = mysql_query("INSERT INTO user VALUES('', '$nama', '$user', '$pass', '$date', '$mail', '$tlp', '$permit')");
$gets = mysql_query("INSERT INTO user_pack VALUES('', '$pack_name', '$user', '$start', '$end', '0', '$limit', '$price', '$permiti', '$encrypts', '$invoice', '$start_date', '$end_date', '0')");
if($save || $gets){
session_start();
$_SESSION['username'] = $user;
$_SESSION['status'] = 'login';
header("location:user/invoice.php");
} else {
header("location:register_pack.php?message=fail1");
}
}
}
?>
请帮帮我:(
答案 0 :(得分:3)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>