使用客户端的新信息登录(提交表)后,将用户添加到新表中

时间:2019-05-29 08:20:02

标签: php html mysql database

首先,有人登录该站点。其次,他们应该确定一种用户(自由职业者/雇主)。在这个阶段,他们应该填写表格。我们生成了一些代码,可以通过此表单将该用户插入数据库,但无法正常工作。

我使用会话保留 userId ,但是在执行代码后,另一个 userId 将插入到表中。

<?php
include "../../inc/inc.php";
$frame->RequestMethodPost();


if (


    isset($_POST['selected'])
    &&
    isset($_POST['workexperience'])
    &&
    isset($_POST['profileimg'])
    &&
    isset($_POST['backgroundimg'])
    &&
    isset($_POST['shortdescription'])
    &&
    isset($_POST['description'])
    &&
    isset($_POST['language'])
    &&
    isset($_POST['timefee'])
    &&
    isset($_POST['hours'])
    &&
    isset($_POST['projecttype'])
    &&
    isset($_POST['available'])
    &&
    isset($_POST['mobile'])
    &&
    isset($_POST['profileimgname'])
    &&
    isset($_POST['backgroundimgname'])
    &&


    !empty($_POST['selected'])
    &&
    !empty($_POST['workexperience'])
    &&

    !empty($_POST['shortdescription'])
    &&
    !empty($_POST['description'])
    &&
    !empty($_POST['language'])
    &&
    !empty($_POST['timefee'])
    &&
    !empty($_POST['hours'])
    &&
    !empty($_POST['projecttype'])
    &&
    !empty($_POST['available'])
    &&
    !empty($_POST['mobile'])



){



    $subcatId = $db->Real(($_POST['selected']));
    $subcatId1[] = (explode(",",$subcatId));


    $workexperience = $db->Real(($_POST['workexperience']));
    $profileimg= $db->Real(($_POST['profileimg']));
    $backgroundimg = $db->Real(($_POST['backgroundimg']));
    $description = $db->Real(($_POST['description']));
    $shortdescription = $db->Real(($_POST['shortdescription']));
    $language = $db->Real(($_POST['language']));
    $timefee = $db->Real(($_POST['timefee']));
    $hours = $db->Real(($_POST['hours']));
    $projecttype = $db->Real(($_POST['projecttype']));
    $available = $db->Real(($_POST['available']));
    $mobile = $db->Real(($_POST['mobile']));
    $profileimgname = $db->Real(($_POST['profileimgname']));
    $backgroundimgname = $db->Real(($_POST['backgroundimgname']));
    session_start();
    if( isset($_SESSION["login"]) && $_SESSION["login"]==true ) {
        $freelancerid= $_SESSION["submitid"];
        $select = mysqli_query($db->connect(),"SELECT * from submit where id=$freelancerid");
        $result = mysqli_fetch_assoc($select);
        $name=$result['name'];
        $family=$result['family'];
        $email=$result['email'];
        $username=$result['username'];
        $password=$result['password'];


        $insertfree = mysqli_query($db->connect(), "INSERT INTO freelancer (id, name, family, email, password, shortdescription, description, reg_date, reg_time, username, timefee, projecttype, available, mobile, workexperience, language, hours)
                                                                     value ('$freelancerid','$name','$family','$email','$password','$shortdescription','$description','','','$username','$timefee','$projecttype','$available','$mobile','$workexperience','$language','$hours')");
        $insertimgprofile=  mysqli_query($db->connect(),"INSERT INTO gallery(id, img_address, freelancer_id, employer_id, freeco_id, empco_id) value ('','$profileimgname','$freelancerid','','','')");
        $insertimgbackground=  mysqli_query($db->connect(),"INSERT INTO gallery(id, img_address, freelancer_id, employer_id, freeco_id, empco_id) value ('','$backgroundimgname','$freelancerid','','','')");

        foreach($subcatId1 as $selected) {
            $insertskill=mysqli_query($db->connect(),"INSERT INTO skill(freelancer_id, subcat_id, project_id, employer_id)
                                                             value ('$freelancerid','$selected','','')");

        }


        if( $insertfree && $insertimgprofile && $insertimgbackground && $insertskill   )

        {

            $data = array("error"=>false,"MSG"=>"ثبت  با موفقیت انجام شد");
            echo json_encode($data);

            $db->endFile();
            return;
        }else{
            $data = array("error"=>true,"MSG"=>"خطای 1 پیش آمده");
            echo json_encode($data);
            $db->endFile();
            return;

        }





        }

}
session_destroy();

    ?>

0 个答案:

没有答案