-1

It appears that I have some problem with my code or more specifically my syntax I tried everything but none of my attempts worked.

I changed the syntax. I also renamed my variables and changed them.

This is the first file

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

    }

} 
?>

This is the second file

<?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,
                ))
                ;
            }
    }
    ?>

the sign up file

<?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();
?>
Dharman
  • 30,962
  • 25
  • 85
  • 135
zikoko
  • 3
  • 1
  • 3
    What's the full error message? – Jonnix Jul 23 '19 at 19:42
  • 2
    Possible duplicate of [PHP parse/syntax errors; and how to solve them?](https://stackoverflow.com/questions/18050071/php-parse-syntax-errors-and-how-to-solve-them) – Jonnix Jul 23 '19 at 19:55
  • @Jonnix Fatal error: Uncaught Error: Call to undefined method user::setpass() in C:\xampp\htdocs\atp\traitement\inscription.php:8 Stack trace: #0 {main} thrown in C:\xampp\htdocs\atp\traitement\inscription.php on line 8 – zikoko Jul 24 '19 at 20:10

1 Answers1

0

You're missing a semicolon here:

header('location:../views/login.php')
ThrownAway
  • 36
  • 4