Quantcast
Channel: Heck Designs » Demo Code
Viewing all articles
Browse latest Browse all 6

PHP Text Editor with $_SESSION

$
0
0

Here’s the code I came up on my lunch break with after a short conversation with Phillip about using Cookies to save text:

  1. <?php
  2. $starttext = "Type in the text area to change this text";
  3.  
  4. if(isset($_POST[‘save’])){
  5.         $_SESSION[‘text’] = $_POST[‘text’];
  6. }
  7. else{
  8.         $_SESSION[‘text’] = $starttext;
  9. }
  10. echo $_SESSION[‘text’];
  11. ?>
  12. <form name="texteditor" method="post" action="">
  13.           <textarea rows="5" cols="36"name="text"><?php echo $_SESSION[‘text’];?></textarea>
  14.           <br/>
  15.           <input type="submit" name="save" value="Save Text" />
  16. </form>

Viewing all articles
Browse latest Browse all 6

Trending Articles