Simple but I'm stuck!
Moderator: General Moderators
Simple but I'm stuck!
I developed an intranet for the company I work for and I have an admin section where the owner can acknowledge staff. I have it set up as an input field and it posts on the home page but when you leave the page and return later its gone. How do I make it stay.
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Make what stay? What was in the input field? If submitted, you can store the data into a session variable quite easily. If the page is not submitted, the server won't know about the data so you may need to use Javascript to store the data into a cookie the server can look for (although it feels like a hack.) There's also an Ajax option, but seems a bit overkill for such a basic thing.
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Its just a few lines of text. My goal is to not have to teach her html. Right now the form is handled by php with the print function. Now I just type in what I want hit submit and it posts the text on the homepage. I need the text to remain there untill the next time it is edited.Code: Select all
<?php // Script 3.4 - home.php
$text2 = $_POST['text2'];
$text3 = $_POST['text3'];
$text4 = $_POST['text4'];
print " $text2 <p/>";
print " $text3 <p/>";
print " $text4 ";
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Start by googling "PHP and MySQL tutorials". Maybe download the first four chapters of Kevin Yanks "How to build a database driven website using PHP and MySQL" from Sitepoint. Maybe search these forums for database driven web site development or something along those lines. What you want to do is pretty common so I am sure you will find some demos and tutorials out there that will suit your needs.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA