简体   繁体   中英

How can I save html form input data?

I want to store the data I inserted into this html form on the server side. And afterwards I want to be able to access this data and use it in a Raspberry Pi project. How can I do that?

<div class='alertBox' id='box'>
            <p id='displayDate'></p> <br>
            <form>
                <input name='Event' type='text' placeholder=' Event'> <br>
                <input type='submit' name='save' value='save'>
            </form> <br>
            <a onclick='unpop()' class='close'>Close</a> 
        </div>

You can use MySQL to store the data. And afterwards, you can fetch the data again.

Like this:

$sqlInsert = 'INSERT INTO table_name (All, the, column, names) VALUES (the, inserted, values)';

Fetching:

SELECT * 
FROM table_name 
WHERE a_column_name = user_input

If you're new to PHP / MYSQL, you could view / store the users input using $_POST[]; superglobal.

Like this:

<?php
$input = $_POST['Event'];
?>
<form method="post">
    <input name='Event' value="<?php if(isset($_POST['save'] { echo $input; } ?>" type='text' placeholder=' Event'> <br>
    <input type='submit' name='save' value='save'>
</form>

More information: https://www.w3schools.com/php7/php7_forms.asp

I hope this helps ;)

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