Jump to content
xisto Community
TheChosenDarkness

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

Recommended Posts

<?php$changepage = $_REQUEST['changepage'];echo " <tt>$changepage</tt> ";?><form action="pasture.php" method="post"><TEXTAREA class="text" 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.

Share this post


Link to post
Share on other sites
<?php$changepage = $_REQUEST['changepage'];echo " <tt>$changepage</tt> ";?><form action="pasture.php" method="post"><TEXTAREA class="text" 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 class="text" 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.

Edited by sonesay (see edit history)

Share this post


Link to post
Share on other sites

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. ^^

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Edited by TheChosenDarkness (see edit history)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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. =]

Share this post


Link to post
Share on other sites

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...

 

http://www.w3schools.com/php/php_file.asp

 

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
<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:

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.