dsfjnxjlbqv9812 2018-08-24 20:24
浏览 114

Textarea与TextboxIO不发布

I'm currently having a problem with a <textarea> not posting with the rest of the form. Currently the <textarea> will only post data supplied from $r['bio'] that's used to fill in the <textarea> if there's already content in $r['bio'].

Things I've tried with no success

  1. moving the submit button to the bottom of the page.

  2. giving the form an unique id with $FID and adding form='$FID' to the text area

  3. removing var editor = textboxio.replaceAll('textarea'); will let the textarea post as intended but then I lose the WYSIWYG editor.

            $query = $conn->query('SELECT * FROM users');
                while($r = $query->fetch()){
                $memID =  $r['id'];
                $bioID = 'b'.$r['id'];
                $FID = 'f'.$r['id'];
                $ebioID = 'eb'.$r['id'];
                $tbioID = 'tb'.$r['id'];
                $tabioID = 'tba'.$r['id'];
    
                if($r['active'] == 1){
                    $activeStatus = 'Yes';
                }else{
                    $activeStatus = 'No';
                }
    
                if($r['admin'] == 1){
                    $adminStatus = 'Yes';
                }else{
                    $adminStatus = 'No';
                }
    ?>
    
    <div class="userMgmWrap">
    <form method="post" enctype="multipart/form-data">
    <table>
        <tbody>
            <tr>
            <td>Edit Profile Image</td>
            <td><input type="file" name="selectedFile" id="selectedFile"></td>
            <td><input type="submit" value="Upload" name="upload"></td>
            </tr>
        </tbody>
    </table>
    </form>
        <div class="userMgmProfilepic"><img src="images/profilepics/<?php if(isset($r['profilepicture'])){echo $r['profilepicture'];}else{echo 'NULL';}?>" style="width:100%;height:100%;"> </div>
        <div class="userMgmInfo">
            <form method="post">
                <table>
                    <tbody>
                        <tr>
            <!-- Username --><td>Username: </td>
            <!-- Username --><td><?php if(isset($r['username'])){echo $r['username'];}else{echo 'NULL';}?> </td>
            <!-- Username --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"></td>
                        </tr>
                        <tr>
            <!-- Email --><td>Email: </td>
            <!-- Email --><td><?php if(isset($r['email'])){echo $r['email'];}else{echo 'NULL';}?> </td>
            <!-- Email --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="text" name="newEmail"></td>
                        </tr>
                        <tr>
            <!-- Active --> <td>Active: </td>
            <!-- Active --> <td><?php if(isset($activeStatus)){echo $activeStatus;}else{echo 'NULL';}?> </td>
            <!-- Active --> <td class="<?php echo $tbioID; ?>" style="visibility:hidden">
                                <select name="newActive">
                                    <option selected="selected"></option>
                                    <option value="1">Yes</option>
                                    <option value="0">No</option>
    
                                </select>
                            </td>
                        </tr>
                        <tr>
            <!-- Admin --><td>Admin: </td>  
            <!-- Admin -->  <td><?php if(isset($adminStatus)){echo $adminStatus;}else{echo 'NULL';}?> </td>
            <!-- Admin -->  <td class="<?php echo $tbioID; ?>" style="visibility:hidden">
                                <select name="newAdmin">
                                    <option selected="selected"></option>
                                    <option value="1">Yes</option>
                                    <option value="0">No</option>
                                </select>
                            </td>           
                        </tr>
                        <tr>
            <!-- DOB -->    <td>Birth Date: </td>
            <!-- DOB -->    <td><?php if(isset($r['dob'])){echo $r['dob'];}else{echo 'NULL';}?> </td>
            <!-- DOB -->    <td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="date" name="newDOB" id="newDOB"></td>
                        </tr>
                        <tr>
            <!-- Bio -->    <td>Bio: </td>
            <!-- Bio -->    <td><input id="<?php echo $bioID; ?>" type="button" name="viewBio" value="View Bio" onclick="mod(this.id)"></td>
            <!-- Bio -->    <td><input id="<?php echo $ebioID; ?>" type="button" name="modBio" value="Modify Bio" onclick="mod(this.id)"></td>
                        </tr>
                    </tbody>
                </table>
        </div>
        <div class="userMgmInfo2">
            <table>
                <tbody>
                    <tr>
        <!-- First Name --><td>First Name: </td>
        <!-- First Name --><td><?php if(isset($r['firstname'])){echo $r['firstname'];}else{echo 'NULL';}?> </td>
        <!-- First Name --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="text" name="newFirstName"></td>
                    </tr>
                    <tr>
        <!-- Last Name --><td>Last Name: </td>
        <!-- Last Name --><td><?php if(isset($r['lastname'])){echo $r['lastname'];}else{echo 'NULL';}?> </td>
        <!-- Last Name --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="text" name="NewLastName"></td>
    
                    </tr>
                    <tr>
        <!-- Social 1 --><td>Social 1: </td>
        <!-- Social 1 --><td><?php if(isset($r['social1'])){echo $r['social1'];}else{echo 'NULL';}?> </td>
        <!-- Social 1 --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="text" name="NewSocial1"></td>
                    </tr>
                    <tr>
        <!-- Social 2 --><td>Social 2: </td>
        <!-- Social 2 --><td><?php if(isset($r['social2'])){echo $r['social2'];}else{echo 'NULL';}?> </td>
        <!-- Social 2 --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="text" name="NewSocial2"></td>
                    </tr>
                    <tr>
        <!-- Social 3 --><td>Social 2: </td>
        <!-- Social 3 --><td><?php if(isset($r['social3'])){echo $r['social3'];}else{echo 'NULL';}?> </td>
        <!-- Social 3 --><td class="<?php echo $tbioID; ?>" style="visibility:hidden"><input type="text" name="NewSocial3"></td>
                    </tr>
                    <tr>
        <!-- Edit -->   <td>Edit Account: </td>
        <!-- modify --> <td><input id="<?php echo $tbioID; ?>" type="button" name="modify" value="Modify" onclick="mod2(this.id)"></td>
        <!-- save -->   <td><input id="" type="submit" name="<?php echo $tabioID ?>" value="Save"></td>
                    </tr>
                </tbody>
            </table>
        </div>
    
        <div style="clear: both;"></div>
        <div class="userMgmBio">
            <div class="<?php echo $ebioID; ?>" style="display :none;">
                <textarea id="test"name="newbody"><?php //if(isset($r['bio'])){echo $r['bio'];} ?></textarea>
            </div>
            </form>
            <div class="<?php echo $bioID; ?>" style="display :none;"><?php if(isset($r['bio'])){echo $r['bio'];} ?></div>
        </div>
    </div>
    
    <?php
    
                    if(isset($_POST[$tabioID])){
                        print_r($_POST);
                        //error check up here
                        if($_POST['newEmail'] !==""){
                            if(!filter_var($_POST['newEmail'], FILTER_VALIDATE_EMAIL)){
                                $error[] = 'Please enter a valid email address.';
                                $eerror = 'Please enter a valid email address.';
                            } else {
                                $stmt = $conn->prepare('SELECT email FROM users WHERE email = :email');
                                $stmt->execute(array(':email' => $_POST['newEmail']));
                                $row = $stmt->fetch(PDO::FETCH_ASSOC);
    
                                if(!empty($row['newEmail'])){
                                    $error[] = 'Email provided is already in use.';
                                    $eerror2 = 'Email provided is already in use.';
                                }
    
                            }
                        }//EO email Check
    
                        if(isset($error)){print_r ($error);}
                        if(!isset($error)){
                        //prepare query
                        //newEmail --
                        //newActive --
                        //newAdmin --
                        //newDOB --
                        //newbody --
                        //newFirstName ---
                        //NewLastName --
                        //NewSocial1
                        //NewSocial2
                        //NewSocial3
                            $q = array();
                            if(trim($_POST["newEmail"]) !== ""){
                                $q[] = "email = :newEmail";
                            }
                            if(trim($_POST["newActive"]) !== ""){
                                $q[] = "active = :newActive";
                            }
                            if(trim($_POST["newAdmin"]) !== ""){
                                $q[] = "admin = :newAdmin";
                            }
                            if(trim($_POST["newDOB"]) !== ""){
                                $q[] = "DOB = :newDOB";
                            }
                            if(trim($_POST["newbody"]) !== ""){
                                $q[] = "bio = :newbody";
                            }
                            if(trim($_POST["newFirstName"]) !== ""){
                                $q[] = "firstname = :newFirstName";
                            }
                            if(trim($_POST["NewLastName"]) !== ""){
                                $q[] = "lastname = :NewLastName";
                            }
                            if(trim($_POST["NewSocial1"]) !== ""){
                                $q[] = "social1 = :NewSocial1";
                            }
                            if(trim($_POST["NewSocial2"]) !== ""){
                                $q[] = "social2 = :NewSocial2";
                            }
                            if(trim($_POST["NewSocial3"]) !== ""){
                                $q[] = "social3 = :NewSocial3";
                            }                       
                            if(sizeof($q) > 0){//check if we have any updates otherwise don't execute
                                $query2 = "UPDATE users SET " . implode(", ", $q) . " WHERE id= :id";
                                $stmt = $conn->prepare($query2);
                                $stmt->bindParam(":id", $memID);
    
                                if(trim($_POST["newEmail"]) !== ""){
                                    $stmt->bindParam(":newEmail", $_POST["newEmail"]);
                                }
                                if(trim($_POST["newActive"]) !== ""){
                                    $stmt->bindParam(":newActive", $_POST["newActive"]);
                                } 
                                if(trim($_POST["newAdmin"]) !== ""){
                                    $stmt->bindParam(":newAdmin", $_POST["newAdmin"]);
                                } 
                                if(trim($_POST["newDOB"]) !== ""){
                                    $stmt->bindParam(":newDOB", $_POST["newDOB"]);
                                } 
                                if(trim($_POST["newbody"]) !== ""){
                                    $stmt->bindParam(":newbody", $_POST["newbody"]);
                                }                           
                                if(trim($_POST["newFirstName"]) !== ""){
                                    $stmt->bindParam(":newFirstName", $_POST["newFirstName"]);
                                }   
                                if(trim($_POST["NewLastName"]) !== ""){
                                    $stmt->bindParam(":NewLastName", $_POST["NewLastName"]);
                                }       
                                if(trim($_POST["NewSocial1"]) !== ""){
                                    $stmt->bindParam(":NewSocial1", $_POST["NewSocial1"]);
                                }
                                if(trim($_POST["NewSocial2"]) !== ""){
                                    $stmt->bindParam(":NewSocial2", $_POST["NewSocial2"]);
                                }           
                                if(trim($_POST["NewSocial3"]) !== ""){
                                    $stmt->bindParam(":NewSocial3", $_POST["NewSocial3"]);
                                }                               
                                $stmt->execute();
                            }
                            //echo "<meta http-equiv='refresh' content='0'>";
    
    
    
                        }
    
                    }
    
                }// EO while Loop
    ?>
    
    <script type="text/javascript">
    // Create a Textbox.io Editor for the matched element(s)
        var editor = textboxio.replaceAll('textarea');
      //var editor = textboxio.replace(#class or ID);
    function mod(value){
    
        var elements = document.getElementsByClassName(value);
        for (var i = 0; i < elements.length; i++) {
            if(elements[i].style.display  == "none"){
                elements[i].style.display  = "block";
            }else{
                elements[i].style.display  = "none";
            }
    
    
        }
    
    }
    function mod2(value){
        var elements = document.getElementsByClassName(value);
        for (var i = 0; i < elements.length; i++) {
            if(elements[i].style.visibility  == "hidden"){
                elements[i].style.visibility  = "visible";
            }else{
                elements[i].style.visibility  = "hidden";
            }
    
    
        }
    
    }
    </script>
    </div>
    
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
    • ¥15 如何在scanpy上做差异基因和通路富集?
    • ¥20 关于#硬件工程#的问题,请各位专家解答!
    • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
    • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
    • ¥30 截图中的mathematics程序转换成matlab
    • ¥15 动力学代码报错,维度不匹配
    • ¥15 Power query添加列问题
    • ¥50 Kubernetes&Fission&Eleasticsearch
    • ¥15 報錯:Person is not mapped,如何解決?