So I am creating a registration form and I am getting a "Undefined variable" error, the full error goes like this:
Notice: Undefined variable: username in C:\xampp\htdocs\phpacademy\cms\admin\signup.php on line 8
Notice: Undefined variable: password in C:\xampp\htdocs\phpacademy\cms\admin\signup.php on line 9
Now first of all my database for the register form goes like this:
Schema Name:cms
Tables:users,articles
Users table:user_id,user_name,user_password
Now for the code I have index.php, connection.php and signup.php Here is the code:
index.php:
        <?php
echo "<form action='signup.php' method='POST'>
      <input type='text' name='username' placeholder='Username'><br>
    <input type='password' name='password' placeholder='Password'><br>
    <button type='submit'>SIGN UP</button>
</form>";
?>
signup.php:
<?php
require 'connection.php';
$statement = $pdo->prepare("INSERT INTO users (username, password)
    VALUES(:username, :password)");
$result = $statement->execute(array(
    "username" => $username,
    "password" => $password
));
$statement = null;
?>and connection.php:
 <?php
try{
$pdo = new PDO('mysql:host=localhost;dbname=cms', 'root', '');
} catch (PDOException $e) {
 exit('Database error.');
 
}
 if(empty($pdo)) die("pdo variable is empty!");
?>Now just so you guys know this is index.php is a part of a larger code,also because this is a part of a much bigger file when i put the connection.php in a another folder I get an error of the connection.php couldn't be found, if you guys have any more questions I'll answer them,thank you!
 
     
     
    