•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 427,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,192 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 456 | Replies: 5 | Solved
![]() |
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
i have a textbox and a button,like this:
, and i want that everytime that i push the button the content to be listed on the page without the previous content being lost. I know that something like:
would be useless because it would erase the previous text, but how can i get it done?
cheers
php Syntax (Toggle Plain Text)
<form method='post' action=<?php echo $_SERVER["PHP_SELF"]; ?> > <input type='text' name='write'> </input> <input type='submit' name='push'> </input> </form>
, and i want that everytime that i push the button the content to be listed on the page without the previous content being lost. I know that something like:
php Syntax (Toggle Plain Text)
<?php if(isset($_POST['push'])) if($_POST['push']) echo $_POST['write']."<br/>"; ?>
would be useless because it would erase the previous text, but how can i get it done?
cheers
Last edited by soultrav : Mar 15th, 2008 at 6:52 am.
•
•
Join Date: Nov 2007
Location: Perth, Australia
Posts: 119
Reputation:
Rep Power: 1
Solved Threads: 16
You could store it in a variable so:
PHP Syntax (Toggle Plain Text)
<?php if(isset($_POST['push'])) { $text .= $_POST['write']; echo($text); } ?>
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
i stored the variable in a file:
,but i'm still hoping to find a more elegant solution
php Syntax (Toggle Plain Text)
<?php $filename='test.txt'; $handle=fopen($filename,'a'); $handle2=fopen($filename, 'rt'); if(isset($_POST['push'])) { fwrite($handle,$_POST['write'].' '); $contents=fread($handle2,filesize($filename)); echo $contents; } ?>
,but i'm still hoping to find a more elegant solution
•
•
Join Date: Mar 2008
Posts: 153
Reputation:
Rep Power: 1
Solved Threads: 19
Try this:
Matti Ressler
Suomedia
<?php session_start(); if(isset($_POST['write'])) $push_result = $_SESSION['push_stuff'] . $_POST['write'] . '<br />'; $_SESSION['push_stuff'] = $push_result; echo $_SESSION['push_stuff']; ?>
Matti Ressler
Suomedia
•
•
Join Date: Mar 2008
Posts: 10
Reputation:
Rep Power: 1
Solved Threads: 0
•
•
•
•
Try this:
<?php session_start(); if(isset($_POST['write'])) $push_result = $_SESSION['push_stuff'] . $_POST['write'] . '<br />'; $_SESSION['push_stuff'] = $push_result; echo $_SESSION['push_stuff']; ?>
Matti Ressler
Suomedia
yeah, that worked for me
thanks
Last edited by soultrav : Mar 17th, 2008 at 7:27 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the PHP Forum
- Previous Thread: The best community software?
- Next Thread: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource


Linear Mode