Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion of HTML form to PHP 1

Status
Not open for further replies.

ZOR

Technical User
Jan 30, 2002
2,963
GB
I have 3 HTML form pages which I want to convert to PHP. The control content is the same for all 3 pages, being text boxes.I have changed the extension of one form to .php, and it still lives as I presume the server is looking at the page and doing nothing as no php tags are in there. The reason I want to convert them is to allow for sessions to be used in order to keep data alive whilst moving from form to form. As they are just straight inputs as text am I going to get away with just adding in php tags on the pages. I know I have to include the session header, but is this going to work? A final PHP page will deal with the 3 pages of data. Regards
 
but is this going to work?

did you try it? I'm sure it will...you should start the sessions and then use the session vars through the forms.

Cheers.

Chacal, Inc.[wavey]
 
That what I like to hear, thanks. I thought I would check it out before doing too many changes. I am using Frontpage and it's a pain in the neck at times. I tried copying a form as a backup, gave it a new name. I started working on it (Intelligent Buttons). Yes they were intelligent, after changing their legends and paths, I found it had changed the original page as well. So I am restricting major changes until I know where I'm going. Presumeably I put the PHP tags early on for things to work? Thanks
 
You're not going to be able to make all that FrontPage folderol work with PHP. Most of that additional functionality, like Intelligent Buttons, requires server-side ASP to work.

I generally use a good text editor. For a list of editors recommended by your fellow TT members, see faq434-4252


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
It all kept crashing. I removed every bit of code other than text box inputs and still it screwed up. I am going to start at the beginning again. Can someone be so good as to insert the PHP tags in where they should go, and any reference in the beginning ie HTML W3 etc. From this I can quickly reproduce my form again. Many thanks.
 
Stupid me, forgot to put the basic starting off code:

It all kept crashing. I removed every bit of code other than text box inputs and still it screwed up. I am going to start at the beginning again. Can someone be so good as to insert the PHP tags in where they should go, and any reference in the beginning ie HTML W3 etc. From this I can quickly reproduce my form again. Many thanks.



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>

</head>

<body>

<p><input type="text" name="T1" size="20"></p>

</body>
</html></html>
 
I don't understand. Why do you want to add PHP tags to a static HTML page?

It's not the above that needs PHP start- and end-tags. It's the script to which this HTML page will submit its data.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
I have several HTML pages where I want to put all the value data into a final PHP form which will finally deal with all the data. Someone said it would be better to convert all these HTML pages into PHP to enable constant data passing. Am I correct, if I have one HTML form, and transfer the data into a PHP page, this will be lost if I repeat the operation again with another HTML form. I can't seem to get it clear to people
what I'm trying to do. I asked if I would need to go from an HTML form with the data into a PHP form to put the data into a database, I was told there was no need if all my forms were of PHP. So do you see, I am going round in circles. I appreciate the help to date, but would appreciate getting put in the right direction. Thanks again
 
It makes absolutely no difference to PHP's session-handling system whether the path through your application is:

a.html submits to 1.php which redirects to b.html which submits to 2.php which redirects to c.html which submits to 3.php

or whether your application flow is:

a.php submits to 1.php which redirects to b.php which submits to 2.php which redirects to c.php which submits to 3.php

This is because web appliations are discontinuous. It doesn't matter if 5 static pages are between two PHP scripts, so long has both PHP scripts are run in the same browser session.



Want the best answers? Ask the best questions!

TANSTAAFL!!
 
So, finally confirming I can open form1 HTML, pass data to Store.php, then open form2 HTML, pass data into Store.php etc etc, and the variables/data will still be in the system. If that the case then I only need a section in the HTML code where php start and end tags are placed to deal with the transfer. If this is all correct then thats much clearer and I can finally see the clouds.
 
Let's be clear with our metaphors.

You can direct your browser to fetch form1.html from the server. Once your browser has rendered the form you can interact with the form by entering data in certain fields. Once the data in the fields is correct to your satisfaction, you will then direct the browser to submit the data in the form.

Your browser will open a connection to the web server, and instructs the web server to run store.php and to pass to the script the data from the from, which the browser provides.

store.php will then process the submitted data in some way.


Your application may require that the HTML pages that contain the forms to be generated by a script rather than be static HTML pages. I cannot say as I only know generalities about your application. I am only saying that PHP's session-handling mechanism doesn't require that the form be dynamically generated.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Many thanks. re:

"store.php will then process the submitted data in some way."

If you go HTML/PHP/HTML/PHP each time going from a different HTML form and putting data into the PHP form/page, will it retain all the transactions.........
 
will it retain all the transactions"

Can it? Certainly. Will it? Not necessarily.

You must always keep in mind that web applications are discontinuous.

"Discontinuous" in this context means that, unlike a console application, application software is not running all the time. So there is no memory kept alive to keep variables available. The order of operations is:[ol][li]Browser contacts a script through a web server and possibly submits data[/li][li]web server runs script, sending output to the browser.[/li][li]script run stops, and all variables loaded in memory go to the great beyond that all variables do to when their application's quit running.[/li][li]Browser renders output[/li][li]user interacts with what the browser has rendered, user instructs browser to contact script and submit data[/li][li]Skip to step 1[/li][/ol]

An important step is "script run stops". Because the script must stop its execution and be run from scratch again at a later time, scripts must find some state-maintaining mechanism to keep variables alive. This is where session variables come in. But scripts do not use session variables automatically -- you must write your script to explicitly use them.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Many thanks for your patience. It all seems so hit and miss. After all the time the Internet has been around, and the money
people have been spending with Microsoft, it ends up with nothing always working, software that only goes part way etc etc. All of a bit of a joke. So the owness if I get it right, is for the PC that is doing all the communications to hang in there, sessions are the way to increase reliability in the chain. Presumeably, the session part has to be at the front of every page? I was looking forward to this project comming from Visual Basic being glad not to have the trauma of learning VB.Net. I should have been a dustman. You deserve a star for putting up with my tooing? and froing? Regards
 
It's not hit-and-miss. It's just that there are three fundamental differences between what you're used to and what you're dealing with now:[ol][li]you're going from one programming paradigm (console applications) to another (web applications), and a lot of conveniences aren't available,[/li][li]you're switching to a language (PHP) that has not been engineered specifically to insulate you from all the low-level nitty-gritty that all programs require (VB), and[/li][li]you're entering into a world where standards, once agreed upon, are generally adhered to (HTTP/HTML versus the entire Microsoft-specific world)[/li][/ol]

You must keep in mind that the world wide web was not invented for Amazon to sell books -- it was invented for scientists to publish documents. There was no concept at all of state-maintenance between script runs on the world wide web until Netscape invented HTTP cookies. And that event didn't happen all that long ago.

You're right -- you're not in some safe little Microsoft-centric world any more. You're learing a programming language that can[ul][li]talk to multiple database systems natively (without the overhead of ODBC),[/li][li]generate, without having to pay for expensive third-party libraries, graphics on the fly, and[/li][li]actually run on more than one operating system[/li][/ul]

So, yeah, you're going to have to get out of your comfort zone a little.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Okay, I give in. As you say, comming into this region from VB, yes there were far more facilities (comforts) in what you could do, and to give up basic things like control properties etc is difficult and I have to forego those. Unfortunately loosing those at a time when I am having to learn basic building blocks like yesterday of web design aint easy. However I must say without people like you on the forum would be a disaster, your guidance is invaluable. All I can say is I and many others are greatful you come back to us, even though at times you must think here we go, another one. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top