Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9179287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:45:38+00:00 2026-06-17T17:45:38+00:00

Thanks for helping me guys. I have another question. In my previous question I

  • 0

Thanks for helping me guys. I have another question.
In my previous question I asked how to make the textbox message to show at the top of page after form submission.
I managed to do this thanks to you guys.
Next question is how to make this happen at least 8x times?

 <?php

 include('header1.php');

 if(isset($_POST['submit']) && $_POST['submit']=='Submit'){
 message=$_POST['message'];
$name=$_POST["name"];
echo "<center>";
echo "<div>" . $name . "<br />" . $message ."</div>"; 
echo "</center>";


    if(isset($_POST['submit']) && isset($_POST['prevmsg']) &&      isset($_POST['prevname'])){

    echo "<center>";
    echo $_POST['prevname'];
    echo "<br/>";
    echo $_POST['prevmsg'];
    echo "</center>";   
 }

 ?>

<html>
<head>
</head>
<body style="position:center">
<form method="POST" action="<?=$_SERVER["PHP_SELF"]?>">

        <table>
                    <tr>
                        <th>
                            <label for="name">Name</label>
                        </th>
                        <td>
                            <input type="text" name="name" id="name">
                        </td>
                    </tr>

    <input type="hidden" name="prevname" value="<?=$name?>"/>

                    <tr>
                        <th>
                            <label for="message">Message</label>
                        </th>
                        <td>
                            <textarea name="message" id="message"></textarea>
                        </td>
                    </tr>    
    <input type="hidden" name="prevmsg" value="<?=$message?>"/>

        </table>
<input type="submit" name="submit" value="Submit"/>

 </form>
  </body>
 </html>

  <?php

   } else {  

   ?>

  <html>

  <head>  

  </head>

  <body>
  <form method="POST" action="<?=$_SERVER["PHP_SELF"]?>">

        <table>
                    <tr>
                        <th>
                            <label for="name">Name</label>
                        </th>
                        <td>
                            <input type="text" name="name" id="name">
                        </td>
                    </tr>


                    <tr>
                        <th>
                            <label for="message">Message</label>
                        </th>
                        <td>
                            <textarea name="message" id="message"></textarea>
                     </td>
                    </tr>
        </table>
                     <input type="submit" name="submit" value="Submit"/>

 </form>
 </body>
 </html>


 <?php } 
include('inc/footer.php');
 ?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T17:45:39+00:00Added an answer on June 17, 2026 at 5:45 pm

    You can use a for loop. I also cleaned up your code as you had some syntax errors. Since you’re reusing the form, you probably want to make it a function.

    <?php
    
      include('header1.php');
    
      function myForm( $name, $message ) {
    ?>
    <form method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
    <input type="hidden" name="prevmsg" value="<?php echo $message; ?>" />
    <input type="hidden" name="prevname" value="<?php echo $name; ?>" />
    <table>
      <tr>
        <th><label for="name">Name</label></th>
        <td><input type="text" name="name" id="name"></td>
     </tr>
      <tr>
        <th><label for="message">Message</label></th>
        <td><textarea name="message" id="message"></textarea></td>
     </tr>
    </table>
    <input type="submit" name="submit" value="Submit" />
    </form>
    <?php
    
      }
    
      if( isset($_POST['submit']) && $_POST['submit'] == 'Submit' ) {
        $message = $_POST['message'];
        $name = $_POST["name"];
    
        for($i = 0; $i < 8; $i++) {
        echo "<center>";
        echo "<div>" . $name . "<br />" . $message ."</div>"; 
        echo "</center>";
        }
    
        if( isset($_POST['submit']) && isset($_POST['prevmsg']) && isset($_POST['prevname']) ) {
        echo "<center>";
        echo $_POST['prevname'];
        echo "<br/>";
        echo $_POST['prevmsg'];
        echo "</center>";   
        }
    
    
    ?>
    
    <html>
    <body style="position:center">
    <?php myForm( $name, $message ); ?>
    </body>
    </html>
    
    <?php
    
        }
        else {  
    
       ?>
    <html>
    <body>
    <?php myForm( NULL, NULL ); ?>
    </body>
    </html>
    <?php
    
        }
    
      include('inc/footer.php');
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Thanks to everyone out there helping newbies like me. So far I have this:
Hello there freaks & geeks. Here comes my question again, thanks for helping!. Lets
Let me thanks you guys at the Stack Overflow community for helping me with
Thanks for helping with this. I have a script that checks logins and then
Alright guys thanks for helping me with the 100% height problem. it works now..
Thanks for helping me answering this question, I want to update the user's location
Thanks for helping. I have a view that allows me to upload a csv
Rails newbie, thanks for help with this hopefully basic JSON type question.... I have
thanks for helping me setting my cron jobs, crontab has really been a gold
THANKS FOR HELPING!!! Ok... So I am trying to write a script that will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.