Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_errors', 1);
- $servername = "localhost";
- $username = "xgx2741";
- $password = "Izaacmarc20";
- $dbname = "xgx2741";
- $name = "";
- $userpassword = "";
- $email = "";
- //Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- //Check connection
- if($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- $name = input($_POST["username"]);
- $userpassword = input($_POST["userpassword"]);
- $email = input($_POST["email"]);
- function input($data) {
- $data = trim($data);
- $data = stripslashes($data);
- $data = htmlspecialchars($data);
- return $data;
- }
- $sql = "CREATE TABLE lab07data (
- username VARCHAR(50) PRIMARY KEY,
- password VARCHAR(50) NOT NULL,
- email VARCHAR(50) NOT NULL
- )";
- if($conn->query($sql) === TRUE) {
- } else {
- echo "Error creating table: " . $conn->error;
- }
- $sql = "INSERT INTO lab07data (username, password, email) VALUES('$name', '$userpassword', '$email')";
- if ($conn->query($sql) === TRUE) {
- echo $email;
- } else {
- echo "Error: " . $sql . "<br>" . $conn->error;
- }
- $conn->close();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement