这是用户在其中输入数据的表单。
<form action="addemployee.php" method="POST" id="addEmployeeToDataBase">
<input type="text" name="username" placeholder="UserName..." class="txtInput" required="" />
<input type="text" name="fullname" placeholder="Full Name..." class="txtInput" required="" />
<br />
<input type="email" name="email" placeholder="Email Address..." class="txtInput" required="" />
<input type="password" name="password" placeholder="Password..." class="txtInput" required="" />
<br />
<select name="dept" id="txtInput">
<option value="-1">Select Department</option>
<option value="Back-Office">Back-Office</option>
<option value="HR">HR</option>
<option value="Marketing">Marketing</option>
<option value="Sales">Sales</option>
<option value="Technical">Technical</option>
</select>
<br />
<input type="text" name="address" placeholder="Address..." class="txtInput" required=""/>
<input type="text" name="city" placeholder="City..." class="txtInput" required="" />
<br />
<input type="text" name="pincode" placeholder="Pin/Postal/Zip Code..." class="txtInput" required="" />
<input type="text" name="country" placeholder="Country..." class="txtInput" required="" />
<br />
<p style="font-size: 17px;" />Date of Joining:<input type="date" name="joiningdate" placeholder="Joining Date" class="txtInput" required="" />
<br />
<input type="submit" name="submit" id="submit" value="Add Employee"/>
现在我想使用 sql 语句,输入的数据将同时发送到不同的表。
Table employee (emp_id, username, email, password, dept, address, city, pincode, country and joiningdate).
Table dept (dept_id, dept_name, dept_head, and emp_id).
这种形式基本上插入到雇员表中。
现在的“问题”是我想将单个表单的数据分别插入到employee和dept表中,其中表单中dept的输入数据也应该插入到dept表的dept_name列中,并且还应该更新emp_id带有输入数据的部门表。
请指导我完成这个。