2 Forms

This is a discussion on 2 Forms within the PHP Language forums, part of the PHP Programming Forums category; I was handed a voting form that the company has used in previous years, for updating. The first page is ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-06-2006
Jerim79
 
Posts: n/a
Default 2 Forms

I was handed a voting form that the company has used in previous years,
for updating. The first page is a form, asking for name, business name,
title and email address(twice for verification). The form gets posted
to a verfication PHP script that checks that the email addresses match
and that the email address isn't already in the database. If there is a
problem, it sends you back to the first form; if everything is okay it
sends you on to the second form.

The second form is the actual voting form. At the top of the screen,
the customer's information is displayed for them, using PHP variables.
So that name, business name, and title are at the top. Customer fills
out the form and clicks submit. The form forwards to a PHP script for
inserting the data into MySQL. This is where the problem comes in.
Everything but the name, title and email address gets written to the
database. I have checked my SQL query and it is find. My working theory
right now is that the second form erases all variables from the first
form, as for as the system is concerned. Here is a line of code from
the second form:

<form method="POST" action="check.php?email=<?php echo $email ?>">

It looks like the origional program was passing email in the URL which
would explain why email works but the name, business name and title
don't. I think the origional coder knew the issue. I am looking for
confirmation of my belief that only one set of variables can exist at a
time, from a form for any given method. If that is true, how do I pass
multiple variables in the URL above? I tried seperating them with
commas or ?.

Reply With Quote
  #2 (permalink)  
Old 12-06-2006
Jerim79
 
Posts: n/a
Default Re: 2 Forms


Jerim79 wrote:
> I was handed a voting form that the company has used in previous years,
> for updating. The first page is a form, asking for name, business name,
> title and email address(twice for verification). The form gets posted
> to a verfication PHP script that checks that the email addresses match
> and that the email address isn't already in the database. If there is a
> problem, it sends you back to the first form; if everything is okay it
> sends you on to the second form.
>
> The second form is the actual voting form. At the top of the screen,
> the customer's information is displayed for them, using PHP variables.
> So that name, business name, and title are at the top. Customer fills
> out the form and clicks submit. The form forwards to a PHP script for
> inserting the data into MySQL. This is where the problem comes in.
> Everything but the name, title and email address gets written to the
> database. I have checked my SQL query and it is find. My working theory
> right now is that the second form erases all variables from the first
> form, as for as the system is concerned. Here is a line of code from
> the second form:
>
> <form method="POST" action="check.php?email=<?php echo $email ?>">
>
> It looks like the origional program was passing email in the URL which
> would explain why email works but the name, business name and title
> don't. I think the origional coder knew the issue. I am looking for
> confirmation of my belief that only one set of variables can exist at a
> time, from a form for any given method. If that is true, how do I pass
> multiple variables in the URL above? I tried seperating them with
> commas or ?.


I was able to find that the & symbol is the seperator between multiple
variables. It is working now. I still haven't found confirmation that
only one set of POST or GET variables can exist at one time. If this is
true, I wonder how the problem is handled at larger companies where
multiple POST forms could make up a site. Certainly they don't resort
to URL GET as I could see how the strings could be quite long in some
cases.

Reply With Quote
  #3 (permalink)  
Old 12-06-2006
Moot
 
Posts: n/a
Default Re: 2 Forms

Jerim79 wrote:
> My working theory
> right now is that the second form erases all variables from the first
> form, as for as the system is concerned.


Indeed, this is the case. A form submission is a *one-time-only*
action. Whatever form fields exist are passed to the next page,
afterwhich they no longer exist. Submitting that second form passes on
the second form's data, but none of the first.

> <form method="POST" action="check.php?email=<?php echo $email ?>">
>


Eww. This just looks like a bad idea. Typically, to have forms span
multiple submissions, you need to propogate the form fields, but not
like this. The easiest way is to use hidden form fields. IE, something
like:
<input type="hidden" name="name" value="<?php echo $_POST['name'] ?>">

You give each piece of data you want to propogate it's own hidden
element, that way this data gets included along with the next form
submission.

Reply With Quote
  #4 (permalink)  
Old 12-06-2006
Jerim79
 
Posts: n/a
Default Re: 2 Forms


Moot wrote:
> Jerim79 wrote:
> > My working theory
> > right now is that the second form erases all variables from the first
> > form, as for as the system is concerned.

>
> Indeed, this is the case. A form submission is a *one-time-only*
> action. Whatever form fields exist are passed to the next page,
> afterwhich they no longer exist. Submitting that second form passes on
> the second form's data, but none of the first.
>
> > <form method="POST" action="check.php?email=<?php echo $email ?>">
> >

>
> Eww. This just looks like a bad idea. Typically, to have forms span
> multiple submissions, you need to propogate the form fields, but not
> like this. The easiest way is to use hidden form fields. IE, something
> like:
> <input type="hidden" name="name" value="<?php echo $_POST['name'] ?>">
>
> You give each piece of data you want to propogate it's own hidden
> element, that way this data gets included along with the next form
> submission.


Thank you. I had thought about hidden buttons, but wasn't sure if that
was the way to go. I will go back and do it the way you suggested.

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 06:53 AM.


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