how to fill in Forms on existing HTML pages using PHP?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pglenn
Forum Newbie
Posts: 3
Joined: Sun Sep 14, 2008 3:35 pm

how to fill in Forms on existing HTML pages using PHP?

Post by pglenn »

I am relatively new to PHP development so if the answer is simple I apologise :-)

I am looking for a way to use existing HTML pages within my PHP application, basically so I or someone else can design the HTML pages using a HTML editor, and then "include" those pages within my PHP code. The idea is to to be to design/format/update the HTML pages separate from the PHP code.

I am using the following within my PHP code to display my HTML pages, which seems to work just fine
-require("./insert-band.html");

I then just wrap my needed PHP code around that statement

Most of my HTML pages will include forms, for working with mySQL tables. Each of the forms of course has an "action" that references the next page (HTML page included within PHP as above). So far I have no problem with taking the output of my forms, processing it via PHP against the mySQL tables, and then displaying the next HTML page. My problem occurs when I need to fill in the HTML form with data selected from mySQL tables.

I would prefer to have my HTML and my PHP separated as I am currently doing. I was thinking I could either place tags, perhaps HTML comments, within my HTML pages and then parse and output the HTML files, filling in the data based on the tags. Otherwise It would be nice if I could directly reference the fields within the HTML forms (ie FrmInsert.lstSelectPerson for a listbox lstSelectPerson on a form named frmInsert) and then just use my PHP code to fill in the data for that field.

any and all help and suggestions would be appreciated.

Patrick
pglenn
Forum Newbie
Posts: 3
Joined: Sun Sep 14, 2008 3:35 pm

Re: how to fill in Forms on existing HTML pages using PHP?

Post by pglenn »

hmm, no replies, I figured this is something that would have been done by others many times :-(

anyways, a bit more detail. I did find the following link, which needs minimal modification to do "most" of what I need.
- http://www.onlamp.com/pub/a/php/2006/03 ... tml?page=1

I would have to load the $request array from mySQL rather than from $_REQUEST which isnt a problem, but I still am stuck on how to fill the LIST/COMBO/DROP-DOWN controls on my forms with the actual selection data from mySQL tables

(ie - I have a drop-down on my HTML form that allows me to select a band name, and I want those values to come from mySQL rather than the "default" entries already on the HTML form)

I am guessing on the HTML form, maybe I can surround my LIST/COMBO/DROP-DOWN controls with some sorta tags and then new functions can be written to replace those with mySQL generated controls? or maybe better, just surround the values themselves with tags? or maybe best just have some kinda tag instead of default values, and that tag itself is replaced with the mySQL data. I know the principle but again I am very new to PHP programming.

anyways, all help and suggestions are welcome

Patrick
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: how to fill in Forms on existing HTML pages using PHP?

Post by alex.barylski »

Code: Select all

file_get_contents('http://www.domain.com/that/holds/the/webpage/you/want/to/show.html')
It's literally that easy...probably to easy for most to bother answering...that and some might have concerns about you stealing content which is usually illegal and frowned upon. I'll give you the benefit of the dought cause I'm bored. ;)

Unless I misunderstand what it is your trying to do...I only read the first sentance or two. :D
pglenn
Forum Newbie
Posts: 3
Joined: Sun Sep 14, 2008 3:35 pm

Re: how to fill in Forms on existing HTML pages using PHP?

Post by pglenn »

Hockey wrote:

Code: Select all

file_get_contents('http://www.domain.com/that/holds/the/webpage/you/want/to/show.html')
It's literally that easy...probably to easy for most to bother answering...that and some might have concerns about you stealing content which is usually illegal and frowned upon. I'll give you the benefit of the dought cause I'm bored. ;)

Unless I misunderstand what it is your trying to do...I only read the first sentance or two. :D
thanks for the reply - but you should have read past the first couple sentences. I am NOT just trying to display existing HTML pages... I am trying to display existing HTML pages that have FORMS included within them, and use PHP code to fill in the values for the fields within the forms based on data within my mySQL tables

OH, and also I believe I stated the forms/HTML pages are my own that I and/or my HTML designer created. I dont want to re-invent the wheel by created pretty HTML pages and then break them up for PHP usage :-)

Patrick

PS - not trying to fllame you back or anything, seriously
Post Reply