dongluo9156 2015-10-21 06:40
浏览 51
已采纳

使用PHP和MySQL显示添加的员工的摘要信息[关闭]

I'm beginner in PHP MySQL, I would like to ask if this possible:

I have ADD NEW EMPLOYEE page after I submit, I want to have simple summary information of the added employee like

Something like opening a new window page:

Agent Code: The Agent code of the employee newly added
Name: Name of the Employee
Type: Type of the employee

Here is PHP Code in my ADD NEW EMPLOYEE page:

<?php
session_start();
include_once 'dbconnect.php';

if(!isset($_SESSION['user']))
{
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM accounts WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);



if(isset($_POST['btn-signup']))
{
$agentCode = mysql_real_escape_string($_POST['agentCode']);
$pass = md5(mysql_real_escape_string($_POST['pass']));
$aFName = mysql_real_escape_string($_POST['aFName']);
$aLName = mysql_real_escape_string($_POST['aLName']);
$aMName = mysql_real_escape_string($_POST['aMName']);
$aSuffixName = mysql_real_escape_string($_POST['aSuffixName']);
$aContact = mysql_real_escape_string($_POST['aContact']);
$aAddress = mysql_real_escape_string($_POST['aAddress']);
$aGender = mysql_real_escape_string($_POST['aGender']);
$utype = mysql_real_escape_string($_POST['utype']);
$loctype = mysql_real_escape_string($_POST['loctype']);
$ipadd = mysql_real_escape_string($_POST['ipadd']);


if(mysql_query("INSERT INTO accounts(agentCode, password, agentFname, agentMname, agentLname, aSuffixName, agentContact, agentAddress, agentGender, user_type, location_type, ip_add) 
    VALUES('$agentCode', '$pass', '$aFName', '$aMName', '$aLName', '$aSuffixName', '$aContact', '$aAddress', '$aGender', '$utype', '$loctype', '$ipadd' )"))
{
    ?>

    <script>alert('Successfully added!');</script>

    <?php
  } else {
    ?>
    <script>alert('Agent Code is not available!');</script>
    <?php
   }
   }
  ?>
  • 写回答

2条回答 默认 最新

  • doucheyi1347 2015-10-21 06:49
    关注

    You can do it in 2 ways.

    1) You will have all posted for db from the form which you used to insert the values to you database. You can use same values to display there.

    2) Capture the last insert id, on successfully inserted the data, fetch the data based on that id and display in view.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作