Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- ini_set('display_error', 1); // error display should come first
- error_reporting(E_ALL); // error display should come first
- require_once("database.php");
- //define variables and initialize with empty values
- $firstnameError = $lastnameError = $emailError = $confirmemailError = "";
- $firstname = $lastname = $email = $confirmemail = '';
- if ($_POST['register']) { // $_POST['register'] instead
- if (empty($_POST['firstname'])) {
- $firstnameError = "field required";
- } else {
- $firstname = $_POST['firstname'];
- }
- if (empty($_POST['lastname'])) {
- $lastnameError = "field required";
- } else {
- $lastname = $_POST['lastname'];
- }
- if (empty($_POST['email'])) {
- $emailError = "field required";
- } else {
- $email = $_POST['email'];
- }
- if (empty($_POST['confirmemail'])) {
- $confirmemailError = "field required";
- } else {
- $confirmemail = $_POST['confirmemail'];
- }
- }
- ?>
- <form method="POST" action="">
- <div class="form-group">
- <label>First Name</label>
- <input type="text" class="form-control" placeholder="Enter first name" name="firstname" value="<?php echo htmlspecialchars($firstname);?>">
- <span class="error"><?php echo $firstnameError;?></span>
- </div>
- <div class="form-group">
- <label>Last Name</label>
- <input type="text" class="form-control" placeholder="enter last name" name="lastname" value="<?php echo htmlspecialchars($lastname);?>">
- <span class="error"><?php echo $lastnameError;?></span>
- </div>
- <div class="form-group">
- <label>Email</label>
- <input type="email" class="form-control" placeholder="enter email" name="email" value="<?php echo htmlspecialchars($email);?>">
- <span class="error"><?php echo $emailError; ?></span>
- </div>
- <div class="form-group">
- <label>Confirm Email</label>
- <input type="email" class="form-control" placeholder="confirm email" name="confirmemail" value="<?php echo htmlspecialchars($confirmemail);?>">
- <span class="error"><?php echo $confirmemailError; ?></span>
- </div>
- <button type="submit" class="btn btn-default" name="register" value="submit">REGISTER</button> <!-- don't use camel case for form names -->
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement