Last active
November 26, 2016 16:53
-
-
Save simplyniceweb/6ace3b5f5708fa0767f027bf2507dff2 to your computer and use it in GitHub Desktop.
users
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$servername = "localhost"; | |
$database = "exercise"; | |
$username = "root"; | |
$password = "root"; | |
$connection = new PDO ("mysql:host=$servername;dbname=$database;charset=utf8mb4", $username, $password); | |
/* End of file */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title> Registration Form </title> | |
</head> | |
<body> | |
<form name="registration" method="post" action="submit.php"> | |
<table> | |
<tr> | |
<td>Fullname:</td> | |
<td><input type="text" name="fullname" autofocus /></td> | |
</tr> | |
<tr> | |
<td>Username:</td> | |
<td><input type="text" name="username" /></td> | |
</tr> | |
<tr> | |
<td>Password:</td> | |
<td><input type="password" name="password" /></td> | |
</tr> | |
<tr> | |
<td><button type="submit">Registration</button></td> | |
</tr> | |
</table> | |
</form> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include("database.php"); | |
function saveThisShit( $userData, $connection ) { | |
$statement = $connection->prepare("INSERT INTO users(`fullname`, `username`, `password`) VALUES (?, ?, ?)"); | |
$statement->execute(array($userData["fullname"], $userData["username"], $userData["password"])); | |
echo "User data saved!"; | |
exit; | |
} | |
$userData = array( | |
"fullname" => $_POST['fullname'], | |
"username" => $_POST['username'], | |
"password" => $_POST['password'] | |
); | |
saveThisShit( $userData, $connection ); | |
/* End of file */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment