我目前遇到了一个问题,即<textarea>
没有发布表格的其余部分。目前,<textarea>
将仅发布从中提供的数据,$r['bio']
用于填写.<textarea>
$r['bio']
我尝试过的事情没有成功
将提交按钮移动到页面底部。
使用 $FID 为表单提供唯一 ID,并将 form='$FID' 添加到文本区域
删除 var editor = textboxio.replaceAll('textarea'); 将让 textarea 按预期发布,但随后我失去了所见即所得的编辑器。
$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>