更新网站设置时,我会清空徽标字段

时间:2019-07-17 16:10:39

标签: php

在此代码页设置站点中可以看到,错误是当我更新徽标字段以外的任何字段时清空徽标字段,因此标题清空图像,有一种方法可以传递徽标更新我更新其余字段时的字段?

    // Upload Variables, Get Info From The Form
        $logo_name = $_FILES['logo']['name'];
        $logo_type = $_FILES['logo']['type'];
        $logo_temp = $_FILES['logo']['tmp_name'];
        $logo_size = $_FILES['logo']['size']; 


        //List Of Allowed File Typed To Upload
        $logoAllowedExtension = array("jpeg", "jpg", "png", "gif");

        // Get Logo Extension 

        $logoExtension1 = explode('.', $logo_name);
        $logoExtension = end($logoExtension1);

        // Get Variables From The Form
        $sitename       = $_POST['sitename'];
        $url            = $_POST['url'];
        $email          = $_POST['email'];
        $status         = $_POST['status'];
        $regstatus      = $_POST['regstatus'];
        $copyright      = $_POST['copyright'];


        // Validate the form
        $formErrors = array();

        if (empty($sitename)) {
            $formErrors[] = lang("Site_name_Empty");
        }

        // Loop into error array and echo it
        foreach ($formErrors as $error) {
            $theMsg = '<div class="form-custom text-center alert alert-danger">' . $error . '</div>' . '<br />';
            redirectHome($theMsg, 'back', 3);
        }

        // Check if there's no error proceed the update opertion
        if (empty($formErrors)) {

            $logo = rand(0, 10000000) . '_' . strtolower($logo_name);

            move_uploaded_file($logo_temp, '..\content\uploads\images\\' . $logo);


            // Update The Database With This Info

            $stm = $db->prepare("UPDATE settings SET Logo = ?, Site_Name = ?, Site_Url = ?, Site_Email = ?, Site_Status = ?, Reg_Status = ?, Copy_Right = ?");
            $stm->execute(array($logo, $sitename, $url, $email, $status, $regstatus, $copyright));

0 个答案:

没有答案