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 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用