dongyan7950 2019-05-29 08:20
浏览 59

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

At first a person sign-in to the site. Secondly they should decide a kind of users (freelancer / employer). In this stage they should fill a form . We produce some codes to insert this user to database by this form but it does not work properly.

I use session to keep userId but after executing the code the other userId will insert to the table.

<?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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
    • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
    • ¥15 stata安慰剂检验作图但是真实值不出现在图上
    • ¥15 c程序不知道为什么得不到结果
    • ¥40 复杂的限制性的商函数处理
    • ¥15 程序不包含适用于入口点的静态Main方法
    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因