Jump to content

Changing php variables within the browser in form fields


kqkyler

Recommended Posts

Hey all,

 

I'm a pretty much new to coding.  I barely understand the basics of HTML, and much less in php.  So I'm sure that this is simple, yet I couldn't find an answer from google.

 

All I'm doing is creating simple variables in a file (such as variables.php) like:

 

$sitename = 'Site Name';

 

and then echoing the $sitename from different files within the site.

 

I'd like to create a form within variables.php so anyone can access it and change the variable $sitename from a form with a save changes button on the bottom.  What's the best way to do this?

The best way to do this would be store the variable with a database or text file (database is probably simpler).

 

There is a book in my signature that has chapters on handling forms and accessing data stored within a database. You should read it.

Yes I want to change the variables permanently. I was thinking of doing something like:

 

<?php $sitename = 'Site Name'; ?>

 

<form name="varchanges"  method="POST" action="variables.php">

 

<input type="text" name="sname" maxlength="100" value="<?php echo $sitename->sname; ?>" />

 

</form>

 

Would this work?

 

As i understand it <?php $sitename = 'Site Name'; ?> creates the object $sitename and gives it the value 'Site Name', so when I <?php echo "$sitename" ?> it prints 'Site Name'. 

 

I was just looking for a way to change $sitename without having to go into the code, change it, then re-upload the new file with <?php $sitename = 'New Name'; ?>

 

I just want to access varables.php from the browser, enter New Name in a field, hit save, and change the code.

Yeah, I know I get that.  I make 10-20 new sites each week from a template.  I'm just trying to find an easy way to change the Customer Service # (for example) throughout every page and all of the terms and conditions and everything all at once.  Creating a database and linking the sites to that database doesn't make much sense with how many sites I create. 

 

I just built my template to call on one file to get all of the info as needed, CS#, Names, Addresses, ect.  I can just change that every time.  I'll still be easier than what I was doing (opening all of the files, then find and replace).  But thanks anyways for your time.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.