I have a database that is linked with the php. When I'm writing the first code, my web page gets redirected to the page 'mypage1.php'. But when I'm writing the second code, which is almost(exactly) the same, it doesn't get redirected to the mypage1.php. In the table inside my database, I have Orderid's that I'm using to relate to the php code. Could you tell me why doesn't the second code redirects to the same page? (It stays on the same page). The web page gets redirected to the mypage1.php when I am removing the text areas code from the 2nd code, particularly when I'm removing this code:
<input type='textarea' name='staffname'>
</td><td>
<input type='textarea' name='Time'>
</td><td>
<input type='textarea' name='custdetail'>
</td><td>
<input type='textarea' name='orderId'>
CODE 1 (PHP CODE): echo "";
echo "<tr>";
echo "<td>idSpatula</td><td>Qauntity</td><td>Staff Name</td><td>Staff Id</td><td>Customer Details</d><td>Order Id</td>";
echo "</tr>";
echo "<tr>";
echo "<form >";
echo "<td>" ."Spatula Id=3"."</td><td>
<input type='textarea' name='3'>
</td><td>
<input type='textarea' name='staffname'>
</td><td>
<input type='textarea' name='Time'>
</td><td>
<input type='textarea' name='custdetail'>
</td><td>
<input type='textarea' name='orderId'>
<input type='submit' id='submit' value='submit'>
</td>
</form>";
echo "</tr>";
echo "</table>";
echo "</br>";
if(isset($_GET['3'])){
// means submit clicked!
$queryy3=0;
$queryy3 = $_GET['3'];
header('Location: mypage1.php');
$sqll3 = "UPDATE Spatula SET QuantityInStock=QuantityInStock-$queryy3 WHERE idSpatula=3 and QuantityInStock>0";
$sqlorder3 = "insert into `Order`(idOrder, RequestedTime, ResponsibleStaffMember, CustomerDetails) values (3,'1987-04-20 11:34:09','Shubhams','tell')";
$result1003 = mysqli_query($con, "SELECT QuantityInStock FROM Spatula where idSpatula=3");
mysqli_query($con, $sqlorder2);
if (mysqli_query($con, $sqll3) & $col1003['QuantityInStock']!=0 ) {
//$sql = "UPDATE Spatula SET QuantityInStock=QuantityInStock-$query WHERE idSpatula= and QuantityInStock>0";
echo "Updated";
}
while($col1003 = mysqli_fetch_array($result1003)) {
echo $col1003['QuantityInStock'];
if ($col1003['QuantityInStock']<=0){
header('Location: mypage2.php');
}
}
}
CODE 2:
echo "<table border='1'>";
echo "<tr>";
echo "<td>idSpatula</td><td>Qauntity</td><td>Staff Name</td><td>Staff Id</td><td>Customer Details</d><td>Order Id</td>";
echo "</tr>";
echo "<tr>";
echo "<form >";
echo "<td>" ."Spatula Id=4"."</td><td>
<input type='textarea' name='4'>
</td><td>
<input type='textarea' name='staffname'>
</td><td>
<input type='textarea' name='Time'>
</td><td>
<input type='textarea' name='custdetail'>
</td><td>
<input type='textarea' name='orderId'>
</td>
<input type='submit' id='submit' value='submit'>
</form>";
echo "</tr>";
echo "</table>";
if(isset($_GET['4'])){
// means submit clicked!
$queryy4=0;
$queryy4 = $_GET['4'];
header('Location: mypage1.php');
$sqll4 = "UPDATE Spatula SET QuantityInStock=QuantityInStock-$queryy4 WHERE idSpatula=4 and QuantityInStock>0";
$sqlorder4 = "insert into `Order`(idOrder, RequestedTime, ResponsibleStaffMember, CustomerDetails) values (5,'1987-04-20 11:34:09','Shusss','tss')";
$result1004 = mysqli_query($con, "SELECT QuantityInStock FROM Spatula where idSpatula=4");
mysqli_query($con, $sqlorder4);
if (mysqli_query($con, $sqll4) & $col1004['QuantityInStock']!=0 ) {
echo "Updated";
}
while($col1004 = mysqli_fetch_array($result1004)) {
echo $col1004['QuantityInStock'];
if ($col1004['QuantityInStock']<=0){
header('Location: mypage2.php');
}
}
}