• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

How to insert data in two tables at the same time (SQL server)

Joined
Feb 28, 2016
Messages
1
<?php
include 'conn.php';
$affected_rows = $conn->exec("INSERT into tbl_ideas1 (week_no,category,problem,solution,id_no) Values ('".$_POST["week_no"]."','".$_POST["category"]."','".$_POST["problem"]."','".$_POST["solution"]."','".$_POST["id_no"]."')");


$affected_rows = $conn->exec("Insert into tbl_sub (idea_no,week_no,category,problem,solution,id_no) Values ('".$idea."','".$_POST["week_no"]."','".$_POST["category"]."','".$_POST["problem"]."','".$_POST["solution"]."','".$_POST["id_no"]."')");

/* $affected_rows = $conn->exec("INSERT into tbl_sub (week_no,category,problem,solution,Fname,Mname,Lname,building,cluster,id_no) Values ('".$_POST["week_no"]."','".$_POST["category"]."','".$_POST["problem"]."','".$_POST["solution"]."','".$_POST["Fname"]."','".$_POST["Mname"]."','".$_POST["Lname"]."','".$_POST["building"]."','".$_POST["cluster"]."','".$_POST["id_no"]."')"); */


echo "<script language=\"Javascript\">alert('Submitted Successfully!');self.location=\"send_ideas.php\"</script>";
?>
 
Thats some of the worst code I've ever seen - and I've seen a lot of bad php. Sheesh.
 
Nothing in that indicates it needs to be "at the same time"..

... Also use parameters.
 
xkcd: Exploits of a Mom
bc8Be4b.png
 
Keep in mind incoming $_POST can be crafted without the need for a html form. So, client side checks are useless.
Also, you could try "read locking" the table for the time you're inserting. There are tutorials.
It will still be readable but not writeable.
 
Back
Top