Data cannot insert in to the database

HI, I just create site for learning purpose data cannot insert into the database, but when I run the code in local it works, please help me.
Url - http://asadathome.000webhostapp.com/usersingup.php
Thanks & Regards
Toufik

Which issues do you face?

We can’t really assist with coding as such and only hosting issues, I’ve checked your DB and account and it can insert without issue.

I think is issue whit your host, Because same code executive properly in my local machine.

I share the code plese have a look.

<?php 
	$host = 'localhost';
	$user = 'id12402477_asadathome';
	$pass = 'asadathome';
	$db = 'id12402477_asadathome';

	$con = mysqli_connect($host,$user,$pass,$db);
	
if (!$con) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}

?>
<html>
<body>
		<form method="POST">
			<p>Name:
				<input type="text" name="username">
			</p>
			<p>
				Email:
				<input type="email" name="useremail">
			</p>
			<p>
				Password:
				<input type="password" name="userpass">
			</p>
			<input type="submit" name="singupsub">
		</form>

<?php
	if(isset($_POST['singupsub']))
	{
		mail("felixraj44@gmail.com","Success","Send mail from localhost using PHP");
		$username= $_POST['username'];
		$useremail= $_POST['useremail'];
		$userpass= $_POST['userpass'];
		$userverifycode = rand(0,999999);
        
		$qr = "INSERT INTO user_singup (name,email,password,verify_code) VALUES ('$username','$useremail','$userpass','$userverifycode')";

		$ex = mysqli_query($con,$qr);
		
		echo '<pre>';
		print_r($ex);
		echo '</pre>';
		
		var_dump($ex);

		if($ex==1)
		{
			?>
				<script>
					alert("Sing Up Scessfull");
				</script>
			<?php

		}
		else
			{
			?>
				<script>
					alert("Sing Up Error");
				</script>
			<?php
		}
	}
?>

	</body>
</html>

Maybe change PHP to match that of local machine?

1 Like

hmm i also do that currently it set 5.6 but still code do now work

HI, It IS solver now thanks for support