Skip to content
Snippets Groups Projects
Commit 189d1eda authored by Iqbal's avatar Iqbal
Browse files

Auto insert on Driver table.

parent 135bacff
2 merge requests!7Routing Configuration with index.php,!6Reconfigure Login and Register Page
......@@ -23,4 +23,9 @@ class Driver extends User {
}
}
public static function InsertNewDriver(PDO $dbconn) {
$lastUser = $dbconn->query("SELECT * FROM user ORDER BY id DESC LIMIT 1")->fetch(PDO::FETCH_ASSOC);
$newId = $lastUser['id'];
$dbconn->prepare("INSERT INTO driver VALUES ($newId, 0, 0)")->execute();
}
}
\ No newline at end of file
<?php
require_once __DIR__.'/../model/Driver.php';
class User {
public $id;
......@@ -113,6 +116,7 @@ class User {
$insertExpression = "INSERT INTO user ($columns) VALUES ($values)";
$conn->query($insertExpression);
Driver::InsertNewDriver($conn);
} catch (PDOException $e) {
echo "Error: ".$e->getMessage();
return false;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment