如何将textarea值发布到数据库中

k5hmc34c  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(393)

我在将值输入到 textarea . 其他一切都很好,你知道怎么做吗?
html格式:

<form id="formData2" action="artistuploader.php" method="post" 
enctype="multipart/form-data">

        <input type="hidden" name="size" value="1000000"></input>
        <br/>
        <input id="inputField" type="text" name="actname" placeholder="Act Name" >
        <br>
        <input id="inputField" type="text" name="fullname" placeholder="Full Name" >
        <br>
        <input id="inputField" type="text" name="genre" placeholder="Genre" >
        <br>
        <textarea id="inputField" name="biography" form="formData2" placeholder="Biography"<?php echo $biography; ?>></textarea>
        <br>
        <input id="inputField" type="file" name="artistImage" placeholder="Artwork" >
        <br>
        <input id="inputField" type="text" name="imagepath" placeholder="Image path URL" >
        <br>
        <input id="submitButton" type="submit" name="uploadArtist" value="Register Artist">

    </form>

PHP

<?php

$msg = "";

//if Upload button is pressed
if (isset($_POST['uploadArtist'])){
    $target = "uploads/artistPics".basename($_FILES['artistImage']['name']);

    //connecting to our database
    $db = mysqli_connect("127.0.0.1", "user", "pass", "tablename");
    $tmp_name = $_FILES['artistImage']['tmp_name'];
    $name = $_FILES['artistImage']['name'];
    //getting the submitted form data
    $ActName = $_POST['actname'];
    $FullName = $_POST['fullname'];
    $Genre = $_POST['genre'];
    $ArtistPhoto = $_FILES['artistImage']['name'];
    $imageURLpath = $_POST['imagepath'];
    $Biography = $_POST['biography'];//having problem with this line here

    //saving submitted data into database table songsDB
    $sql = "INSERT INTO  artistsdb (ActName,FullName,Genre,ArtistPhoto,Biography,imageURLpath) VALUES ('$ActName','$FullName','$Genre','$ArtistPhoto','$Biography','$imageURLpath')";
    mysqli_query($db, $sql); //stores the submitted data into table

    //now moving the uploaded image to uploads folder
    if(move_uploaded_file($_FILES['artistImage']['tmp_name'], $target)){
        $msg = "Uploaded Successful";
    }else{
        $msg = "There was a problem uploading Data";
    }
}

//header("refresh:1; url=index.php"); ?>
wpx232ag

wpx232ag1#

更换您的 textarea 具有

<textarea id="inputField" name="biography" form="formData2" placeholder="Biography"><?php echo $biography; ?></textarea>

相关问题