簡體   English   中英

如何將textarea值發布到數據庫中

[英]how to post textarea value into database

我在發布鍵入到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"); ?>

將您的textarea替換為

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM