Click to See Complete Forum and Search --> : How do I edit variables through a form?
Ok, I have a PHP script called config.php, the script has a whole list of variables to be displayed on another PHP script called index.php. Now what I want to do is put a form on index.php to edit those variables in config.php. How do I do that?
Thanks!
warmwind
06-29-2002, 11:16 PM
Okay, if I understand your prob correctly:
Put the variable definitions in a file - call it vars.inc
<?php
$trucks = 26;
$bikes = 12;
$usebydate = "2002-06-30";
?>
index.php AND config.php both have:
include("vars.inc");
.. at the top ..
in index.php, form elements will oook like this:
<input type="text" name="trucks" value="<?php echo $trucks; ?>">
index.php TARGETS store.php, which takes the variables and re-writes vars.inc
Simple.
OR, you could get store.php to parse the entire config.php and use regexs to alter the values :) But how yuck is that!
Ok, so which file is the form supposed to be pointing to for the action element?
<form action="????" method="POST">
warmwind
06-30-2002, 04:05 AM
Kuraden wrote:
-------------------------------
Ok, so which file is the form supposed to be pointing to for the action element?
<form action="????" method="POST">
store.php
This takes the variables and creates the include file anew :)
So you have:
vars.inc ------------------
| |
| |
config.php index.php
|
|
store.php CREATES vars.inc
Wait a sec...what do I put in store.php?
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.