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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Confirming Form Information 1

Status
Not open for further replies.

Julzzey

Programmer
Sep 2, 2002
19
US
Hi,

I'm new to this and I'm wondering what the best way is to handle this. I have the user enter information into a form and then when they hit submit I have to show them the information and say "is this correct?" If it's right then they hit yes and my program needs to open the database and add the info. If they say no I need to go back to the form and allow them to change things. I can open the database and show the form, but I don't know how to deal with the buttons. Can I do this all in one file, or do I need multiple pages? Any help would be appreciated.

Thanks!!
 
Don't think of this as a single file or mulitple pages. This of your accomplishing this using a single script file or multiple script files.

You can do it either way. If you use multiple scripts (one to produce the original form, a second to produce the confirmation page, and a third to do the insertion), then make sure that on the intermediate page you both display the values entered and carry them forward in a set of hidden form fields.

My programming style is to use a single script file. PHP has the ability to perform both GET-method and POST-method form input at the same time, which can come in handy for situations like this.


Want the best answers? Ask the best questions: TANSTAAFL!
 
I've searched for the difference between the get and the post, but I can't find it. I don't understand how I would use those. Would I have my form first thing and then if they hit submit my form goes away and it shows them the information for them to confirm? How do I do that in one script?

Thanks!!
 
GET-method forms send their information via the URL.

POST-method forms send their information via a data stream the browser opens with the server.

POST can send more information than can GET. There is a limit to how long a URL can be.


My method makes use of both GET and POST method. My script would be divided into three sections, and would run each section depending on the value of a GET-method input called "action".

Here's the basic layout of the script:

$act = '';
if (is_set ($_GET['action'])
{
$act = $_GET['action'];
}

switch ($act)
{
case 'confirm':
//perform those steps necessary to confirm and preserve data
break;

case 'insert':
//perform those steps necessary to insert data and either show a "got it" page or redirect the browser
break;

default:
//perform those steps necessary to display the original blank form.
}



Want the best answers? Ask the best questions: TANSTAAFL!
 
I really appreciate all of your help, but I'm still lost. What does the

if (is_set ($_GET['action'])
{
$act = $_GET['action'];
}

do? Is is_set a built in function? In the default I'd put my regular form, but do I use the get or the post method.

Thanks Again!!
 
Yes, is_set() is a PHP builtin function. For information on this and all of PHP's functions, point your browser to
I would use both GET and POST at the same time. The initial form (produced by the default section of the switch) have an opening tag like:

<form method=POST action=&quot;

The confirmation page (produced by the &quot;confirm&quot; action section of the switch) would probably display the user-entered data both visually and in a form the opening tag of which would look like:

<form method=POST action=&quot;
This page could, I suppose have two forms, one if to confirm the data, the other to re-edit. The second form's opening tag would be of the form:

<form method=POST action=&quot;
You could either provide visible submit buttons for the two forms or use JavaScript-target links to submit them programmatically.

The third part of the script doesn't produce a form

Want the best answers? Ask the best questions: TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top