I've created an update page, where users can update their cards. It's working fine on localhost, but I just uploaded it to 000webhostapp and my database doesn't update. I don't get any errors, or anything, it just doesn't update it. I'm using Xampp for the localhost. My update code:
<?php
session_start();
define('DB_SERVER', 'localhost');
define('DB_USERNAME', '1');
define('DB_PASSWORD', '2');
define('DB_NAME', '3');
if(!isset($_SESSION["loggedin"]) || $_SESSION["loggedin"] === false){
header("Location: login.php");
} else {
$mysqli = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
mysqli_set_charset($mysqli, "utf8");
if($mysqli === false){
die("failed to connect. " . mysqli_connect_error());
}
$id = $_GET['id'];
if (isset($_POST['sub'])) {
$name = $_POST['name'];
$phone = $_POST['phone'];
$phone2 = $_POST['phone2'];
$email = $_POST['email'];
$zipcode = $_POST['zipcode'];
$address = $_POST['address'];
$company = $_POST['company'];
$job = $_POST['job'];
$description = $_POST['description'];
$userid = $_SESSION['id'];
if (
strlen($name) < 31 &&
strlen($job) < 51 &&
strlen($zipcode) < 5 &&
strlen($email) < 51 &&
strlen($phone) < 21 &&
strlen($phone2) < 21 &&
strlen($address) < 51 &&
strlen($company) < 51 &&
strlen($description) < 501) {
$stmt = $mysqli -> prepare('UPDATE cards SET name=?, phone=?, phone2=?, email=?, zipcode=?, address=?, company=?, job=?, description=?, visibility=?, confirmed=? WHERE id = ?');
$stmt->bind_param('ssssissssiii', $name, $phone, $phone2, $email, $zipcode, $address, $company, $job, $description, $visibility, $confirmed, $id);
$success = $stmt -> execute();
if ($success) {
echo "Sikeres módosítás!";
}
} else {
echo $mysqli -> error;
}
}
$getstmt = $mysqli->prepare("SELECT * FROM cards WHERE id= ?");
if ($getstmt and
$getstmt->bind_param('i', $id) and
$getstmt->execute() and
$result = $getstmt->get_result() and
$row = $result->fetch_assoc()
) {
if($row['userid'] == $_SESSION['id']){
$name = $row['name'];
$phone = $row['phone'];
$phone2 = $row['phone2'];
$email = $row['email'];
$zipcode = $row['zipcode'];
$address = $row['address'];
$company = $row['company'];
$job = $row['job'];
$description = $row['description'];
}else{
header("Location: index.php");
}
?>
It is so frustrating because I have absolutely no idea why it doesn't work there if it's working on localhost...