Problem in Passing PHP variables over multiple php pages
Moderator: General Moderators
Problem in Passing PHP variables over multiple php pages
hi all.
dear programmers and developers i am begineer to php progrmming.
i am working on php 5.2.3.3 with IIS on windows XP 2006 version.
i want to get information from user to a form named "form.htm"and then i pass values to php page named "info.php" by using $_POST method. upto this state nothing is wrong there but the problem starts when i want to use that $_POST[]
values to second php page named "access.php". i cannot get those values to second php page.
i have no idea of php sessions if any body guides me that how i can do all that with phpsession or with some other approach. i would be very thankful.
Regards..
maani janjua
dear programmers and developers i am begineer to php progrmming.
i am working on php 5.2.3.3 with IIS on windows XP 2006 version.
i want to get information from user to a form named "form.htm"and then i pass values to php page named "info.php" by using $_POST method. upto this state nothing is wrong there but the problem starts when i want to use that $_POST[]
values to second php page named "access.php". i cannot get those values to second php page.
i have no idea of php sessions if any body guides me that how i can do all that with phpsession or with some other approach. i would be very thankful.
Regards..
maani janjua
Last edited by maani786 on Fri Jul 13, 2007 5:33 am, edited 1 time in total.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
Basically you need to initialise the "start" of session usage:
Put this at the very top of your page
Whenever you want to pass variables to multiple pages when you can't use "POST" simply setup some "SESSION" variables:
Remember you must have a value that the "SESSION" can be set to i.e. you must "submit" form data ("POST" values must exist).
Put this at the very top of your page
Code: Select all
session_start();Code: Select all
$_SESSION["first_name"] = $_POST["first_name"];thanks for ur reply
respected sir
i have did all that in the same way u told.
i send information from a form' s textfield and that values is diplayed at ist page of php which is called by form's action method.
and after that i displayed that value at php page by using session variable.
the value is displayed accurately but a message along with value is also displayed.
"PHP Warning: session_start() [function.session-start]: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in C:\Inetpub\wwwroot\phpsessions\1.php on line 2 PHP Warning: Unknown: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in Unknown on line 0 PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\DOCUME~1\maani\LOCALS~1\Temp\php\session) in Unknown on line 0 "
what i am looking for is to use that value( which was passed by form to php page )
to another php page i am using the same session variable which was created in previous php page but nothing is displayed there and i got only this message
"PHP Warning: session_start() [function.session-start]: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in C:\Inetpub\wwwroot\phpsessions\2.php on line 2 PHP Notice: Undefined index: text in C:\Inetpub\wwwroot\phpsessions\2.php on line 14 PHP Warning: Unknown: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in Unknown on line 0 PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\DOCUME~1\maani\LOCALS~1\Temp\php\session) in Unknown on line 0"
what could be the solution
regards
-----------
maani janjua
i have did all that in the same way u told.
i send information from a form' s textfield and that values is diplayed at ist page of php which is called by form's action method.
and after that i displayed that value at php page by using session variable.
the value is displayed accurately but a message along with value is also displayed.
"PHP Warning: session_start() [function.session-start]: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in C:\Inetpub\wwwroot\phpsessions\1.php on line 2 PHP Warning: Unknown: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in Unknown on line 0 PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\DOCUME~1\maani\LOCALS~1\Temp\php\session) in Unknown on line 0 "
what i am looking for is to use that value( which was passed by form to php page )
to another php page i am using the same session variable which was created in previous php page but nothing is displayed there and i got only this message
"PHP Warning: session_start() [function.session-start]: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in C:\Inetpub\wwwroot\phpsessions\2.php on line 2 PHP Notice: Undefined index: text in C:\Inetpub\wwwroot\phpsessions\2.php on line 14 PHP Warning: Unknown: open(C:\DOCUME~1\maani\LOCALS~1\Temp\php\session\sess_h4peelbc3vhgimb0p8putkbbk2, O_RDWR) failed: Permission denied (13) in Unknown on line 0 PHP Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\DOCUME~1\maani\LOCALS~1\Temp\php\session) in Unknown on line 0"
what could be the solution
regards
-----------
maani janjua
runto find the php.ini you have to edit.
Open this file in a text editor and search for session.save_path.
Set the value to a valid directory where php can save the session data and save the file.
Restart the webserver.
Code: Select all
<?php echo 'ini: ', get_cfg_var('cfg_file_path'); ?>Open this file in a text editor and search for session.save_path.
Set the value to a valid directory where php can save the session data and save the file.
Restart the webserver.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
thanks
thats good idea .
i changed path and all error messages vanished.
but still i cannot get value at second page of php
i have to reintialize the session variable in second page?
because there is no value.
"my code for page 1.php is"
"Code for page 2.php is"
i changed path and all error messages vanished.
but still i cannot get value at second page of php
i have to reintialize the session variable in second page?
because there is no value.
"my code for page 1.php is"
Code: Select all
<?php
session_start();
$_session['text']=$_POST["textfield"];
?>
<?php
echo "Php Page # 1 session: ".$_session['text'];
?>
<form method="post" action="2.php">
<input type="submit" name="submit" id="submit" value="Next Page" class="button" />
</form>"Code for page 2.php is"
Code: Select all
<?php
session_start();
?>
<?php
echo "Php page # 2 session: ".$_SESSION['text'];
?>output
respected all
output of 1.php is ok.
Php Page # 1 session: maani
output of 2.php is
Php page # 2 session:
whats wrong with coding..
kindly guide me ... i would be very thankful to all who give a positive responce..
regards
---------------
maani janjua
output of 1.php is ok.
Php Page # 1 session: maani
output of 2.php is
Php page # 2 session:
whats wrong with coding..
kindly guide me ... i would be very thankful to all who give a positive responce..
regards
---------------
maani janjua
hi as you said in the start, you are new to php.
i think problem might be when you post variable (say abc) to info.php, there you submit some form to move to access.php e.g.
$abc = $_POST['abc'];
<form action="access.php" method="post">
<input type="submit" value="Move to Access File">
</form>
....something like this.
Nothing is wrong with this but the posted variable will be not posted to access.php. What you need to do is pass this variable as hidden field from within the form as...
<form action="access.php" method="post">
<input type="hidden" name="abc" value="<?php echo $abc;?>">
<input type="submit" value="Move to Access File">
</form>
Now it will be available at next page i.e. access.php
If this is the case, above example may solve your problem. If something else just ignore it.
i think problem might be when you post variable (say abc) to info.php, there you submit some form to move to access.php e.g.
$abc = $_POST['abc'];
<form action="access.php" method="post">
<input type="submit" value="Move to Access File">
</form>
....something like this.
Nothing is wrong with this but the posted variable will be not posted to access.php. What you need to do is pass this variable as hidden field from within the form as...
<form action="access.php" method="post">
<input type="hidden" name="abc" value="<?php echo $abc;?>">
<input type="submit" value="Move to Access File">
</form>
Now it will be available at next page i.e. access.php
If this is the case, above example may solve your problem. If something else just ignore it.
Last edited by ocpamit on Fri Jul 13, 2007 7:44 am, edited 1 time in total.
- aceconcepts
- DevNet Resident
- Posts: 1424
- Joined: Mon Feb 06, 2006 11:26 am
- Location: London
If you are passing values from one form to another page i.e. page1(form) to page2 simply set the "SESSION" variable to the "POST" variable in the second page.
Think of it like this:
if you live at 100 London Road England and post a letter to 17 China Town Street Paris where will the letter be received???
Thats right, 17 China Town (providing no delivery hicups occur).
I hope the example helps.
You can set the "ACTION" part of the "FORM" to the same file it was sent from (just like ocpamit suggested) but as you are particulalry new to PHP its probably more straightforward to use additional pages so that the results/methods are clearer.
Think of it like this:
if you live at 100 London Road England and post a letter to 17 China Town Street Paris where will the letter be received???
Thats right, 17 China Town (providing no delivery hicups occur).
I hope the example helps.
You can set the "ACTION" part of the "FORM" to the same file it was sent from (just like ocpamit suggested) but as you are particulalry new to PHP its probably more straightforward to use additional pages so that the results/methods are clearer.
thanks 2 all
Thank you so very much dear mr. ocpamit and mr. Volka
and every body which reply me..
due to hidden variable i have got the solution which i was looking for..
perhaps i will be back soon with new query and i am hopeful that u all will reply me again also...
Take a very good care of urselves.
Thanks once again
Regards
---------------------
maani janjua
and every body which reply me..
due to hidden variable i have got the solution which i was looking for..
perhaps i will be back soon with new query and i am hopeful that u all will reply me again also...
Take a very good care of urselves.
Thanks once again
Regards
---------------------
maani janjua