473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to transfer the variable to next page?

The first page have the pre-define variable. How to transfer to next
php page?
Thanks

May 20 '06 #1
8 5937
Alex Murphy wrote:
The first page have the pre-define variable. How to transfer to next
php page?
Thanks


Hi Alex,

You can do so in different ways.
If you make a link to the next page, you can pass it via the URL:
http://www.mysite.com/nextpage.php?myvar=23

You can also store the variable in a session.
Look up SESSION at www.php.net to get started.
($_SESSION[] is per-user.)

You can also store the variable somewhere on a database or in a file.

What is the best way completely depends on what you are trying to achieve,
but you didn't tell us a lot.

Regards,
Erwin Moller
May 20 '06 #2
Its work...!!

Thanks Erwin

May 21 '06 #3
Erwin Moller wrote:
Alex Murphy wrote:
The first page have the pre-define variable. How to transfer to next
php page?
Thanks


Hi Alex,

You can do so in different ways.
If you make a link to the next page, you can pass it via the URL:
http://www.mysite.com/nextpage.php?myvar=23

You can also store the variable in a session.
Look up SESSION at www.php.net to get started.
($_SESSION[] is per-user.)

You can also store the variable somewhere on a database or in a file.

What is the best way completely depends on what you are trying to
achieve, but you didn't tell us a lot.

Regards,
Erwin Moller


Or if doing a post, you can store it in a hidden input field.
May 21 '06 #4
But... how to post a predefined variable?

May 21 '06 #5
Alex Murphy wrote:
But... how to post a predefined variable?


The first step is to get php to send the predefined value to the web
browser. This may be done using SESSIONs.

session_start();
$_SESSION['predefined'] = $predefined;
session_write_close();
header('Location: first_page.php');

Then, in first_page.php, you get the predefined value back and place it
into a POST value.

session_start();
<form action="second_page.php" method="POST">
<input type="hidden" name="predefined" value="<?php echo
$_SESSION['predefined'];?>">
</form>

Now, the value of 'predefined' is available to second_page.php as a
$_POST value.

$predefined = $_POST['predefined'];

Does this help?

-david-

May 21 '06 #6
Thanks David, it is very useful for me. I never know PHP can do that.
Thanks again.

May 22 '06 #7

Alex Murphy wrote:
The first page have the pre-define variable. How to transfer to next
php page?
Thanks


Use Sessions or write text files in a temporary location. Sessions are
better.

May 23 '06 #8
David Haynes wrote:
Alex Murphy wrote:
But... how to post a predefined variable?


The first step is to get php to send the predefined value to the web
browser. This may be done using SESSIONs.

session_start();
$_SESSION['predefined'] = $predefined;
session_write_close();
header('Location: first_page.php');

Then, in first_page.php, you get the predefined value back and place
it into a POST value.

session_start();
<form action="second_page.php" method="POST">
<input type="hidden" name="predefined" value="<?php echo
$_SESSION['predefined'];?>">
</form>

Now, the value of 'predefined' is available to second_page.php as a
$_POST value.

$predefined = $_POST['predefined'];

Does this help?

-david-

But if he simply wants to carry a value from one page to the next and he is
doing it via a hidden field in a post, does he really need the session?
Jun 13 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: weiwei | last post by:
Hi all I am having trouble, let's say, I have a form text field, and I want to pass it to the next page, however, I don not want to use submitted button, instead I want to have a variable in link...
2
by: Al Cadalzo | last post by:
I am doing a screen-scraping app using HttpWebRequest. I create the HttpWebRequest and then I call the GetResponse() method on it. I get the page back OK. The page has a 'Next' button on it. ...
4
by: meenu_susi | last post by:
i have different colors for shirt... When I click the blue color the shirt color will change to blue color and Near to that shirt I will have a button as design now when I click that button it...
1
by: rich2912 | last post by:
I have a page, with three drop down boxes. Each has four choices linked to a database. Here is what I would like to do: I would like the results of the three choices, to be displayed on the...
14
by: fjm | last post by:
Hi all.. I'm back with another problem that I just can't seem to solve. I have dynamically generated hyperlinks that are created from a while loop in tabular format. Each hyperlink should...
5
by: phanimadhav | last post by:
Response.Redirect("explain.aspx?firstimportname="+filename); This is my statement.In this statement i am sending only single value to next page.but i want to pass multiple values by using multiple...
9
by: shaiful | last post by:
Hi all, I have a problem to transfer variable from one Form to other Form, such as Form1: command_button1() dim a as string a="Hello world!" Form2.show() I want to see the "Hello World!"...
2
by: ravisuguna | last post by:
Hi, I have a php page which has some checkboxes ,textfields and values.If I select a checkbox ,a particular value will be displayed in a textfield.I have a "go"button in the same page.I want the...
4
by: madhumy | last post by:
I am having Arraylist containg list of data, Now I am using a Session variable concept to Pass the Arraylist to next page, Instead I want to use Querystring method, can it be done? I need code help.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.