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

help passing string between pages (Newbie)

Status
Not open for further replies.

rjseals

Technical User
Nov 25, 2002
63
US
I am kind of new to PHP so this might be an easy question but I have searched the internet and php.net for the solution with no luck. I have a form that the user puts information into. I pass there reponses to a confirmation page where their responses are reprinted out for them to confirm.

So this is what my confirmation page looks like.
php:
Code:
<? 
$type = $_POST['Type']; 
$position = $_POST['Position']; 
$site_location = $_POST['Site_Location']; 
$closing_date = $_POST['Closing_Date']; 
$status = &quot;open&quot;; 
$special_instructions = $_POST['Special_Instructions']; 
?>


I then basically echo the variables. (When I echo them it prints out the whole string.

Then I pass them in a hidden form to added.php

Code:
<p align=&quot;center&quot;><form method=&quot;post&quot; action=&quot;Added.php&quot;> 
<p><input type=&quot;hidden&quot; name=&quot;Type&quot; value='<?echo $type?>'> 
<p><input type=&quot;hidden&quot; name=&quot;Position&quot; value=  <?echo $position?>> 
.... 
<p align=&quot;center&quot;><input type=&quot;submit&quot; value=&quot;submit&quot;</p>


The problem that I am having is that if there is a string instead of just a word only the first word of the string gets passed to added.php.

So if their responses are
certified
Teacher
Wilson Middle School
etc

the only things that will get passed are
certified
Teacher
Wilson

How can I pass the whole string to added.php. THe part that I am the most confused about is when I echo their responses back for them to see on confirmation.php you can see the whole string. But I changed the &quot;hidden&quot; form boxes to regular text and echo'd them into the text box but again only the first word out of the string would show up.

I tried urlencode but that seems a little much for just passing a few string variables.

What am I missing.
 
One thing I've noticed is that your use of quotes around your attribute values wander a bit:

<p><input type=&quot;hidden&quot; name=&quot;Type&quot; value='<?echo $type?>'>
<p><input type=&quot;hidden&quot; name=&quot;Position&quot; value= <?echo $position?>>


In the above two lines you use double-quotes for some things, single-quotes for some things, and no quotes for some things. The lack of quotes around the value for the &quot;Position&quot; element will definately cause problems if there are no quotes.

Some browswers will treat single-quotes and double-quotes as the same. But don't depend on that, as the HTML spec calls for double-quotes. Put double-quotes around all attribute values.

Try the lines as:

<p><input type=&quot;hidden&quot; name=&quot;Type&quot; value=&quot;<?echo $type?>&quot;>
<p><input type=&quot;hidden&quot; name=&quot;Position&quot; value=&quot;<?echo $position?>&quot;>




Want the best answers? Ask the best questions: TANSTAAFL!!
 
That is strange I tried all different combinations of single double and no quotes and I would have sworn I did that one. Anyways that worked and I appreciate your help!
 
what are you doing with this? looks like a job application gone wrong.. why are they hidden values? let me see more of the form perhaps i can help a little.

also reason might be is the space is ening the value attribute possibly.. so make sure tha when it echos the code to the browser that there is value=&quot;wilsons value&quot; and not value=wilsons value..

ive made that mistake a few times.. 0.o just check source of html feed back..

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
I have them hidden because thats the only way I know how to send the variables from page1 to page2(to be confirmed) to page 3(to be entered into the database). Basically the user enters info into the first page, then I echo it back so they can make sure its correct. The only way I know how to send it to the third page is stick it into a hidden form to the third page. If you have any other recommendations I would gladly hear them. I am just barely beginning with php programming so by all means any help would be greatly appreciated.
 
Ill check it out... Thanks for everyones help.
 
im not sure how much data your storing but for smaller things you can pass strings through links..




would set variables


$cmd = post
$jump = 5


good for storing bits of info.. i imagine you can do it a bit bigger.. but thats the way i usually pass info. or through sessions..

sessions only last as long as the browser is open.. once it closes so does the session.

this is a newer way to do it with the new php version

<? session_start(); ?> //must be the first line of the php file unless other header info is with it.



then lets say you have a nice long strign you want to send to next page..

$superstring = &quot;some long string here&quot;;
session_register('superstring');
//registers the session.

now once you move on to the next page you can access that data from the $superstring variable... notice i didnt put a $ in the register.. dont it wont work.

then once your done with the session just...
session_unregister('superstring');
and its all gone.




there are other ways to do sessions.. that was is just the new simple way hehe.. thought im sure ill get responds with use $_SESSION and stuff.. theres few ways.. just gettign ya started :D (im new to php to though ;D hehe)

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
oops btw... the pages you are seing the info to must also have <? session_start(); ?> up top as well then the information will be getable.




and the link way i mentioned above.. is a $_GET['$string'] function btw.. (if yr using older php or have it shut off in the ini)

in the begining man created code.
in the end code will create man.
clones are coming only matter of time.
examples?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top