Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- /*$server = 'v.je';
- $username = 'student';
- $password = 'student';
- //The name of the schema we created earlier in MySQL workbench
- //If this schema does not exist you will get an error!
- $schema = 'accounts';*/
- //^^THIS CONNECTS TO THE DATABASE USING A DIFFERENT METHOD^^
- $pdo = new PDO ("mysql:host=v.je;dbname=accounts","student","student");
- [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION];
- //$results = $pdo->query('SELECT * FROM users');
- if(isset($_POST['submit'])){
- $username = $_POST['username'];
- $password = $_POST['password'];
- $email = $_POST['email'];
- $userStatus = $_POST['userStatus'];
- $insert = $pdo->prepare("INSERT INTO users
- (username,password,userStatus,email)
- values(:username,:email,:password,:userStatus) ");
- $insert->bindParam(':username',$username);
- $insert->bindParam(':password',$password);
- $insert->bindParam(':userStatus',$userStatus);
- $insert->bindParam(':email',$email);
- $cmtd = $insert->execute();//committed the insert tasks to the database
- if($cmtd){
- //$_SESSION['email'] = $email;
- // $_SESSION['username'] = $username;
- // $_SESSION['userStatus'] = 'cust';
- header('location:index.php');
- }
- else{
- echo 'Something went wrong!';
- }
- }
- ?>
- <h2>Register Account</h2>
- <form action="form.php" method="POST">
- <label>Username:</label> <input type="text" name="username" />
- <label>Password:</label> <input type="text" name="password" />
- <label>Email:</label> <input type="text" name="email" />
- <input type="hidden" name="userStatus" value="cust">
- <input type="submit" name="submit" value="Register" />
- <p>
- Already a member? <a href="/assignment/login.php">Login</a>
- </p>
- </form>
Add Comment
Please, Sign In to add comment