<?php
ini_set('error_reporting', E_ALL);
//create empty Variable
$username= $password= $email="";
//check the field is not empty
if (empty(($_POST["Username"]))) {
echo "Username should not be empty";
} else {
if (!empty(($_POST["Username"]=="/^[a-zA-Z0-9_-.]{3,15}$/"))) {
echo "Username should contain character,number,dash,underscore,dot only";
}
}
if (empty(($_POST["Password"]))) {
echo "password should not be empty";
} else {
if (!empty(($_POST["Password"]=="/^[a-zA-z0-9@]{3,15}$/"))) {
echo "Password should contain character,number,@ only";
}
}
if (empty($_POST["Email"])) {
echo "Email field should not be empty";
} else {
// check if e-mail address is well-formed
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$email = "Invalid email format";
}
}
//connect to Mysql Database
$servername = "localhost";
$username = "";
$password = "";
$dbname = "";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$conn->select_db("spinjobs");
//check if the username already exits in database table
if(isset($_POST["$username"]) && $_POST["$username"] != ""){
$sql_username = mysqli_query("SELECT id FROM newuser WHERE username='$username' LIMIT 1");
$username = mysqli_num_rows($sql_username);
if ($username < 1) {
echo '<strong>' . $username . '</strong> is OK';
exit();
} else {
echo '<strong>' . $username . '</strong> is taken';
exit();
}
}
$query = "INSERT INTO `newuser` ( `username`, `email`, `password`) VALUES ( '$username', '$email', '$password')";
$result = mysqli_query($conn, $query);
if (mysqli_affected_rows($conn) == 1) { //If the Insert Query was successfull.
// Send an email
$from = 'donotreply@spinfonet.com';
$to = $email;
$subject ='You are successfully Registered with us';
$message = 'Your $username, $password\r\n Please preserve this mail for your reference';
mail($from, $to, $subject, $message);
}
mysqli_close($conn);
?>
I am using GoDaddy as web host and upload this code file to my webhost space. I have Linux operating system with web host, while I type code on Notepad++ in Windows 10.
When I test my page in browser after filling record in HTML page and submit browser shows blank page, I have checked my PHP code with some of free online code testing website. This website do not find any mistake in code, can you guide what should be the mistake?
GoDaddy gives three version of PHP 5.4, 5.5, and 5.6. I have selected 5.6, 5.4 and 5.5 also have given blank page.