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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
> > 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 |
|
|||
|
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 > > |