php crud在创建记录时给我500个内部服务器错误

qvsjd97n  于 2021-06-25  发布在  Mysql
关注(0)|答案(4)|浏览(302)

我只是想在我的players表中创建一个记录来测试我的php是否正常工作,但是每次单击submit,我都会得到一个500错误,而不是url错误处理程序,如果我的域数据不正确或字段为空,则应该返回这个错误处理程序。
我确实有一个会话保存着我的用户数据。
我的用户创建php作品,这是我的播放器创建php代码的基础。我会张贴我的表,这样你可以看到结构和我的php包括和我的html请任何帮助将是伟大的

我的php包含代码

u91tlkcl

u91tlkcl1#

html/php代码结束

wbrvyc0a

wbrvyc0a2#


<?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();

}
f0brbegy

f0brbegy3#

--结束php include
我的html/php页面代码

zwghvu4y

zwghvu4y4#


<?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';
            ?>

相关问题