Honesty Rocks! truth rules.

How Do I Get The Result To "stick" And Add Html Tags? Help please?

HOME      >>       Programming


<?php$changepage = $_REQUEST['changepage'];echo " <tt>$changepage</tt> ";?><form action="pasture.php" method="post"><TEXTAREA name="changepage" COLS="80" ROWS="15" WRAP="OFF"></textarea><br><input type="submit" value="Change"></form>

Okay, I need a way for any information typed in my textarea to "stick" on the page in which it "posts". Since I am creating a way for my registered users to decorate their "homepages". So any help, tutorials, etc. would be greatly appreciated. ^^Thanks.


<?php$changepage = $_REQUEST['changepage'];echo " <tt>$changepage</tt> ";?><form action="pasture.php" method="post"><TEXTAREA name="changepage" COLS="80" ROWS="15" WRAP="OFF"></textarea><br><input type="submit" value="Change"></form>

What you can have if this is your picture.php file is some code to process the chnagepage variable. Of course it will have to be adapted if this isn't how you want it.

<?phpif(count($_POST) > 0){ $changepage = $_POST['changepage']; // do any extra formatting you need to the string var $changepage here // output it back hereecho " <tt>$changepage</tt> ";}?><form action="pasture.php" method="post"><TEXTAREA name="changepage" COLS="80" ROWS="15" WRAP="OFF"><?phpecho $changepage;?></textarea><br><input type="submit" value="Change"></form>

I'm not sure if thats what you were asking but if theres any mistakes just reply here. Oh by the way I would suggest you handle get and post variables explicitly since request vars are handle differently across XAMPP and Xisto servers. There may be more differences. So use $_GET or $_POST rather then $_REQUEST.


Oh it has no mistakes and it works beautifully. However, I am trying to create something that will stay on the page until the user wants to change it themselves. That is the problem I seem to be having. Everything works wonderfully, but when I hit "enter" and reload the page the information is longer there. I am trying to figure out a way to make it stay there. If that makes any sense. ^^


The information will "stick" on the next page if you submit the information to a database, and then retrieve the information from the database and shove it into the textarea or other areas. Otherwise, closing the browser, closing the browser tab or window, moving to another page without submitting the information again, etc, will cause the information to disappear.


Here is a link to the best php Author I know of.
He refers to this as a 'sticky form' and this also includes the code for the Redux method so you can have the Form and handling of the Form on a single PHP page.

redux sticky forms in php


I was afraid of that. I was hoping there was a quicker or easier way to make it stick. ^^;; However, that does make sense. I guess that means I must make a row under members that is for their account page. Which I call pasture. Then write a code to INSERT the information and then retrieve it. *sighs* Here I go. XD---Oh.. I will got take a quick look at that site from the link you provided. It might work. If it doesn't I will do it the long way around.


Well if you really didn't want to store the data in a database you could always store it in a cookie, but if you want to do this for an account this wouldn't be the best option because your users would lose their preferences whenever they cleared out their cookies.


Very true. I think I might have figured out how to "insert" the data into the database, but it is going to be kind of tricky for me. Since I am still new to the PHP and MySQL language. However, I will report back if I get it to working right. =]


You could always use flat-files if your bent on not using a database... write the content directly to the files instead of storing the information on a database.... you may want to look up some information on file-writing if you do not already no about it...




using some of this in conjuntion with a form, and some includes, you should be able to accomplish what you want....


Well, as Kansuke was stating, you could use flat-files. Such as making a new .txt file with the name of the user and you can always include that file between a set textarea tags. When they submit, the text file is updated and you could also update a html file for the user. This can take up alot of space though.


Yes, very true. Hmm... I seem to have insertion and retireving down pat. However, when I go to change the data the original data I input is still there. So I tried my hand at "updating" and well.. I can't get it to update properly. I may try the txt file thing until I can figure out the database solution to this problem.


The database solution is the ideal one you can look to because it is the only one which stores the user's values without being changed due to any actions on the user's part. Of course, it may take a little time to load but in the long run, that is what you are trying to achieve.


Here is some screenshots of what I am trying to accomplish(off my website and a game i play):


Here is what I have:


Posted Image



Here is what I am trying to do:


Posted Image



In order to get this type of result:


Posted Image


<form action="pasture.php" method="post"><textarea name="layout" id="layout" columns="40" rows="20"> </textarea><br><input type="submit" name="submit" value="Update Layout"></form><?phpinclude ("connect.php");$result = mysql_query("INSERT INTO members VALUES (layout);SELECT * FROM members WHERE layout = 'layout';UPDATE layout WHERE layout = 'layout'")or die ('cannot select member info');$row = mysql_fetch_array($result);echo "ID:".$row['layout'];?>

*sighs* I have a headache from my head meeting my desk so much. XD lol Any way.. I have something that actually works in the sense it tells me "cannot select member info". Which is a start. However, before anyone says I need to "SET" just remember this form is for my users to "DECORATE" their page. As in the code needs to be updated frequently. As in there is no EXISTING data to update until the form SUBMITS said data. *sighs* Closest thing I can think of to describe this is a blog or a personal forum that just deletes and updates the data submitted by the form each time a member decides to change something on their page.Any way.. does anyone know where I went wrong? :lol:


You could use a simple if else to handle this. For e.g. if the user is entering for the first time, use the insert SQL statement, if it is for subsequent visits, you can use the update statements to actually modify the existing values in the table. But then again, you have to determine whether or not the user is entering values for the first time or not.