|
|
|
|
Thread title: help needed: how to update php values? |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
09-19-2008, 02:56 PM
|
#1
|
Status: Sin Binner
Join date: Sep 2008
Location:
Expertise:
Software:
Posts: 35
|
help needed: how to update php values?
Hi
I'm php newbie. For example, I have a php file like this:
php Code:
<?
$value1="content1";
$value2="content2";
?>
Now I want to create a HTML site with 2 input forms allow me change the values (content1, content2) without edit above file manually. I can enter new data and click update button, then it will update new values of above php file.
How do I create this file? There are no SQL DB or complicated functions.
Thank you
|
|
09-19-2008, 05:24 PM
|
#2
|
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
Posts: 2,353
|
There 2 ways you can do it that I know of, either by using a database which is probably the easiest option, or storing the content for each variable in a txt file.
You cannot use a form to update a php variable.
|
|
09-19-2008, 08:43 PM
|
#3
|
Status: Junior Member
Join date: Jul 2008
Location:
Expertise:
Software:
Posts: 52
|
i agree with enigma, only two 2 ways i can think of, and i think it would be better to go down the road of using a database rather than a flat file (text file)
|
|
09-20-2008, 06:47 PM
|
#4
|
Status: I'm new around here
Join date: Jun 2008
Location:
Expertise:
Software:
Posts: 7
|
Solution to your problem
Hi,
I created a small script with comments for you to use in order to change the two variables from PHP. You can see the full explanation on my blog along with a PHP tutorial for it.
Hope it helps,
Mihai Bojin
|
|
10-15-2008, 02:33 AM
|
#5
|
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
Posts: 17
|
When you say update do you mean update and keep the values until you want to change it again or just update them temporarily?
The former would require some type of storage - be it a MySQL database, text file, tmp file or whatever.
The second you could just use $_GET variables
|
|
11-27-2008, 01:09 AM
|
#6
|
Status: I'm new around here
Join date: Nov 2008
Location:
Expertise:
Software:
Posts: 12
|
Yeah there are two different ideas here:
1) You can update those values for a single instance of that page. So you could set them and display them further down the script.
2) You want to set them permanently ie. Someone can load the page, change the variable and close it and then the next person to open the page would see those changes.
The first case is easier and just requires the use of either $_GET['field'] or $_POST['field'] in your PHP.
For the second one, it would probably be easiest to use a text file to store the information.
|
|
11-27-2008, 01:16 AM
|
#7
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
A database would be your easiest and best way.
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
|
|