Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在我的域中单击php时_Php_Html - Fatal编程技术网

在我的域中单击php时

在我的域中单击php时,php,html,Php,Html,当我点击我的网站时,我的网站出现了问题,它只是下载,甚至没有加载到下一页。我能做什么?我应该换什么?我只是一个html和php的新手,顺便说一句,我点击的文件是我制作的一个php文件,当我点击那个php文件时,它并没有指向下载文件的下一页。我想知道是否有人在这里帮助我,提前感谢可能帮助我的人。这只是为了我的项目。 这是一个网站,当我点击该标志并注册时,它将下载php文件。我不知道如何解决这个问题。我已经在youtube和google上搜索过了。我看不出一个答案。请帮帮我,谢谢 register.

当我点击我的网站时,我的网站出现了问题,它只是下载,甚至没有加载到下一页。我能做什么?我应该换什么?我只是一个html和php的新手,顺便说一句,我点击的文件是我制作的一个php文件,当我点击那个php文件时,它并没有指向下载文件的下一页。我想知道是否有人在这里帮助我,提前感谢可能帮助我的人。这只是为了我的项目。 这是一个网站,当我点击该标志并注册时,它将下载php文件。我不知道如何解决这个问题。我已经在youtube和google上搜索过了。我看不出一个答案。请帮帮我,谢谢

register.php的代码

<?php
    ob_start();
    session_start();
    if( isset($_SESSION['user'])!="" ){
        header("Location: home.php");
    }
    include_once 'dbconnect.php';

    $error = false;

    if ( isset($_POST['btn-signup']) ) {

        // clean user inputs to prevent sql injections
        $firstname = trim($_POST['firstname']);
        $firstname = strip_tags($firstname);
        $firstname = htmlspecialchars($firstname);

        $middlename = trim($_POST['middlename']);
        $middlename = strip_tags($middlename);
        $middlename = htmlspecialchars($middlename);

        $lastname = trim($_POST['lastname']);
        $lastname = strip_tags($lastname);
        $lastname = htmlspecialchars($lastname);

        $student_number = trim($_POST['student_number']);
        $student_number = strip_tags($student_number);
        $student_number = htmlspecialchars($student_number);

        $course = $_POST['course'];

        $pass = trim($_POST['pass']);
        $pass = strip_tags($pass);
        $pass = htmlspecialchars($pass);

        // basic name validation
        if (empty($firstname)) {
            $error = true;
            $firstnameError = "Please enter your firstname.";
        } else if (strlen($firstname) < 2) {
            $error = true;
            $firstnameError = "Firstname must have atleat 2 characters.";
        } else if (!preg_match("/^[a-zA-Z ]+$/",$firstname)) {
            $error = true;
            $firstnameError = "Firstname must not contain numbers or special characters.";
        }

        if (!empty($middlename) && !preg_match("/^[a-zA-Z ]+$/",$middlename)) {
            $error = true;
            $middlenameError = "Middlename must not contain numbers or special characters.";
        }

        if (empty($lastname)) {
            $error = true;
            $lastnameError = "Please enter your lastname.";
        } else if (strlen($lastname) < 2) {
            $error = true;
            $lastnameError = "Lastname must have atleat 2 characters.";
        } else if (!preg_match("/^[a-zA-Z ]+$/",$lastname)) {
            $error = true;
            $lastnameError = "Lastname must not contain numbers or special characters.";
        }

        if (empty($course)) {
            $error = true;
            $courseError = "Please select a course.";
        }

        if (empty($student_number)) {
            $error = true;
            $student_numberError = "Please enter your student number.";
        } else if (!(strlen($student_number) >= 12 && strlen($student_number) <= 13)) {
            $error = true;
            $student_numberError = "Student number must have atleat 12 characters.";
        } else if (!preg_match("/^PM-[0-9]{2}-[0-9]{4,5}-[AB]$/", $student_number)) {
            $error = true;
            $student_numberError = "Invalid student number format.";
        } else {
            //check if student number exists
            $result = mysql_query("SELECT * FROM users WHERE student_number = '$student_number'");
            $rowCount = mysql_num_rows($result);

            if ($rowCount == 1) {
                $error = true;
                $student_numberError = "Student number is already taken.";
            }
        }

        // password validation
        if (empty($pass)){
            $error = true;
            $passError = "Please enter password.";
        } else if(strlen($pass) < 6) {
            $error = true;
            $passError = "Password must have atleast 6 characters.";
        }

        // password encrypt using SHA256();
        $password = hash('sha256', $pass);

        // if there's no error, continue to signup
        if( !$error ) {         
            $query = "INSERT INTO users(student_number,userPass,user_role,firstname,middlename,lastname,course) VALUES('$student_number','$password',2,'$firstname','$middlename','$lastname',$course)";
            $res = mysql_query($query);

            if ($res) {
                $errTyp = "success";
                $errMSG = "Successfully registered, you may login now.";
                unset($firstname);
                unset($middlename);
                unset($lastname);
                unset($course);
                unset($student_number);
                unset($pass);
            } else {
                $errTyp = "danger";
                $errMSG = "Something went wrong, try again later...";   
            }   
        }
    }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Coding Cage - Login & Registration System</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css" type="text/css"  />
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="assets/js/jquery-3.2.1.min.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#course').change(function () {
            if ($(this).val() == '') {
                $(this).css('color', '#999');
            }
            else {
                $(this).css('color', '#000');
            }
            $('option').css('color', '#000');
        });
        $('#course').trigger('change');
    });
</script>
</head>
<body>
<div class="container">

    <div id="login-form">
    <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">

        <div class="col-md-12">

            <div class="form-group">
                <h2 class="">Sign Up.</h2>
            </div>

            <div class="form-group">
                <hr />
            </div>

            <?php
            if ( isset($errMSG) ) {

                ?>
                <div class="form-group">
                <div class="alert alert-<?php echo ($errTyp=="success") ? "success" : $errTyp; ?>">
                <span class="glyphicon glyphicon-info-sign"></span> <?php echo $errMSG; ?>
                </div>
                </div>
                <?php
            }
            ?>

            <div class="form-group">
                <div class="input-group ">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                    <input type="text" name="firstname" class="form-control" placeholder="Firstname" maxlength="50" value="<?php echo $firstname ?>" />
                </div>
                <span class="text-danger"><?php echo $firstnameError; ?></span>
            </div>

            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                    <input type="text" name="middlename" class="form-control" placeholder="Middlename" maxlength="50" value="<?php echo $middlename ?>" />
                </div>
                <span class="text-danger"><?php echo $middlenameError; ?></span>
            </div>

            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                    <input type="text" name="lastname" class="form-control" placeholder="Lastname" maxlength="50" value="<?php echo $lastname ?>" />
                </div>
                <span class="text-danger"><?php echo $lastnameError; ?></span>
            </div>

            <div class="form-group">
                <div class="input-group">
                    <span class="input-group-addon"><span class="glyphicon glyphicon-book"></span></span>
                    <select id="course" name="course" class="form-control">
                        <option <?php echo $course == "1" ? "selected" : "" ?> value="1">BSIT</option>
                        <option <?php echo $course == "2" ? "selected" : "" ?> value="2">BSBA</option>
                        <option <?php echo $course == "3" ? "selected" : "" ?> value="3">BSTM</option>
                        <option <?php echo $course == "4" ? "selected" : "" ?> value="4">BSHRM</option>
                        <option <?php echo $course == "5" ? "selected" : "" ?> value="5">BSN</option>
                        <option <?php echo $course == "6" ? "selected" : "" ?> value="6">BSC</option>
                        <option <?php echo $course == "7" ? "selected" : "" ?> value="7">BSA</option>
                        <option <?php echo $course == "8" ? "selected" : "" ?> value="8">BSE</option>
                        <option <?php echo $course == "9" ? "selected" : "" ?> value="9">ABMC</option>
                        <option <?php echo $course == "10" ? "selected" : "" ?> value="10">BSP</option>
                        <option <?php echo $course == "11" ? "selected" : "" ?> value="11">BAPA</option>
                    </select>
                </div>
                <span class="text-danger"><?php echo $courseError; ?></span>
            </div>

            <div class="form-group">
                <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                <input type="text" name="student_number" class="form-control" placeholder="Student Number" maxlength="50" value="<?php echo $student_number ?>" />
                </div>
                <span class="text-danger"><?php echo $student_numberError; ?></span>
            </div>

            <div class="form-group">
                <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                <input type="password" name="pass" class="form-control" placeholder="Password" maxlength="15" />
                </div>
                <span class="text-danger"><?php echo $passError; ?></span>
            </div>

            <div class="form-group">
                <hr />
            </div>

            <div class="form-group">
                <button type="submit" class="btn btn-block btn-primary" name="btn-signup">Sign Up</button>
            </div>

            <div class="form-group">
                <hr />
            </div>

            <div class="form-group">
                <a href="Login.php">Sign in Here...</a>
            </div>

        </div>

    </form>
    </div>  

</div>
</body>
</html>
<?php ob_end_flush(); ?>

您需要向网站托管服务器检查它是否支持PHP。并检查服务器中的配置是否正确

Post code,我不去你的网站你安装了php吗?@fernando是的,签名和注册是php文件。但当我点击它们时,它正在下载。你能添加按钮的代码吗?它必须是一个配置错误的表单,定义了GET而不是POST方法。在bitballoon的网站上,它声明“[…]HTML5站点和应用程序”,因此我假设您不能在此主机上使用PHP。
<?php
    ob_start();
    session_start();
    require_once 'dbconnect.php';


    if ( isset($_SESSION['user'])!="" ) {
        header("Location: home.php");
        exit;
    }

    $error = false;

    if( isset($_POST['btn-login']) ) {  

        // prevent sql injections/ clear user invalid inputs
        $student_number = trim($_POST['student_number']);
        $student_number = strip_tags($student_number);
        $student_number = htmlspecialchars($student_number);

        $pass = trim($_POST['pass']);
        $pass = strip_tags($pass);
        $pass = htmlspecialchars($pass);
        // prevent sql injections / clear user invalid inputs

        if(empty($student_number)){
            $error = true;
            $student_number_Error = "Please enter your student number.";
        }

        if(empty($pass)){
            $error = true;
            $passError = "Please enter your password.";
        }

        // if there's no error, continue to login
        if (!$error) {
            $password = hash('sha256', $pass); // password hashing using SHA256

            $res=mysql_query("SELECT student_number, userPass, user_role, firstname, middlename, lastname, course FROM users WHERE student_number = '$student_number'");
            $row=mysql_fetch_array($res);
            $count = mysql_num_rows($res); // if uname/pass correct it returns must be 1 row

            if( $count == 1 && $row['userPass']==$password ) {
                $_SESSION['user'] = $row['student_number'];
                header("Location: home.php");
                echo $_GET['id'];
            } else {
                $errMSG = "Incorrect Credentials, Try again...";
            }

        }

    }
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Coding Cage - Login & Registration System</title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css" type="text/css"  />
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>

<div class="container">

    <div id="login-form">
    <form method="post" action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" autocomplete="off">

        <div class="col-md-12">

            <div class="form-group">
                <h2 class="">Sign In.</h2>
            </div>

            <div class="form-group">
                <hr />
            </div>

            <?php
            if ( isset($errMSG) ) {

                ?>
                <div class="form-group">
                <div class="alert alert-danger">
                <span class="glyphicon glyphicon-info-sign"></span> <?php echo $errMSG; ?>
                </div>
                </div>
                <?php
            }
            ?>

            <div class="form-group">
                <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
                <input type="text" name="student_number" class="form-control" placeholder="Student Number" value="<?php echo $student_number; function a(){$student_number=$idc;}?>" maxlength="15" />

                </div>

                <span class="text-danger"><?php echo $student_number_Error; ?></span>
            </div>

            <div class="form-group">
                <div class="input-group">
                <span class="input-group-addon"><span class="glyphicon glyphicon-lock"></span></span>
                <input type="password" name="pass" class="form-control" placeholder="Password" maxlength="30" />
                </div>
                <span class="text-danger"><?php echo $passError; ?></span>
            </div>

            <div class="form-group">
                <hr />
            </div>

            <div class="form-group">
                <button type="submit" class="btn btn-block btn-primary" name="btn-login">Sign In</button>
            </div>

            <div class="form-group">
                <hr />
            </div>

            <div class="form-group">
                <a href="register.php">Sign Up Here...</a>
            </div>

        </div>

    </form>
    </div>  

</div>

</body>
</html>
<?php ob_end_flush(); ?>