Search code examples
phpformsinputecho

i want to display my submit data into input form


I want to display my submit data into input form area. The first form is where i input movie name and result came out fine. I want to display that result into the second form input area "Title" and "Description". Thank you all.

i try to echo into the value area not working

<form action="rrr.php" method="post">
<input type="text" name="addmoviess"><br>
<input type="submit">
<br/> 
</form>

<form method="post" action="/admin/ajax_add_movie" id="ajax-movie-add" enctype="multipart/form-data">

<label>Title</label>
<input type="text" name="film_title" id="title" value="" class="input-xxlarge"/>
<br/>
<label>Description</label>
<textarea name="description" id="description" rows="5" value="" class="input-xxlarge"></textarea>
<br/></form>

<?php
include_once 'imdb.class.php';
$oIMDB = new IMDB($_POST['addmoviess']);

    if ($oIMDB->isReady) {
        echo '<p>' .
             '<br>'.
             'TITLE : ' .
             $oIMDB->getTitle() 

.
         '<br>'.
         'DESCRIPTION : ' .
         $oIMDB->getDescription() .
         '.</p>';
} else {
    echo '<p>not found!</p>';
}
?>

I want to display "TITLE" and "DESCRIPTION" into the 2nd form input area. Any help or suggestion would be much appreciated


Solution

  • You need to put your second form after the PHP code. Then use <?php echo ... ?> to output the values where you want them to appear:

    <form action="rrr.php" method="post">
    <input type="text" name="addmoviess"><br>
    <input type="submit">
    <br/> 
    </form>
    
    <?php
    include_once 'imdb.class.php';
    $oIMDB = new IMDB($_POST['addmoviess']);
    
    if ($oIMDB->isReady) {
    } else {
        echo '<p>not found!</p>';
    }
    ?>
    
    <form method="post" action="/admin/ajax_add_movie" id="ajax-movie-add" enctype="multipart/form-data">
    
    <label>Title</label>
    <input type="text" name="film_title" id="title" value="<?php echo $oIMDB->getTitle() ?>" class="input-xxlarge"/>
    <br/>
    <label>Description</label>
    <textarea name="description" id="description" rows="5" value="" class="input-xxlarge"><?php echo $oIMDB->getDescription() ?></textarea>
    <br/></form>