I'm having a very strange issue here. I have this code here which is 100% functioning on my localhost but when I host it to godaddy the insert command doesn't function while the select command functions. Code below
Register.php
<!DOCTYPE html>
<html>
<head>
<title>Doc Title</title>
</head>
<body class="signup-page" style="background-color:#f5cf00;">
<div class="signup-box">
<div class="logo">
<h1>
<?php
ob_start();
include 'includes/connect.php';
$error = false;
if ( isset($_POST['sign_up']) )
{
// clean user inputs to prevent sql injections
$user_name = trim($_POST['user_name']);
$user_name = strip_tags($user_name);
$user_name = htmlspecialchars($user_name);
$gender = trim($_POST['gender']);
$gender = strip_tags($gender);
$gender = htmlspecialchars($gender);
$dob = trim($_POST['dob']);
$dob = strip_tags($dob);
$dob = htmlspecialchars($dob);
$email = trim($_POST['email']);
$email = strip_tags($email);
$email = htmlspecialchars($email);
$country = trim($_POST['country']);
$country = strip_tags($country);
$country = htmlspecialchars($country);
$phone = trim($_POST['phone']);
$phone = strip_tags($phone);
$phone = htmlspecialchars($phone);
$username = trim($_POST['username']);
$username = strip_tags($username);
$username = htmlspecialchars($username);
$password = trim($_POST['password']);
$password = strip_tags($password);
$password = htmlspecialchars($password);
// if there's no error, continue to signup
if( !$error ) {
$query = "INSERT INTO users
(user_role,user_name,gender,dob,email,country,phone,username,password,added_by, added_date)
VALUES
('User','$user_name','$gender','$dob','$email','$country','$phone','$username', '$password','Register Page',now())";
$res = mysqli_query($con,$query);
if ($res)
{
$errTyp = "success";
$errMSG = "Registration Successful, You can now login.";
echo $errMSG;
}
else
{
$errTyp = "danger";
$errMSG = "Something went wrong, try again later...";
}
}
}
?>
</h1>
</div>
<div class="card">
<div class="body">
<form id="sign_up" action="register.php" method="POST">
<div class="msg">Register a new membership</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">person</i>
</span>
<div class="form-line">
<input type="text" class="form-control" name="user_name" placeholder="Full Name" required autofocus>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">group</i>
</span>
<div class="form-line">
<select name="gender" class="form-control show-tick">
<option value="">-- Select Gender --</option>
<option value="Male">Male</option>
<option value="Female">Female</option>
</select>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">date_range</i>
</span>
<div class="form-line">
<input name="dob" type="date" class="form-control" placeholder="Please choose a date...">
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">email</i>
</span>
<div class="form-line">
<input type="text" class="form-control" name="email" placeholder="Email" required autofocus>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">my_location</i>
</span>
<div class="form-line">
<select name="country" class="form-control show-tick">
<option value="">-- Select Country --</option>
<option value="country_1">country 1</option>
<option value="country_2">country 2</option>
</select>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">phone</i>
</span>
<div class="form-line">
<input name="phone" type="text" class="form-control" name="namesurname" placeholder="number" required autofocus>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">person</i>
</span>
<div class="form-line">
<input name="username" type="text" class="form-control" name="namesurname" placeholder="Username" required autofocus>
</div>
</div>
<div class="input-group">
<span class="input-group-addon">
<i class="material-icons">lock</i>
</span>
<div class="form-line">
<input name="password" type="password" class="form-control" name="namesurname" placeholder="Password" required autofocus>
</div>
</div>
<button name="sign_up" class="btn btn-block btn-lg bg-pink waves-effect" type="submit">SIGN UP</button>
<div class="m-t-25 m-b--5 align-center">
<a href="login.php">You already have a membership?</a>
</div>
</form>
</div>
</div>
</div>
</body>
</html>
Database:
CREATE TABLE `users` (
`user_id` int(11) NOT NULL,
`user_role` varchar(255) NOT NULL,
`user_name` varchar(255) NOT NULL,
`gender` varchar(255) NOT NULL,
`dob` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
`country` varchar(255) NOT NULL,
`city` varchar(255) NOT NULL,
`phone` varchar(255) NOT NULL,
`username` varchar(255) NOT NULL,
`password` varchar(255) NOT NULL,
`added_by` varchar(255) NOT NULL,
`added_date` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
I hope my question was clear and any help or support identifying the problem is appreciated.
EDIT: My connect.php file when uploaded
<?php
$con = mysqli_connect('localhost','user here','pass here');
if (empty($con)) {
echo mysqli_error();
}
$data = mysqli_select_db($con,"dbname here");
if (empty($data)) {
echo mysqli_error();
}
?>