# [web] Questions about Web Development

This topic is 4726 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I'm not too experienced with developing websites, and have a few questions. If people could just point me in the right direction (maybe some keywords and things), then I'm sure I could do well learning things on my own. I need to do the following: -Create a website where numbers, values, etc. that are on the parge are easily adjusted, by people who aren't tech-savvy. So if the webpage says: Special Number of the Day: 19 I need someone in charge of the website to easily be able to adjust the value (for example, from 19 to 17) very quickly and without much computer knowledge. (This means that going through the website's code and manually changing the value from 19 to 17 is NOT an option - although, if there exists a means to hold all these special values on one private page/file that are easily adjustable and savable, then that's ok). So after quickly changing the value, the webpage says: Special Number of the Day: 17 Also, this method needs to work not just with numbers, but strings (entire sentences). So where should I look to figure out how to do this? If you can narrow down what I should be looking for, I'd be happy to look around google and such. Thanks. -Gauvir_Mucca

##### Share on other sites
Are you using any server side languages such as PHP, ASP, or CGI? If so, then this is very easy, especially if you are using PHP and XML. You could probabally do the same with pure HTML as well, but first, what kind of software are you working with?

[Edited by - Drew_Benton on June 15, 2005 11:35:57 PM]

##### Share on other sites
I didn't have any kind of software in mind, specifically. I'm not too familiar with PHP, ASP, CGI, etc. But if the software is easily installed on the server (or is commonly found in hosting services), then I'm all for it.

-Gauvir_Mucca

##### Share on other sites
Ok, I think I can do what I need to do with just javascript. However, in order to do this, I must ask...

Can I save data generated from one page on the site to a site directory or file? And then can another page on the site look at that directory/file for the value of the data saved, and use that in javascript calculations?

##### Share on other sites
Ok here is my take on all of this. I am still a beginner at this web stuff, so if I miss something, I'm sure someone will correct me [wink].

javascript - not really meant for this level of interaction of the user and data driven web pages. It is meant for more client side use in terms of changing settings of the window (such as size and menus), restricting actions (no right click, no text select), and stuff like that. Now you can interface JS in with Java, of which Java has everything you could want to do, but I do not know of how Java works server side to get something like this done.

So instead, I will talk about PHP. Most web services do include access to PHP as it is becoming more widely used today. It is very easy to install and configure - most of the time people just install it to their local computers and develop like that becase it's so simple. The idea of PHP is that is is a server side program that runs scripts that let you do a lot of stuff.

People cannot see the PHP code on a server when they try to access it, just the HTML output from it, so it is very safe. If something is badly misconfigured, then this will not apply, but you usualyl ahve ot go out of your way and know what you are doing to get it so that will happen.

The design of web page you want is one that is data driven - a design that is vey robust, easy to maintain, and very efficient. Now most of the time these days, people use databases such as MySQL to host all the information, but there are also a lot of people that do not use that and just use plain text files to store it all in (such as myself) [wink]. Starting out, not using a database is fine, but when you get larger sites, you will definitly want to upgrade to a database.

For the page now, let's say you have some data that needs to be easily changed. The best way to do this is to simply store it in a text file so the page can just load it up and display it. For example, take a look at this quick test page I made. Link. Now the source code to that page is as follows:
<html>    <head>        <title>PHP Test App</title>    </head>        <body>        <p>            <?php                // PHP code start tag                                // Variable to hold the data from the file                $content = ''; // Open up the file that contains the data$wp = fopen("Test.txt","r");                // Read in all of the data                while( !feof( $wp ) ) { // ".="" appends data to the variable, we read in 4KB chuncks$content .= fread( $wp, 4096 ); } // Close the file fclose($wp);                // Now we can simply echo out the data                echo "$content"; // PHP code end tag ?> </p> </body></html> Here is the file that it loads from. Now if you were to change that file, then the contents of the main page would change. It's as easy as that! Now all that's left is to make it so someone without any tech skills can modify it. To do that, you will just make another script that modifies the text file. For that though, you will want to first make a html page that is the form that will set the variables. First is Admin.php <html> <body> <form action="Modify.php" method="POST"> Enter the new welcome string: <input type="text" name="name" /> <input type="submit" /> </form> </body></html> The purpose of the admin.php file is to allow your client to log in and set the new settings of all the data. In this example, anyone can just use it, but for you, you will want to use a login system to make sure only your client can access it. This example just uses regular html forms to do it. Finally is the file Modify.php <?php // Open the file$fp = fopen( "Test.txt", "w");    // Save the new string    $write = fputs($fp, $_POST["name"] ); // Close the file fclose($fp );?>

The purpose of this file is to get the data the client entered on the admin page and save it to a file. Once again it uses the HTML forms methods to do so mixed in with the PHP functions to write files to the server.

So to see this example in action just do this:
2. Open up the Admin page in a new window and use the form to set the new contents.
3. Go back to the main page and refresh, you should see the new contents.

That's it! As you can see, there's not that much to it really. It just takes some time to develop everything so it is secure safe and bugfree. There are A LOT of tutorials and scripts for PHP online that help go though all thist uff as well. The forms portion of this I got from here. if you have any questions on this feel free to ask.

To anyone viewing this, please be responsible and do not abuse this example by writing inappropriate data to the file. Thanks [smile]

[Edited by - Drew_Benton on June 15, 2005 11:25:52 PM]

##### Share on other sites
Quote:
 Original post by Gauvir_MuccaI need someone in charge of the website to easily be able to adjust the value (for example, from 19 to 17) very quickly and without much computer knowledge. (This means that going through the website's code and manually changing the value from 19 to 17 is NOT an option - although, if there exists a means to hold all these special values on one private page/file that are easily adjustable and savable, then that's ok). So after quickly changing the value, the webpage says:Special Number of the Day: 17

PHP would work well for this. Just create a file with your variable definitions. It would look like this:
<?php  $NUMBER_OF_THE_DAY = 19;$WORD_OF_THE_DAY = 'bat';?>

...
<?php include('variables.inc.php') ?>...   <p>The number of the day is<?php echo $NUMBER_OF_THE_DAY ?></p> <p>The word of the day is <?php echo$WORD_OF_THE_DAY ?></p>...

• 9
• 13
• 41
• 15
• 12