I'm a rookie amateur trying to build my own site that uses PHP and a backend SQL database. Having got all my pages working with the database on an Apache II localhost, I have now moved my files to a commercial hosting service. Post migration, some of the pages have gone blank. I have narrowed the problem down to a block of php code that runs as follows:
<?php
if (isset($_POST['submit3'])) {
$email = htmlentities($_POST['email']);
$password = htmlentities($_POST['password']);
if (empty($email) || empty($password)) {
echo <<<EOF
<script type="text/javascript">
$(".welcome").hide();
$("#form3").hide();
$("#error").show();
</script>
EOF;
}
else {
$sql = "SELECT `email` FROM `Registrations` WHERE `email` = '".$email."' AND `password` = '".$password."'";
$rs = $connection->query($sql);
if ($rs->num_rows === 0) {
echo <<<EOF
<script type="text/javascript">
$(".welcome").hide();
$("#form3").hide();
$("#nomatch").show();
</script>
EOF;
}
else {
$_SESSION["email"] = "$email";
echo <<<EOF
<script type="text/javascript">
window.location = "PharMEdCentral-MyAccount.php";
</script>
EOF;
}
$rs->free();
}
}
?>
The html renders well when these two lines are commented out, but I get blank page with these line in. It's probably a silly thing but I have been unable to figure out what mistake I'm making. The problem is not with the connection to the database as other pages with the same connection are rendered properly.
The server version is MySQL 5.6.26 via UNIX socket.
Would highly appreciate any tips on how to fix this!