passing variables through functions
Moderator: General Moderators
-
jenjenut233
- Forum Newbie
- Posts: 7
- Joined: Fri Sep 29, 2006 2:23 pm
passing variables through functions
used to be a question here.
Last edited by jenjenut233 on Sun Feb 19, 2012 10:43 pm, edited 1 time in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
-
jenjenut233
- Forum Newbie
- Posts: 7
- Joined: Fri Sep 29, 2006 2:23 pm
used to be a question here.
Last edited by jenjenut233 on Sun Feb 19, 2012 10:44 pm, edited 1 time in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Have you thought of maybe including them? Say something along the lines of...
Form1.php
Form1.php
Code: Select all
<form name="quote" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="radio" name="logo" value="Logo for Web" />
<input type="radio" name="logo" value="Logo for Print" />
<input type="radio" name="logo" value="Identity Package" />
<input type="radio" name="web" value="5 Page Website" />
<input type="radio" name="web" value="10 Page Website" />
<input type="radio" name="web" value="20 Page Website" />
<input onclick="setDisplay('5','block');" type="checkbox" name="web2" value="Additional Pages" />
<input type="text" size="2" name="additional_pages" />
<div align="center">
<input type="submit" name="check_quote" value="View Total" />
<input type="reset" name="reset" value="Clear Form" />
</div>
</form>Code: Select all
function form1() {
include 'form1.php';
}-
jenjenut233
- Forum Newbie
- Posts: 7
- Joined: Fri Sep 29, 2006 2:23 pm
Yes I have. But if the includes are called within a function, then that still doesn't help with my problem of the variables being passed from the first section to the last. The form variables are all being set within the if (isset(check_quote)) block... so when the script gets to the else if (isset(send)) block, it has rid itself of the local variables within the first and won't pull them into the latter unless they are passed somehow (typically through return values or global variables - none of which are working for me in this case.)
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Might I suggest either sessions or hidden form values?
What you have is a stepped process of form completion, so after step 1, the user is sent to step 2 where information from step 1 was used. Step 2 repeats the process to step 3.
Maintaining state between the steps is either going to be done with carrying the $_POST array data through with hidden form fields or by pushing data by the query string using the $_GET array or by sessions.
What you have is a stepped process of form completion, so after step 1, the user is sent to step 2 where information from step 1 was used. Step 2 repeats the process to step 3.
Maintaining state between the steps is either going to be done with carrying the $_POST array data through with hidden form fields or by pushing data by the query string using the $_GET array or by sessions.
-
jenjenut233
- Forum Newbie
- Posts: 7
- Joined: Fri Sep 29, 2006 2:23 pm
Thank you for your help! 
Last edited by jenjenut233 on Sun Feb 19, 2012 10:44 pm, edited 1 time in total.
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA