May be i didn't ask well Let's say i have two forms
<form action="reg.php" method="post" enctype="multipart/form-data">
<input type="text" name="reg_as" id="export" value="exporter">
<input type="submit" name="reg">
</form>
<form action="reg.php" method="post" enctype="multipart/form-data">
<input type="text" name="reg_as" id="import" value="importer">
<input type="submit" name="reg">
</form>
How do i insert into multiple tables with if else conditions reg.php
$reg_as = strip_tags(@$_POST['reg_as']);
$reg = strip_tags(@$_POST['reg']);
$exporter = "exporter";
$importer = "importer";
if ($reg)
{
if ($reg_as == $exporter)
{
$sql =<<<EOF
INSERT INTO exporter (reg_as)
VALUES ('$reg_as');
EOF;
$stmt = $db->exec($sql);
if (!$stmt)
{
echo "<script>alert('There was an error some where!.. Please try again')</script>";
}
else
{
header("Location: index.php");
}
if ($reg_as == $importer) {
$sql = <<<EOF
INSERT INTO importer (reg_as)
VALUES ('$reg_as');
EOF;
}
$stmt = $db->exec($sql);
if (!$stmt)
{
echo "<script>alert('There was an error some where!.. Please try again')</script>";
}
else
{
header("Location: index.php");
}
}
The issue here is that, the data dosn't insert to database. Please what could be wrong?