Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/82.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何在如图所示的表格中插入上一页的tusername_Php_Html_Sql - Fatal编程技术网

Php 如何在如图所示的表格中插入上一页的tusername

Php 如何在如图所示的表格中插入上一页的tusername,php,html,sql,Php,Html,Sql,我有一个页面,在那里我发送tusername,然后在第二个页面上创建表单。 我想使用该表单在表中添加多个数据。当请求id并由us输入sub_代码时,表将保存如下数据 我想这可以帮到你 <?php include("db.php"); // Lets test if the form has been submitted if(isset($_POST['SubmitCheck'])) { // The form has been submited $tusername

我有一个页面,在那里我发送tusername,然后在第二个页面上创建表单。 我想使用该表单在表中添加多个数据。当请求id并由us输入sub_代码时,表将保存如下数据


我想这可以帮到你

<?php

include("db.php");

// Lets test if the form has been submitted

 if(isset($_POST['SubmitCheck'])) {
 // The form has been submited
     $tusername =$_REQUEST['tusername'];

foreach($_POST['sub_code'] as $sub_code) {
                        //insert your data

  @mysql_query("update INTO `techsub`(sub_code, tusername) 
 VALUES ('$sub_code','$tusername') where tusername='$tusername'"); 

 }

    }

else {
    // The form has not been posted
    }
?>
<form id="Form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

    Subject One: <input type="text" name="sub_code[1]"><br>
    Subject Two: <input type="text" name="sub_code[2]"><br>
    Subject Three:<input type="text" name="sub_code[3]"><br>
    Subject Four: <input type="text" name="sub_code[4]"><br>

    <input type="hidden" name="SubmitCheck" value="Assign">
    <input type="Submit" name="Form1_Submit" >
</form>

可爱的漏洞。享受你的服务器pwn3d。我不会把它上传到服务器上。这是一个学校项目。不走运,先生,单击提交后第9行“$tusername=$\u请求['tusername'];”中出现错误。因为它想在提交后重新命名。如何使用提交表单发送tusername。@JasjeetSingh您从哪里获得tusername的价值?您是否声明了任何会话变量?
<?php

include("db.php");

// Lets test if the form has been submitted

 if(isset($_POST['SubmitCheck'])) {
 // The form has been submited
     $tusername =$_REQUEST['tusername'];

foreach($_POST['sub_code'] as $sub_code) {
                        //insert your data

  @mysql_query("update INTO `techsub`(sub_code, tusername) 
 VALUES ('$sub_code','$tusername') where tusername='$tusername'"); 

 }

    }

else {
    // The form has not been posted
    }
?>
<form id="Form1" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

    Subject One: <input type="text" name="sub_code[1]"><br>
    Subject Two: <input type="text" name="sub_code[2]"><br>
    Subject Three:<input type="text" name="sub_code[3]"><br>
    Subject Four: <input type="text" name="sub_code[4]"><br>

    <input type="hidden" name="SubmitCheck" value="Assign">
    <input type="Submit" name="Form1_Submit" >
</form>