Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2012/2.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 - Fatal编程技术网

从表单提交调用PHP函数

从表单提交调用PHP函数,php,Php,我对PHP非常陌生,我不知道如何正确处理事情,我需要帮助 我的register-page.php如下所示: <?php include "includes/functions/Register/Register.php"?> <?php include "includes/header.php"?> <?php include "includes/navbar.php"?> <?php include "includes/registerContaine

我对PHP非常陌生,我不知道如何正确处理事情,我需要帮助

我的register-page.php如下所示:

<?php include "includes/functions/Register/Register.php"?>
<?php include "includes/header.php"?>
<?php include "includes/navbar.php"?>
<?php include "includes/registerContainer.php"?>
<?php include "includes/hidden.php"?>
<?php include "includes/footer.php"?>

从上面的代码可以看出,我将文件保存在includes文件夹中,Register.php是保存函数的文件

register-container.php中的表单:

<form action="" class="registerForm" method="post">

                <div class="row">
                    <div class="col-md-12">
                        <div class="input-group regElements">
                            <span class="input-group-addon glyphicon glyphicon-envelope"></span>
                            <input class="form-control " name="regEmail" type="email" placeholder="Email" autofocus>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="input-group regElements">
                            <span class="input-group-addon glyphicon glyphicon-user"></span>
                            <input class="form-control " name="regUsername"  type="text" placeholder="Username"  >
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="input-group regElements">
                            <span class="input-group-addon glyphicon glyphicon-lock"></span>
                            <input class="form-control " name="regPassword"  type="password" placeholder="Password"  >
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="input-group regElements">
                            <span class="input-group-addon glyphicon glyphicon-lock"></span>
                            <input class="form-control " name="regPassword2"  type="password" placeholder="Confirm Password" >
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div id="errors">

                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-md-12">
                        <div class="input-group regElements">
                            <input id="regButton" name="registerButton"type="submit" class="btn" value="Register Now!">
                        </div>
                    </div>
                </div>

            </form>

如您所见,我将表单操作留空,因为我的代码在 我将这段代码包括在内:
在底部(页脚下)

但现在我意识到,通过这样做,我不能使用会话,当我尝试时,我会收到一个错误

我不知道如何解决这个问题,如果有人可以帮助我,这是非常感谢。如果我方需要更多信息,请告诉我,谢谢

编辑:我意识到,当我将寄存器功能放在顶部时,它可以工作,但显示错误的功能不起作用,这是不正确的

function errorDisplay($regErrors){
    //Display Errors
        foreach ($regErrors as $errrorMessage) {
            ?>
                <script>
                    $("#errors").append('<div class="alert alert-danger" role="alert"><?php echo $errrorMessage; ?></div>');
                    if($(window).width()<=1024 && $(window).height()<=768){
                        $(".registerContainer").animate({marginBottom:"75vh"});
                    }
                    else{
                        $(".registerContainer").animate({marginBottom:"60"});
                    }
                    alert($msgheight);
                </script>
            <?php
        }
}
函数错误显示($regErrors){
//显示错误
foreach($regErrors作为$errrorMessage){
?>
$(“#错误”)。追加(“”);

如果($(window).width(),我不确定错误/问题是什么?你能澄清一下吗?当Register.php位于最底部时,如果我将它放在顶部,我可以注册。我没有收到任何错误。我认为HTML是无用的,但在你的问题中包括
Register.php
可能有用。我打赌
session\u start()
位于
Register.php
的顶部。这就是为什么如果在底部包含此文件,
$\u SESSION
将无法工作的原因。(
SESSION\u start()
如果要使用它,必须首先在代码中声明).我编辑了我的文章,我意识到,因为php文件位于顶部,具有函数,使用jquery显示错误的函数不起作用,有什么建议吗?可能很有趣?