我只是想在我的玩家表中创建一个记录来测试我的php是否有效,但每次点击我的提交时我都会收到500错误,而不是我的url错误处理程序,如果我的数据不正确则会返回我的域名或字段为空。
我确实有一个会话,其中包含我的用户数据。
我的用户创建php作品,这是我基于我的播放器创建PHP代码。我将发布我的表,以便您可以看到结构和我的PHP包含和我的HTML请任何帮助将是伟大的
我的php包含代码--------------
<?php
if (isset($_POST['submit'])) {
include_once 'dbh.php';
$player_first = mysqli_real_escape_string($conn, $_POST['player_first']);
$player_last = mysqli_real_escape_string($conn, $_POST['player_last']);
$player_mobile = mysqli_real_escape_string($conn, $_POST['player_mobile']);
$player_address = mysqli_real_escape_string($conn,
$_POST['player_address']);
$player_city = mysqli_real_escape_string($conn, $_POST['player_city']);
$player_state = mysqli_real_escape_string($conn, $_POST['player_state']);
$player_zip = mysqli_real_escape_string($conn, $_POST['player_zip']);
$player_dob = mysqli_real_escape_string($conn, $_POST['player_dob']);
$player_gender = mysqli_real_escape_string($conn, $_POST['player_gender']);
$player_id = mysqli_real_escape_string($conn, $_POST['player_id']);
//Error handlers
//Check for empty fields
if (empty($player_first) || empty($player_last) || empty($player_mobile) ||
empty($player_address) || empty($player_city) || empty($player_state)||
empty($player_zip)|| empty($player_dob)|| empty($player_gender) ||
empty($player_id)) {
header("Location: ../profile.php?profile=empty");
exit();
}
else {
//check if input characters are valid
if (!preg_match("/^[a-zA-Z]*$/", $player_first)
|| !preg_match("/^[a-zA-Z]*$/", $player_last)) {
header("Location: ../profile.php?profile=invalid");
exit();
}
else {
//check if email is valid
if (!filter_var($player_mobile, FILTER_SANITIZE_NUMBER_INT)) {
header("Location: ../profile.php?player=mobile");
exit();
} else {
$sql = "SELECT * FROM players WHERE player_id='$player_id'";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
header("Location: ../profile.php?profile=playertaken");
exit();
} else {
//Insert the player into the database
$sql = "INSERT INTO players (player_first, player_last, ,
player_mobile, player_address, player_city, player_state, player_zip,
player_dob, player_gender, player_id) VALUES
('$player_first', '$player_last', '$player_address',
'$player_city', '$player_state', '$player_zip', '$player_dob',
'$player_gender', '$player_id');";
mysqli_query($conn, $sql);
header("Location: ../profile.php");
exit();
}
}
}
}
else {
header("Location: ../profile.php");
exit();
}
----------------------------------------------- ---------------结束php包括
我的html / php页面代码----------------------------------------- -----------------
<?php
session_start();
include_once 'header.php';
include 'includes/dbh.php';
?>
<!-- ============================================================== -->
<!-- Page Content -->
<!-- ============================================================== -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Profile page</h4> </div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<button class="right-side-toggle waves-effect waves-
light btn-info btn-circle pull-right m-l-20"><i class="ti-settings text-
white"></i></button>
<ol class="breadcrumb">
<li><a href="./index.php">Dashboard</a></li>
<li class="active">Profile page</li>
</ol>
</div>
</div>
<div class="tab-pane active" id="settings">
<form class="form-horizontal form-material"
action="includes/profile-inc.php" method="POST">
<div class="form-group">
<label class="col-md-12">First
Name</label>
<div class="col-md-12">
<input type="text" required=""
name="player_first" value ="<?php echo $user_first ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-12">Last
Name</label>
<div class="col-md-12">
<input type="text" required=""
name="player_last" value ="<?php echo $user_last ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label for="example-email"
class="col-md-12">Mobile</label>
<div class="col-md-12">
<input type="text" required=""
name="player_mobile" value ="<?php echo $player_mobile ?>" class="form-
control form-control-line"> </div>
</div>
<div class="form-group">
<label for="example-email"
class="col-md-12">Address</label>
<div class="col-md-12">
<input type="address"
required="" name="player_address" value ="<?php echo $player_address ?>"
class="form-control form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">City</label>
<div class="col-md-12">
<input type="text" required=""
name="player_city" value ="<?php echo $player_city ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">State</label>
<div class="col-md-12">
<input type="text" required=""
name="player_state" value ="<?php echo $player_state ?>" class="form-
control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-12">Zip</label>
<div class="col-md-12">
<input type="text" required=""
name="player_zip" value ="<?php echo $player_zip ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-12">Date of
Birth</label>
<div class="col-md-12">
<input type="date" required=""
name="player_dob" value ="<?php echo $player_dob ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">Gender</label>
<div class="col-md-12">
<input type="text" required=""
name="player_gender" value ="<?php echo $player_gender ?>" class="form-
control form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">User_id</label>
<div class="col-md-12">
<input type="text" required=""
name="player_id" value ="<?php echo $user_id ?>" class="form-control form-
control-line"></div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button class="btn btn-success"
type="submit" name="submit">Update Profile</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /.row -->
<!--
============================================================== -->
<!-- Right sidebar -->
<!--
============================================================== -->
<!-- .right-sidebar -->
<div class="right-sidebar">
<div class="slimscrollright">
<div class="rpanel-title"> Service Panel <span><i
class="ti-close right-side-toggle"></i></span> </div>
<div class="r-panel-body">
<ul id="themecolors" class="m-t-20">
<li><b>With Light sidebar</b></li>
<li><a href="javascript:void(0)" data-
theme="default" class="default-theme">1</a></li>
<li><a href="javascript:void(0)" data-
theme="green" class="green-theme">2</a></li>
<li><a href="javascript:void(0)" data-
theme="gray" class="yellow-theme">3</a></li>
<li><a href="javascript:void(0)" data-
theme="blue" class="blue-theme">4</a></li>
<li><a href="javascript:void(0)" data-
theme="purple" class="purple-theme">5</a></li>
<li><a href="javascript:void(0)" data-
theme="megna" class="megna-theme">6</a></li>
<li><b>With Dark sidebar</b></li>
<br/>
<li><a href="javascript:void(0)" data-
theme="default-dark" class="default-dark-theme">7</a></li>
<li><a href="javascript:void(0)" data-
theme="green-dark" class="green-dark-theme">8</a></li>
<li><a href="javascript:void(0)" data-
theme="gray-dark" class="yellow-dark-theme">9</a></li>
<li><a href="javascript:void(0)" data-
theme="blue-dark" class="blue-dark-theme">10</a></li>
<li><a href="javascript:void(0)" data-
theme="purple-dark" class="purple-dark-theme">11</a></li>
<li><a href="javascript:void(0)" data-
theme="megna-dark" class="megna-dark-theme working">12</a></li>
</ul>
<ul class="m-t-20 all-demos">
<li><b>Choose other demos</b></li>
</ul>
</div>
</div>
</div>
<!--
============================================================== -->
<!-- End Right sidebar -->
<!--
============================================================== -->
</div>
<!-- /.container-fluid -->
<?php
include_once 'footer.php';
?>
----------------------------------------------- -------------结束html / php代码