designing source code for multiple forms

This is a discussion on designing source code for multiple forms within the PHP Language forums, part of the PHP Programming Forums category; Hi I want to start writing a new site. It will include 3 forms that will collect information from the ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-08-2005
yoelgold@yahoo.com
 
Posts: n/a
Default designing source code for multiple forms

Hi
I want to start writing a new site. It will include 3 forms that will
collect information from the user. I know how to keep the info in
sessions etc. my question is about the design of the server side php
files. I don't want to design all three forms in one big file, id
rather have a separate php file for each form.

Say I have a file form1.php which creates the initial form, should I
say (form1 action="form1.php") and have the form validation code in
form1.php? If so how do I call form2.php from inside form1.php? Or do I
say(form1 action ="form2.php") and have my validation code for form 1
inside form2.php if so how do I call back form1 if validation fails

now this has been asked already (see link below)and it was suggested to
use the include() require() functions. but then others have argued
against it. so is includeonce() the most practical way or should I
rather write all the code in to one big index.php

Reply With Quote
  #2 (permalink)  
Old 02-08-2005
yoelgold@yahoo.com
 
Posts: n/a
Default Re: designing source code for multiple forms


>
> now this has been asked already (see link below)and it was suggested

to
> use the include() require() functions. but then others have argued
> against it. so is includeonce() the most practical way or should I
> rather write all the code in to one big index.php


sorry i forgot to include the link, here you go

http://groups-beta.google.com/group/...k+to+Search&&d

Reply With Quote
  #3 (permalink)  
Old 02-08-2005
ggg@gg.com
 
Posts: n/a
Default Re: designing source code for multiple forms

I can't think of a good reason for either case -- wether you have
separate files for each section, or have one big file. That's why I'd
say it's more of stylistic issue.

That said, I'd argue for multiple pages, because, to me, it fits in
better with the logical flow of what you want to do. Like another guy
said in that old thread - I like the one-to-one correlation between
script and URL.

I typically have my form validation on the same page. Here's a sketch of
what I'm thinking. In form1.php:

<?

// if it's valid submitted data, go to step 2
if (isValid())
header();
?>

<form action="form1.php" method="POST">
<!--- the form elements -->
</form>


....then in form2.php you could store the passed variables in a <input
type="hidden"> fields.

...then if you have problems, and the user has to go back to form1.php
you have those form1 varaiables tracked.

It sounds like you want to avoid passing everything around? I guess you
could use sessions, as you mentioned or, cookies.


In article <1107898647.435794.272210@c13g2000cwb.googlegroups .com>,
yoelgold@yahoo.com says...
> Hi
> I want to start writing a new site. It will include 3 forms that will
> collect information from the user. I know how to keep the info in
> sessions etc. my question is about the design of the server side php
> files. I don't want to design all three forms in one big file, id
> rather have a separate php file for each form.
>
> Say I have a file form1.php which creates the initial form, should I
> say (form1 action="form1.php") and have the form validation code in
> form1.php? If so how do I call form2.php from inside form1.php? Or do I
> say(form1 action ="form2.php") and have my validation code for form 1
> inside form2.php if so how do I call back form1 if validation fails
>
> now this has been asked already (see link below)and it was suggested to
> use the include() require() functions. but then others have argued
> against it. so is includeonce() the most practical way or should I
> rather write all the code in to one big index.php
>
>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 10:31 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0