Support
Quality
Security
License
Reuse
kandi has reviewed myprojects and discovered the below as its top functions. This is intended to give you an instant insight into myprojects implemented functionality, and help decide if they suit your requirements.
Get all kandi verified functions for this library.
Get all kandi verified functions for this library.
My own projects on cloud.
QUESTION
how to use $_POST to change some contents forever
Asked 2022-Apr-18 at 02:32I am trying to populate data from a website to another wensite: a.html:
<form action="b.php" method="post">
<textarea id="myProjects" name="mp"></textarea>
<input id="submit" type="submit" value="Submit" />
</form>
in b.php:
<?php $content=$_POST['mp'];
echo "you entered ".$content;
?>
This works in a very strange way, when I click submit button, I am directed to the b.php page, and I can see what I entered. But if I reload this page, not refresh, my contents disappear, and throwWarning: Undefined array key "mp"
It looks like data received from $_POST is "temporarily" stored. I am new to PHP, so I am not sure how can I figure it out.
ANSWER
Answered 2022-Apr-18 at 02:28You can use the PHP SESSION feature to keep the data persistent:
in b.php:
<?php
// Start the session
session_start();
// save the input var as a SESSION property
if (isset($_POST['mp'])) {
$_SESSION['content'] = $_POST['mp'];
}
// display the property
echo "you entered " . $_SESSION['content'];
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Find more information at:
Save this library and start creating your kit
Save this library and start creating your kit
Open Weaver – Develop Applications Faster with Open Source