jwk811 Posted August 24, 2006 Share Posted August 24, 2006 I'm trying to catch a piece of data from a form into a variable for further use. I'm not sure if this is even possible because I tried what I figured would be right and an error message came up on the next page.Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/j/w/k/jwk811/html/form2.php on line 5So this way I'm guessing that you can't make a piece data from a form into a variable that way. Well I don't know if I'm making a mistake but there is another way out there to do this without using variables.This is what my situation looks like. I am trying to get data from a form to be used on ,not only the page it is directed to by the form action, but the next few pages after it.I have asked about this to someone before and I think it has something to due with cookies or/and sessions, but I have no idea how to do this as I am very new to php and a lot of this stuff doesn't make that much sense to me. If anyone has any answers for me that will be incredible. Thanks for any help! Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/ Share on other sites More sharing options...
Orio Posted August 24, 2006 Share Posted August 24, 2006 http://www.google.com/search?hl=en&lr=&q=%22multi+page%22+forms+php+tutorialLot's of good stuff there.Orio. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79759 Share on other sites More sharing options...
wildteen88 Posted August 24, 2006 Share Posted August 24, 2006 Could you provide some code so can diagnose the error you are getting. You can get get form data into a another varibale like so:[code=php:0]$somevar = $_POST['your_field_name_here'];[/code]Now $somevar variable holds the value $_POST['your_field_name_here']; has. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79761 Share on other sites More sharing options...
jwk811 Posted August 24, 2006 Author Share Posted August 24, 2006 Okay, for my first page where the form is, I sent the data to another page where I tried to catch the data and put it into a variable like this.Form-<FORM METHOD="POST" ACTION="nextpage.php"><INPUT TYPE="text" NAME="name" SIZE="30"><INPUT TYPE="submit">Next Page-<?php$name="$_POST["name"]";echo $name;?>I just put out two test pages like that and coudn't get it to work. I keep getting this error:Parse error: parse error, unexpected '\"', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/j/w/k/jwk811/html/form2.php on line 5I'm gonna try playing around with this a little more but if you can tell me what I'm doing wrong that would be great. And as I said I'm using this data from the form to be caught into a variable so I can use that variable in further pages. Now, I'm not even sure that's going to work. So, if there is a different method to do that and anyone knows how I would really appreaciate some information. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79896 Share on other sites More sharing options...
.josh Posted August 24, 2006 Share Posted August 24, 2006 your error is with your quotes. try this:$name = $_POST['name']; Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79901 Share on other sites More sharing options...
jwk811 Posted August 24, 2006 Author Share Posted August 24, 2006 Ahhhh... I thought that would be the problem and changed it all then a different error came up:Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/content/j/w/k/jwk811/html/form2.php on line 5Would you know how to fix this one? Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79907 Share on other sites More sharing options...
wildteen88 Posted August 24, 2006 Share Posted August 24, 2006 Post the code in form2.php, if its more than 10 lines post lines 3 - 8 here. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79916 Share on other sites More sharing options...
jwk811 Posted August 24, 2006 Author Share Posted August 24, 2006 I have it posted in form2.php Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79943 Share on other sites More sharing options...
wildteen88 Posted August 24, 2006 Share Posted August 24, 2006 huh? I'm confused. I mean post the code. Did you post the code from form2.php earlier. Or have I missed something. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79960 Share on other sites More sharing options...
.josh Posted August 24, 2006 Share Posted August 24, 2006 repost form2.php Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79961 Share on other sites More sharing options...
jwk811 Posted August 24, 2006 Author Share Posted August 24, 2006 I don't understand. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-79979 Share on other sites More sharing options...
wildteen88 Posted August 24, 2006 Share Posted August 24, 2006 Post the code that is in form2.php here Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-80020 Share on other sites More sharing options...
jwk811 Posted August 25, 2006 Author Share Posted August 25, 2006 I got the form data into variables. The variable can only be used on the same page. Why? If I lead the next form to another page and try to use the <?php echo $variable?> statment. It will not work and page won't come up because of that error. This is the warning that I got:Warning: reset(): Passed variable is not an array or object in /home/content/j/w/k/jwk811/html/gdform.php on line 8Warning: Variable passed to each() is not an array or object in /home/content/j/w/k/jwk811/html/gdform.php on line 13Warning: Cannot modify header information - headers already sent by (output started at /home/content/j/w/k/jwk811/html/gdform.php:8) in /home/content/j/w/k/jwk811/html/gdform.php on line 23Does anyone know what this means? Please help! Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-80117 Share on other sites More sharing options...
wildteen88 Posted August 25, 2006 Share Posted August 25, 2006 You can only use variables on one page, you cannot use variables one page and then be able to use the same variable on another page. As when php parses the script it stops at the end and clears any variables. However if you want to use a variable on one page and then use it in another you'll have to use a cookie or session. Quote Link to comment https://forums.phpfreaks.com/topic/18520-formsvariablescookiessessions-help-me-please/#findComment-80320 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.