Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- define('DB_USERNAME','root');
- define('DB_PASSWORD','');
- define('DB_DATABASE','enterprisecoursework');
- $conn = mysqli_connect('localhost', DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die(mysqli_error());
- $dbcon = mysqli_select_db($conn, DB_DATABASE);
- if (!$conn) {
- die("Connection failed: " . mysqli_error());
- }
- echo "connected fine";
- //require('db/db_connect.php');
- // If the values are posted, insert them into the database.
- if (isset($_POST['username']) && isset($_POST['password'])){
- $username = $_POST['username'];
- $email = $_POST['email'];
- $password = $_POST['password'];
- switch($_POST['acc_choice']) {
- case "2":
- $account = $_POST['acc_choice'];
- case "3":
- $account = $_POST['acc_choice'];
- default:
- $account = $_POST['acc_choice'];
- $verified = 1;
- }
- $loggedIn = 0;
- $verified = 0;
- $query = "INSERT INTO 'users' (username, password, email, loggedIn, accountType, verified )
- VALUES('$username', '$password', '$email', '$loggedIn', '$accType', '$verified')";
- $final = mysqli_query($conn, $query);
- if($final){
- $msg = "User Created Successfully.";
- }else{
- $msg = "User Registration Failed";
- }
- echo $msg;
- }
- mysqli_close($conn);
- ?>
- <?php include ('inc/header.php'); ?>
- <body>
- <div class="container">
- <div id="login-form">
- <form method="POST" action="index.php" autocomplete="off">
- <div class="infoContainer">
- <div class="group">
- <h2 class="">Sign Up</h2>
- </div>
- <?php
- if ( isset($errMSG) ) {
- ?>
- <div class="group">
- <div><?php echo ($errTyp=="success") ? "success" : $errTyp; ?></div>
- <span><?php echo $errMSG; ?></span>
- </div>
- </div>
- <?php
- }
- ?>
- <fieldset>
- <div class="input-group">
- <label>Username</label><input type="text" name="name" class="form-control" placeholder="Enter username" maxlength="50" value="" />
- </div>
- <span class="error"></span>
- <div class="input-group">
- <label>Password</label><input type="password" name="pass" placeholder="Enter a password" maxlength="30" value="" />
- </div>
- <span class="error"></span>
- <div class="input-group">
- <label>Email</label><input type="email" name="email" placeholder="Enter Your Email" maxlength="50" value="" />
- </div>
- <span class="error"></span>
- <div class="radios">
- <label>Select an account type</label>
- <select name="acc_choice">
- <option value="1">Shopper</option>
- <option value="2">Photographer</option>
- <option value="3">Admin</option>
- </select>
- <p>Photographer and admin accounts will need to be verified before use. Admin do this within 1 day of registering.</p>
- </div>
- <input type="submit" name="registerBtn"/><br />
- <a href="login.php" style="float: right;">Looking for the login?</a>
- </fieldset>
- </div>
- </form>
- </div>
- </div>
- </div>
- <?php include ('inc/footer.php'); ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement