I'm using a function in which I'm assigning a variable a tablename
value like:
function mshirt(){
var tbname='m_shirts';
}
Then in PHP form action section:
include 'database_connection.php';
$tablename=tbname;
if(isset($_POST['submit'])){
$Size=$_POST['size'];
$Color=$_POST['color'];
$Code=$_POST['code'];
$Brand=$_POST['brand'];
$sql="INSERT INTO `$tablename` (size,color,code,brand) VALUES('$Size','$Color','$Code','$Brand')";
if(mysqli_query($conn,$sql)){
echo("Added Succesfully");
}
else
echo("Failed to Add");
The problem is that it assumes tbname
to be undefined constant.