Dynamic entries in Form

Super novice here… I have been looking for a solution to my problem and have viewed many tutorials but can’t really find the right answer. Hoping that someone here can help point me in the right direction. I maintain a simple website with static webpages, but have recently got a request to add a feature which allows the user to update the page. I have been told that this could be accomplished with PHP. After a few hours on the Internet, I think I get the basic concept, but haven’t been able to find examples of what I am trying to accomplish.

I would like to create a webpage which includes a form. The form would have multiple text fields which display the IP addresses of certain sites. The form has a submit button which would allow the user to enter addresses in the fields.

https://docs.google.com/file/d/0B9AYrMP5ZnUyc3NFd0JkTXpYbkk/edit?usp=docslist_api

What I need is for the user to view an initial set of pre-determined values in those fields, but if the user updates the fields, and hits the Submit button, the webpage will get updated, so that the next time they access the page, the new values will be displayed. Further, a hyperlink is needed for each of the entries, so that the user may click on the link and go to a webpage at the corresponding IP address.

The users will be installing the entire website on their own personal computers so there is no requirement to access to a webserver (remember, these were just static webpages at one time). I am assuming that this is possible as each user may have different entries for this page. I get an error message that there is a requirement for a site definition when I attempt to create/edit my .php file. I am hoping that there is a simple way to distribute my set of html pages without installing any additional software.

I don’t even know if this is possible, but I would appreciate any guidance on how to tackle this problem. Thanks in advance.

Hi Freddie.

Yes your project can be done in PHP. However there are a few things you should know before you begin.
This will require a little bit of knowledge as it will suddenly get very daunting if you don’t know PHP.

I suggest you have a read up on handling forms first with only PHP. Once you are comfortable with this process, look at interacting with a database (mysql, etc.)

Then and only then should you begin this project. Don’t be scared, it’s not actually as scary as it sounds and there is plenty of help available here. Just post up your code and someone will take a look and help out.

One final thing - and probably the most important - You say people are going to use this on their own personal computers.
This you may find a little difficult as PHP doesn’t come installed on windows machines :o and whilst there are plenty of software out there, configuring PHP with windows can be pretty scary!

Red :wink:

Red;

Thanks for responding so quickly. I’m not sure what installing PHP entails… Is this something fairly simple, or does it require an entire application? At some point, it becomes easier to just hard code my IP addresses on my static webpage and provide the links. If I need to add hundreds of megabytes of code, then I don’t see the point…

My project is to provide an HTML based solution (training guide) for a small group of people. If the installation of PHP is cumbersome, it would be easier for me to just email an updated webpage… Let me know if you have any recommendations here… thanks.

PHP is a server side language. IE: by the time the data hits your web browser, php has done it’s thing and is finished with as opposed to javascript which is client side (runs in the actual browser).

If I had to get the end user to install and configure PHP I would give it a miss. I pretty much guarantee there will be more users asking you to help set up PHP than your program.

On the other hand, if you are going to do a web based program PHP is relatively easy to learn. You should be able to submit and process a form in a couple of hours provided you ‘get it’ reading the docs.

Basically, write a form in HTML with the action being submit.php
then write a php script named submit.php

This is a very basic workflow;
[php]
// you input comes via the $_POST variable for whatever you named the elements in the form.
// IE:
// You will access this variable like so: $_POST[‘ipaddress’]

// check the form was submitted
if(isset($_POST[‘submit’])) {

// make a shorthand variable, trim the whitespace from the data
$ipaddress = trim($_POST['ipaddress']);

// validate the $_POST data to avoid malicious data.
// I'll leave that to you as an excercise.
// NEVER LET DATA INTO YOUR DATABASE WITHOUT PRIOR CHECKS

// insert the data into the database

}
[/php]

Once the data is in the database it’s just a matter of calling whatever data you wish.

Hope that helps.
:wink:

PS: again, it sounds scary but it’s not. The biggest issue here is getting other users to install/setup PHP.

Good to know… I’ll have to investigate what it takes to install PHP. Thanks.

To get PHP working on a computer like it does on the web you’ll need a server also.
I’d recommend Apache.

Take a look here for windows users.
WAMP
Windows
Apache
MySql
PHP

or here for nix users.
LAMP
Linux
Apache
MySql
PHP

These are all-in-one installers and generally work out of the box although not the recommended way to install PHP as uses cgi as opposed to running as a module. (not really important if you just doing basic stuff)

Hope that helps,
Red :wink:

Thanks for the info. However, I can see that this solution becomes a little too costly for what I am trying to achieve. The object of the exercise is to allow the user to edit a webpage. I understand that this may be considered architecturally incorrect, but I think I will investigate other ways to save an HTML file. Perhaps Javascript may provide a solution. If not, then I may just hard code the IP addresses in my HTML page. Thanks for the insight.

In terms of monetary value all the software is free. You can write the scripts yourself.
I would expect to have this built in a few hours - I’d expect a beginner to take a day or so.

Start by writing your HTML form with all the elements you want on it, then come back an post it up here as without seeing your form, I/we have no idea what data you are going to use and save etc.

Tag me in the post using the @ before my username and i shall receive an email. I’ll then pop in and take a look an we can begin to put it together.

Red :wink:

You might want to check into http://www.html5rocks.com/en/tutorials/indexeddb/todo/

Nice! :smiley:
Have bookmarked it to read properly later.
I haven’t discovered all the joys of HTML5 yet as I ventured away from PHP down the Python route.

Thanks for the heads up Strider :wink:

Thanks for that. I will have to give that a try.

Sponsor our Newsletter | Privacy Policy | Terms of Service