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

问题描述 投票:0回答:1

我在发布输入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"); ?>
php mysql textarea
1个回答
0
投票

用你的textarea替换

 <textarea id="inputField" name="biography" form="formData2" placeholder="Biography"><?php echo $biography; ?></textarea>
© www.soinside.com 2019 - 2024. All rights reserved.