Jump to content

Parent/child form - can someone explain the "cheese" example?


dkperez

Recommended Posts

I'm sure you guys have seen this example a ton of times, but I need to figure out how to do parent/child forms so I can call the child when a button gets hit on the parent, and stay on the child until the user exits...... I found this example, but I'm not good enough at php yet to figure out how to make it work.... Can one of you tell me what's missing or what needs to be done differently or whatever? And am I supposed to have html stuff top and bottom - is this whole bunch of php supposed to be inside an html body or something?

 

When I run this the display_name appears to run. BUT, stage doesn't seem to ever get set to "cheese". How come?

 

And at the bottom, in the else, if process_form. Isn't process_form a function? And where is it?

 

<?php

function display_name() {

global $PHP_SELF;

?>

<FORM TARGET="<?php echo $PHP_SELF; ?>" METHOD=GET>

Name: <INPUT TYPE=TEXT NAME="name"><BR>

<INPUT TYPE=HIDDEN NAME="stage" VALUE="cheese">

<INPUT TYPE=SUBMIT VALUE="Thanks!">

</FORM>

<?php

}

?>

 

<?php

function display_cheese() {

global $PHP_SELF;

global $name;

?>

<FORM TARGET="<?php echo $PHP_SELF; ?>" METHOD=GET>

Favorite Cheese: <INPUT TYPE=RADIO NAME="cheese" VALUE="brie">Very soft French Brie

<INPUT TYPE=RADIO NAME="cheese" VALUE="cheddar">Farmhouse English Cheddar

<INPUT TYPE=RADIO NAME="cheese" VALUE="mozzarella">Italian Buffalo Mozzarella

Favorite Times to Eat Cheese: <INPUT TYPE=CHECKBOX NAME="times[]" VALUE="m">Morning

<INPUT TYPE=CHECKBOX NAME="times[]" VALUE="n">Noon

<INPUT TYPE=CHECKBOX NAME="times[]" VALUE="d">Dinner

<INPUT TYPE=CHECKBOX NAME="times[]" VALUE="l">Late night

<INPUT TYPE=HIDDEN NAME="name" VALUE="<?php echo htmlspecialchars($name); ?>">

<INPUT TYPE=HIDDEN NAME="stage" VALUE="results">

<INPUT TYPE=SUBMIT VALUE="Thanks!">

</FORM>

<?php

}

?>

 

<?php

if (empty($stage)) { display_name(); }

elseif ($stage == 'cheese') { display_cheese(); }

else { process_form(); }

?>

Link to comment
Share on other sites

Bad question?  Silly question?  One everybody else already knows the answer to?

 

At least, can SOMEONE point me to a WORKING EXAMPLE of a parent/child type form that actually works 'cause this is getting close to being a MAJOR problem that's going to force me to dump php and go to something like Visual Studio...

Link to comment
Share on other sites

dump php and go to something like Visual Studio...

 

how WOULD that SOLVE your PROBLEM?

 

i guarantee you that you'll find VB much more frustrating and less functional since it's not open source.  it's Microsoft.

 

AND, keep in mind .. your MAJOR problem is nobody elses problem.

 

look at this line for example:

 

And at the bottom, in the else, if process_form. Isn't process_form a function? And where is it?

 

are you asking where your function is?  how is anybody supposed to help you.  i read a line like that and i see countless hours of help needing to be invested.  and since you're not paying me, i move on.  so, don't get all upset if nobody is giving you free help, and threaten to drop PHP and move to VB/ASP, 'cause i don't believe anybody around here will lose any sleep over it.

 

1. think about your questions.  i mean

Can one of you tell me what's missing or what needs to be done differently or whatever? And am I supposed to have html stuff top and bottom - is this whole bunch of php supposed to be inside an html body or something?
don't suffice as decent questions.  you don't need to be good at something to be able to ask proper questions.

 

2. have you been specific enough without rambling on?

 

3. have you given as much relevant information about the problem at hand, including any error messages that might have occurred?

 

/rant;

Link to comment
Share on other sites

No, I'm not asking where MY function is, I'm asking what should actually BE in the example I found on the web that purports to enable a user to move between two forms.  As I said in the text ABOVE the example "I found this example, but I'm not good enough at php yet to figure out how to make it work.... Can one of you tell me what's missing or what needs to be done differently or whatever? And am I supposed to have html stuff top and bottom - is this whole bunch of php supposed to be inside an html body or something?"

 

Thus the reason for my confusion.  I'd like to have parent/child forms/screens or whatever, but haven't found a GOOD explanation of exactly how to put them together with php.  Or an example that SHOWS how they go together with php...  Which is WHY I came here to have an expert look at the example, and perhaps EXPLAIN how this is supposed to work, and maybe fill in the missing gaps..... 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.