kqkyler Posted January 17, 2010 Share Posted January 17, 2010 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? Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/ Share on other sites More sharing options...
Buddski Posted January 17, 2010 Share Posted January 17, 2010 Will these variables be stored permanently in your system? Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996388 Share on other sites More sharing options...
trq Posted January 17, 2010 Share Posted January 17, 2010 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. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996389 Share on other sites More sharing options...
kqkyler Posted January 17, 2010 Author Share Posted January 17, 2010 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? Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996394 Share on other sites More sharing options...
trq Posted January 17, 2010 Share Posted January 17, 2010 I'm not sure where your $sitename object suddenly came from. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996396 Share on other sites More sharing options...
kqkyler Posted January 17, 2010 Author Share Posted January 17, 2010 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. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996399 Share on other sites More sharing options...
Buddski Posted January 17, 2010 Share Posted January 17, 2010 thorpe was referring to your use of "$sitename->sname", which makes no sense And what you want to achieve is best done with what thorpe suggested.. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996400 Share on other sites More sharing options...
kqkyler Posted January 17, 2010 Author Share Posted January 17, 2010 Ok, I just thought it would be as easy as one line of code. Thanks anyway. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996403 Share on other sites More sharing options...
trq Posted January 17, 2010 Share Posted January 17, 2010 As I said, there is a link to a free book in my signature (hudzilla). You should read it. You really need to learn to walk before you try to run or you'll fall flat on your face. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996404 Share on other sites More sharing options...
kqkyler Posted January 17, 2010 Author Share Posted January 17, 2010 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. Link to comment https://forums.phpfreaks.com/topic/188751-changing-php-variables-within-the-browser-in-form-fields/#findComment-996427 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.