So I'm making a register page for a website. and I have to send data to that database. The problem is that the database is being hosted and I don't know how to connect to it. this is my code so far : (Note that I did leave out the password for security reasons.)
if(isset($_POST['register'])){
if(isset($_POST['voornaam'], $_POST['tussenvoegsel'],
$_POST['achternaam'], $_POST['straat'], $_POST['huisnummer'],
$_POST['postcode'], $_POST['woonplaats'], $_POST['telefoon'],
$_POST['mobiel'], $_POST['e-mail'], $_POST['wachtwoord'],
$_POST['rekeningnummer']))
{
//personal info
$voornaam = $_POST['voornaam'];
$tussenvoegsel = $_POST['tussenvoegsel'];
$achternaam = $_POST['achternaam'];
//contact info
$straat = $_POST['straat'];
$huisnummer = $_POST['huisnummer'];
$postcode = $_POST['postcode'];
$woonplaats = $_POST['woonplaats'];
$telefoon = $_POST['telefoon'];
$mobiel = $_POST['mobiel'];
//account info
$wachtwoord = $_POST['wachtwoord'];
$hash = password_hash($wachtwoord, PASSWORD_BCRYPT);
$email = $_POST['e-mail'];
$rekeningnummer = $_POST['rekeningnummer'];
//link naar remote database.
$link = mysqli_connect("databases.000webhost.com", "", "", "");
if(mysqli_connect_errno())
{
printf("Connect failed: %s\n", mysqli_connect_errno());
exit();
}
$sql = "INSERT INTO users (username, password, Tussenvoegsel, Achternaam, Straat, Huisnummer, Postcode, Woonplaats, Telefoon, Mobiel, Email, Rekeingnummer)
VALUES('$voornaam', '$hash', '$tussenvoegsel', '$achternaam', '$straat', '$huisnummer', '$postcode', '$woonplaats', '$telefoon', '$mobiel', '$email', '$rekeningnummer')";
mysqli_query($link, $sql);
mysqli_close($link);
}
}
this code gives me an error. the error says :
A connection attempt failed because the connected party did not respond correctly after a certain period of time, or the connection that was made failed because the connected host did not respond
I hope someone can help me with this. I've been stuck here for some time now.