简体   繁体   中英

form is not reloading current page

I've got a state machine in "currentpage.php". I'm trying to call the file and prep the data in the first state. The second state I want to display information and allow changes to be made. And finally the last state will be to interpret the data and save it off.

The following code is from the second state but when "Save" is pressed the page doesn't reload. Why and what can I do to make it work?

<form method="post" action="currentpage.php"></form>
<div id="content">
<div id="fields">
    <?php echo '<textarea name="textarea" style="width:100%;height:100%;" >'.$_SESSION["textarea"].'</textarea>'; ?>
</div>
<div id="instructions">
    <input type="submit" id="" value="Save"></input>
</div>
</div>
</form>

Just remove

</form>

So change

<form method="post" action="currentpage.php"></form>

on this

<form method="post" action="currentpage.php">

You are closing the form with nothing inside it, remove the closing form tag so it looks like this:

<form method="post" action="currentpage.php">
    <div id="content">
        <div id="fields">
            <?php echo '<textarea name="textarea" style="width:100%;height:100%;" >'.$_SESSION["textarea"].'</textarea>'; ?>
        </div>
        <div id="instructions">
            <input type="submit" id="" value="Save"></input>
        </div>
    </div>
</form>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM