Show sourcecode
The following files exists in this folder. Click to view.
createtable.php
dbconnection.php
insertdefaultposts.php
nykompis.php
skapakompis.php
2/
skapakompis.php
36 lines ASCII Windows (CRLF)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<?php
include ('dbconnection.php');
try {
// sql to create table
$sql = "CREATE TABLE kompisar (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
fornamn VARCHAR(30) NOT NULL,
efternamn VARCHAR(30) NOT NULL,
mobil VARCHAR(30) NOT NULL,
epost VARCHAR(30) NOT NULL
)";
// use exec() because no results are returned
$dbconn->exec($sql);
echo "Table created successfully";
}
catch(PDOException $e)
{
echo $sql . "<br>" . $e->getMessage();
}
//Rensa kopplingen till databasen
$dbconn = null;
?>
</body>
</html>