New to coding . tried to create a database that stores details for an advertisement . the php works fine till the end . but the output always shows not inserted . could someone please help me out ?? the form and php are given here .
<html>
<body>
<form action="basic.php" method="post">
Name: <input type="text" name="adtitle"></input><br>
Name: <input type="text" name="sellersname"></input><br>
Name: <input type="text" name="email"></input><br>
Name: <input type="text" name="description"></input><br>
Name: <input type="text" name="noo"></input><br>
Name: <input type="text" name="base"></input><br>
Name: <input type="text" name="cutoff"></input><br>
<input type="submit"></input>
</form>
</body>
</html>
<?php
$serverName = "127.0.0.1";
$userName = "root";
$password = "";
$database = "demo";
$con = mysqli_connect($serverName, $userName, $password, $database);
if(!$con)
{echo 'not connected';}
if(!mysqli_select_db($con,'demo'))
{echo'db not selected';
}
$Title = $_POST['adtitle'];
$Sname= $_POST['sellersname'];
$email = $_POST['email'];
$Description = $_POST['description'];
$Mobileno = $_POST['noo'];
$Base = $_POST['base'];
$Cutoff = $_POST['cutoff'];
$sql = "INSERT INTO advert (Title,Seller name,email,Description,Number,Base,Cutoff)VALUES('$Title','$Sname','$email','$Description','$Mobileno','$Base','$Cutoff')";
if(!mysqli_query($con,$sql))
{echo'not inserted';}
else {echo'innserted';}
?>
echo'not inserted';check for errors, php.net/manual/en/mysqli.error.php. You also are open to SQL injections with this code which code be the cause of your current issue.