-
-
Save emmykolic/895e9c9042e05542e94ba69a652f061e to your computer and use it in GitHub Desktop.
Here is the peices of code that validate's the form.php page
This file contains 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 'config.php'; | |
$error = 0; | |
$error_msg=""; | |
if (isset($_POST['submit'])) { | |
$fullname = get_post("fullname"); | |
$gender = get_post("gender"); | |
$email = get_post("email"); | |
if ($fullname == "") { | |
$error = 1; | |
$error_msg.="fullname is Empty"; | |
} | |
if ($gender == "") { | |
$error = 1; | |
$error_msg.="gender is Empty"; | |
} | |
if ($email == "") { | |
$error = 1; | |
$error_msg.="email is Empty"; | |
} | |
$check=$db->query("SELECT * FROM users WHERE email='$email' OR fullname='$fullname'"); | |
if($check->num_rows>0){ | |
$error=1; | |
$error_msg.="your Email or Fullname is already in use <br>"; | |
} | |
} | |
if($error==0){ | |
$db->query("INSERT INTO users(fullname, gender, email) VALUES('$fullname','gender', '$email')"); | |
set_alert("success", "your registration was successful"); | |
header("location:form.php"); | |
}else{ | |
set_alert("danger", $error_msg); | |
header("location:index.php"); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment