Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,471
There are 895 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

help needed: how to update php values?

Thread title: help needed: how to update php values?
Closed Thread    
    Thread tools Search this thread Display Modes  
09-19-2008, 02:56 PM
#1
susapra is offline susapra
Status: Sin Binner
Join date: Sep 2008
Location:
Expertise:
Software:
 
Posts: 35
iTrader: 0 / 0%
 

susapra is on a distinguished road

  Old  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
creativejen is offline creativejen
Status: Paladin
Join date: Jul 2006
Location: Sheffield, UK
Expertise: design, front-end markup
Software: Photoshop
 
Posts: 2,353
iTrader: 25 / 96%
 

creativejen is an unknown quantity at this point

Send a message via MSN to creativejen

  Old

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
dynamic313 is offline dynamic313
Status: Junior Member
Join date: Jul 2008
Location:
Expertise:
Software:
 
Posts: 52
iTrader: 0 / 50%
 

dynamic313 is on a distinguished road

Send a message via MSN to dynamic313

  Old

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
venomizer is offline venomizer
Status: I'm new around here
Join date: Jun 2008
Location:
Expertise:
Software:
 
Posts: 7
iTrader: 0 / 0%
 

venomizer is on a distinguished road

  Old  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
swg is offline swg
Status: I'm new around here
Join date: Oct 2008
Location:
Expertise:
Software:
 
Posts: 17
iTrader: 0 / 0%
 

swg is on a distinguished road

  Old

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
coder-chris is offline coder-chris
Status: I'm new around here
Join date: Nov 2008
Location:
Expertise:
Software:
 
Posts: 12
iTrader: 0 / 0%
 

coder-chris is on a distinguished road

  Old

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
Village Genius is offline Village Genius
Village Genius's Avatar
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
 
Posts: 6,894
iTrader: 18 / 100%
 

Village Genius will become famous soon enough

  Old

A database would be your easiest and best way.

Closed Thread    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed