类文件中的致命错误显示语法和致命错误

时间:2019-07-23 19:41:29

标签: php error-handling

似乎我的代码有问题,或更具体地说,我尝试了所有操作的语法,但没有任何尝试。

我更改了语法。 我还重命名了变量并进行了更改。

这是第一个文件

<?php
// the second sign up file
class form {

    public function openform($action,$method){

        echo '<form action="'.$action.'" method="'.$method.'"><br>';

    }
    public function name($type,$name){

        echo 'write your name here:<input type="'. $type .'"name="'. $name . '"><br><hr>';
    }

    public function input($type,$name){

        echo 'please type your email here:<input type="'. $type .'"name="'. $name . '"><br><hr>';
    }


    public function password($type,$name){

                echo 'create a password:<input type="' . $type .'"name' . $name . '"><br><hr>' ;

    }   


    public function button($type,$name){

                echo '<input type="'. $type .'"name="'. $name . '"><br><hr>';
        }

    public function endform(){

        echo '</form>';

    }

} 
?>

这是第二个文件

<?php
    class user{

        private $id;
        private $name;
        private $email;
        private $password;

        public function setname($name){
            $this->name=$name;
        }
        public function setemail($email){
            $this->email=$email;
        }
                public function setpassword($password){
            $this->password=$password;
        }
                public function getid(){
            return $this->id;
        }

            public function inscription(){
                $bdd=new PDO('mysql:host=localhost;dbname=yassine','root','');
                $bdd->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
            $req=$bdd->prepare('insert into user (name,email,password) values(:name,:email,:password)');
            $req->execute(array(
                ':name'=>$this->name,
                ':email'=>$this->email,
                ':password'=>$this->password,
                ))
                ;
            }
    }
    ?>

注册文件

<?php
require '../class/user.php';
$u= new user();
var_dump($_POST);
$u->setname($_POST['name']);
$u->setemail($_POST['email']);
var_dump($u);
$u->setpass($_POST['password']);
$u->inscription();
header('location:../views/login.php')
?>










<?php  

include('../Core/form.php');

$F=new form();
$F->openform("../traitement/inscription.php","POST") ;
$F->name("text","name");
$F->input("text","email");
$F->password("password","password");
$F->button('submit',"botonna");
$F->endform();
?>

1 个答案:

答案 0 :(得分:0)

您在这里缺少分号:

header('location:../views/login.php')