都返回" moreEdu"在URL中,如何以单一形式使用两个按钮?

时间:2018-03-30 12:12:52

标签: php html5

这是我的表单我希望通过单击“保存/添加更多”按钮再次显示多个值的表单,然后单击下一步按钮移动到下一个信息。

   <?php
        }
        if(isset($_GET['edu']) OR isset($_GET['moreEdu']))
        {
    ?>

    <div style="box-shadow:0 0 10px #CCC; width:53%; margin:0% 24%">
    <form name="jobInfo" action="jobScript.php" method="post">
        <table>
        <tr>
        <td><strong>Education</strong></td><tr><td style="font-size:12px">(Can add Multiple records)</td></tr>
        </tr>
        <tr>
        <td><input type="text" size="16"  required="required" placeholder="Degree Name" name="degree" ></td>
        <td><input type="text" size="16" required="required"  name="institute" placeholder="College/Institute."></td>
        <td><input type="date" size="16" required="required"  name="completionYear" placeholder="Completion Year." ></td>
        <td><input type="text" size="16"  required="required"  name="grade" placeholder="Grade." ></td>
        <td><button style="background:#399" type="submit" name="btn_add_more_edu">Save/Add More</button></td>
        <td><button style="background:#399" type="submit" name="btn_save_edu" formaction="/jobScript.php" >Next</button></td>

        </tr>
        </table>
    </form>  
    </div>

我的代码从这里开始...这里我想在$ _GET中发送moreEdu以在索引页面中显示用于插入更多记录的表单...或者移动到表单的下一个信息。

    class jobScript extends connect {

        public function insert($table,$fields)
        {
                $sql= "";
                $sql .="insert into " . $table;
                $sql .= "(" .implode(",", array_keys($fields)) . ") values ";
                $sql .= "('".implode("','" ,array_values($fields)) . "')" ;
                $query= mysqli_query($this->conn, $sql);
                if($query)
                {
                        return true;
                }
        }

    //***************************************insert JoB EdUcAtIoN************************************************************** 
            $eduObj= new jobScript;
            if(isset($_POST["btn_save_edu"]))
                {
                    date_default_timezone_set("Asia/Karachi");
                    $Array= array(
                    "degree" => $_POST["degree"],
                    "institute" => $_POST["institute"],
                    "completion_year" => $_POST["completionYear"],
                    "grade" => $_POST["grade"],
                    "dateCreated" => date("Y-m-d h:i:sa"),
                    "dateModified" => date("Y-m-d h:i:sa"),
                    "job_id" => $jobid
                    );
                }
            if($eduObj->insert("jobs_education", $Array))
                {
                    $succMsg= "Record added Succesfully";
                    header  ("location: index.php?exp= $succMsg");
                }
//***************************************insert MoRe JoB EdUcAtIoN**************************************************************    
        $moreEduObj= new jobScript;
        if(isset($_POST["btn_add_more_edu"]))
            {
                date_default_timezone_set("Asia/Karachi");
                $Array= array(
                "degree" => $_POST["degree"],
                "institute" => $_POST["institute"],
                "completion_year" => $_POST["completionYear"],
                "grade" => $_POST["grade"],
                "dateCreated" => date("Y-m-d h:i:sa"),
                "dateModified" => date("Y-m-d h:i:sa"),
                "job_id" => $jobid
                );
            }
        if($moreEduObj->insert("jobs_education", $Array))
            {
                $succMsg= "Record added Succesfully";
                header  ("location: index.php?moreEdu= $succMsg");
            }           

1 个答案:

答案 0 :(得分:3)

我找到了一个我自己的答案,它不是直接在header()中的index.php。 在

下的脚本中引导它

echo "<script>window.open('index.php?exp','_self')</script>";