Jump to content
  • Advertisement
Sign in to follow this  
Unknown1004

[web] Editable Vars

This topic is 3885 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Basically I'm trying something out. What I'm trying to accomplish here, is that when you enter data into the textbox (which has text assigned to it) which you have edited/added to the previous text and echo it off. It does that perfectly, but I'm wanting it too save and stay as that, until you decide to write again, is there anyway of doing this? I was thinking about sessions? But it seems too steep. I was also thinking of making a global define, so I could then manipulate it.
<form method="post" action="test.php" >
<?php $hello = "SOMETEXT"; ?>
<input type="text" name="getme" value="<?php printf($hello); ?>" />

<?php $GetMod = $_POST['getme']; $hello += $GetMod; echo $GetMod; ?>
<input type="submit" name="submit" value="submit" /> </form>

Share this post


Link to post
Share on other sites
Advertisement
i'm not totally sure what you're trying to do, but it sounds like basic information storage and retrieval, which boils down to the following choices:

- a database
- a file
- a cookie (for user-specific data)

PHP sessions / cookies are not hard to implement. They are not expensive. 30 minutes of your time learn.

A database is a more practical way to generally store info. It's also not at risk of getting erased by the user. It does take time to set up and learn.

Writing to/from a file is also easy. That's even easier than using a cookie.

sidenote: if you just want temporary storage, you could even use the cookie functions in javascript for this, but would recommend you let php do it instead.

Share this post


Link to post
Share on other sites
<form method="post" action="test.php" >
<?php $hello = "SOMETEXT"; ?>
<input type="text" name="getme" value="<?php printf($hello); ?>" />


<?php
$GetMod = $_COOKIE['hello'] + $_POST['getme'];
setcookie("hello", $GetMod, time()+86400);
echo $GetMod;
?>


<input type="submit" name="submit" value="submit" />
</form>


Expires in a day.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!