Changing $variables based on a webform
Moderator: General Moderators
Changing $variables based on a webform
I have $variables defined in a config file
I want to be able to modify those variables based on a selection or text entered from a webform.
For instance if a selection is made for active or inactive a varoiable is changed from 0 to 1
or if a 10 is entered (input), the $num=(input) will then be changed in the config file where the $num variable is defined .
I hope this is clear enough, any help appreciated.
Thanks
Mark
I want to be able to modify those variables based on a selection or text entered from a webform.
For instance if a selection is made for active or inactive a varoiable is changed from 0 to 1
or if a 10 is entered (input), the $num=(input) will then be changed in the config file where the $num variable is defined .
I hope this is clear enough, any help appreciated.
Thanks
Mark
Re: Changing $variables based on a webform
Thank for the tip, however that is a lot of reading and seems to be of little relevance.
I am mostly concerned with how to write the variable to the correct line of the file.
Any othe suggestion how to painlessly accomplish this?
Any samples?
I am mostly concerned with how to write the variable to the correct line of the file.
Any othe suggestion how to painlessly accomplish this?
Any samples?
Re: Changing $variables based on a webform
It's probably 2 paragraphs of text. The rest of the page is filled with comments.
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Changing $variables based on a webform
It doesn't seem relevant to what they are asking about.
I have used a combination of include(), var_export() and file_put_contents() for this.
I have used a combination of include(), var_export() and file_put_contents() for this.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Changing $variables based on a webform
Perhaps I should clarify...
My concern is HOW to read/write that variable to/from the file. In other words locating the line, and writing its value correctly in place.
Then page referenced seemed that someone thought I wanted to know how to make a webform , and that is not the case.
THanks
Mark
My concern is HOW to read/write that variable to/from the file. In other words locating the line, and writing its value correctly in place.
Then page referenced seemed that someone thought I wanted to know how to make a webform , and that is not the case.
THanks
Mark
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Changing $variables based on a webform
I gave you the functions. I would also suggest using an array in the config file to make it easier to work with.
You could also serialize the array and save it in the config file.
You could also serialize the array and save it in the config file.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Re: Changing $variables based on a webform
AbraCadaver
Thanks, I am looking into those,
Thanks, I am looking into those,
Re: Changing $variables based on a webform
Would it perhaps be easier just to put those variables in to a different php page and then use an include? If those variable will rarely change, it might be a lot easier and not very difficult to maintain it as long as you document in both files what's going on.
Then again, if something else is constantly changing that config file, nevermind.
Then again, if something else is constantly changing that config file, nevermind.
Re: Changing $variables based on a webform
this project is an admin interface for some display ads.
My goal is to have them manipulated ONLY from the admin interface, but HARD written into the files .
thanks
Mark
My goal is to have them manipulated ONLY from the admin interface, but HARD written into the files .
thanks
Mark
-
Phoenixheart
- Forum Contributor
- Posts: 123
- Joined: Tue Nov 16, 2004 7:46 am
- Contact:
Re: Changing $variables based on a webform
From top of my head (If I got your question right):
Example you have 3 variables: $a, $b, $c. You'll write into the config file like this:
Then, to turn it back into variables:
Example you have 3 variables: $a, $b, $c. You'll write into the config file like this:
Code: Select all
$vars = array(
'a' => $a,
'b' => $b,
'c' => $c,
);
$vars = serialize($vars); // here you serialize the array into a string
file_put_contents('config.inc', $vars); // and write it into the config file
Code: Select all
$vars = file_get_content('config.inc');
$vars = unserialize($vars); // turn it into the array
extract($vars); // after this you'll have $a, $b, $c ready to rock
Re: Changing $variables based on a webform
How would I write it back to the file?
- AbraCadaver
- DevNet Master
- Posts: 2572
- Joined: Mon Feb 24, 2003 10:12 am
- Location: The Republic of Texas
- Contact:
Re: Changing $variables based on a webform
file_put_contents() maybe?markosjal wrote:How would I write it back to the file?
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.