Initial Setup with basic SQL Register.
This commit is contained in:
commit
6f01c507be
21
index.php
Normal file
21
index.php
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
$con = mysqli_connect("localhost", "root", "", "social");
|
||||||
|
|
||||||
|
if(mysqli_connect_errno()) {
|
||||||
|
echo "Failed to connect to database: " . mysqli_connect_errno();
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = mysqli_query($con, "INSERT INTO test VALUES(NULL,'Jonathan')");
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hello World</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<h1>Hello World!</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
82
register.php
Normal file
82
register.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<?php
|
||||||
|
$con = mysqli_connect("localhost", "root", "", "social");
|
||||||
|
|
||||||
|
if(mysqli_connect_errno()) {
|
||||||
|
echo "Failed to connect to database: " . mysqli_connect_errno();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Variables declaration to prevent errors
|
||||||
|
$fname = "";
|
||||||
|
$lname = "";
|
||||||
|
$email = "";
|
||||||
|
$email_conf = "";
|
||||||
|
$pass = "";
|
||||||
|
$pass_conf = "";
|
||||||
|
$date = ""; // Registration Date
|
||||||
|
$errors = ""; // Used to hold any errors.
|
||||||
|
|
||||||
|
if(isset($_POST['register_but'])) {
|
||||||
|
// Variable Assignments
|
||||||
|
|
||||||
|
// *** strip_tags() is used to prevent html injection. *** //
|
||||||
|
$fname = strip_tags($_POST['reg_fname']); //Sets the value from the forum.
|
||||||
|
$fname = str_replace(' ', '', $fname); // Removes any spaces.
|
||||||
|
$fname = ucfirst(strtolower($fname)); // Capitalizes first letter, lowercases the rest.
|
||||||
|
|
||||||
|
$lname = strip_tags($_POST['reg_lname']);
|
||||||
|
$lname = str_replace(' ', '', $lname);
|
||||||
|
$lname = ucfirst(strtolower($lname));
|
||||||
|
|
||||||
|
$email = strip_tags($_POST['reg_email']);
|
||||||
|
$email = str_replace(' ', '', $email);
|
||||||
|
$email = strtolower($email);
|
||||||
|
|
||||||
|
$email_conf = strip_tags($_POST['reg_email_conf']);
|
||||||
|
$email_conf = str_replace(' ', '', $email_conf);
|
||||||
|
$email_conf = strtolower($email_conf);
|
||||||
|
|
||||||
|
$pass = strip_tags($_POST['reg_pass']);
|
||||||
|
$pass = str_replace(' ', '', $pass);
|
||||||
|
|
||||||
|
$pass_conf = strip_tags($_POST['reg_pass_conf']);
|
||||||
|
$pass_conf = str_replace(' ', '', $pass_conf);
|
||||||
|
|
||||||
|
$date = date(Y-m-d); // Sets the registration date.
|
||||||
|
|
||||||
|
if ($email == $email_conf) {
|
||||||
|
if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
$email = filter_var($email, FILTER_VALIDATE_EMAIL);
|
||||||
|
} else {
|
||||||
|
echo "invalid format";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "The email's do not match.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Meme Machine</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<form action="register.php" method="POST">
|
||||||
|
<input type="text" name="reg_fname" placeholder="First Name" required>
|
||||||
|
<br>
|
||||||
|
<input type="text" name="reg_lname" placeholder="Last Name" required>
|
||||||
|
<br>
|
||||||
|
<input type="email" name="reg_email" placeholder="Email" required>
|
||||||
|
<br>
|
||||||
|
<input type="email" name="reg_email_conf" placeholder="Confirm Email" required>
|
||||||
|
<br>
|
||||||
|
<input type="password" name="reg_pass" placeholder="Password" required>
|
||||||
|
<br>
|
||||||
|
<input type="password" name="reg_pass_conf" placeholder="Confirm Password" required>
|
||||||
|
<br>
|
||||||
|
<input type="submit" name="register_but" value="Register">
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user