Session And Cookies
Moderator: General Moderators
Session And Cookies
Hi
I am New to this form.
kindly help me in regarding the topic session variable and cookies.
How to Use the session variable and use them in multiple Forms.
Explain By giving some Example.
Ujjwal
I am New to this form.
kindly help me in regarding the topic session variable and cookies.
How to Use the session variable and use them in multiple Forms.
Explain By giving some Example.
Ujjwal
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
your best bet would be to hit up the manual or search this forum for information on sessions.
here's a good place to start: session_start().
with your session started, you can create session variables in the $_SESSION[] array and use them wherever you have the session information included on your site.
here's a good place to start: session_start().
with your session started, you can create session variables in the $_SESSION[] array and use them wherever you have the session information included on your site.
Error In session
When i write the given code
It will run properly and Show the Result in the Second Page The Code of which is given below
The Output of the Second Page Contain the Button Which is Directed to the third and the final page And the Result is not Shown there
The Code of the Third Page is Shown below
d11 |
Code: Select all
<html>
<head>
<title>
</title>
</head>
<body>
<form action="e;process12.php"e; method="e;post"e;>
<table border=2>
<tr><td>
Enter the Number 1</td><td><input type="e;text"e; name="e;t1"e;></td></tr>
<tr><td>
Enter the Number 2</td><td><input type="e;text"e; name="e;t2"e;></td></tr>
<tr rowspan=2><td><input type="e;submit"e; name="e;submit"e; value="e;Click Me"e;></td></tr>
</table>
</form>
</body>
</html>Code: Select all
<html>
<head>
<title></title>
</head>
<body>
<form action="e;result.php"e; method="e;post"e;>
<?php
echo "e;You Entered the Following Information <br>"e;;
echo "e;First Number="e;,$_POSTї"e;t1"e;],"e;<br>"e;;
echo "e;Second Number="e;,$_POSTї"e;t2"e;],"e;<br>"e;;
echo "e;Hit the button if the information is correct otherwise click the Back text<br>"e;;
?>
<table><tr><td>
<input type="e;Submit"e; name="e;SS"e; Value ="e;Hit me"e;></td><td><a
href="e;http://192.168.0.111/uj/table1.php"e;>Back and Enter new Nos</a>
</td></tr>
</table>
</form>
</body>
</html>The Code of the Third Page is Shown below
Code: Select all
<html>
<head>
<title>
Result
</title>
</head>
<body>
<?php
echo "e;<b> First Number</b>="e;, $HTTP_POST_VARSї't1'];
echo "e;<br>"e;;
echo "e;<b> Second Number</b>="e;,$HTTP_POST_VARSї't2'];
echo "e;<br>"e;;
$tt=$HTTP_POST_VARSї't1']+$HTTP_POST_VARSї't2'];
echo "e;The Sum of Two Numbers="e;,$tt;
?>
<a href="e;http://192.168.0.111/uj/table1.php"e;>New Query</a>
</body>
</html>Code: Select all
tags please [/color]Re: Error In session
Code: Select all
<?php
session_start();
?>
<html>
<head>
<title></title>
</head>
<body>
<form action="e;result.php"e; method="e;post"e;>
<?php
echo "e;You Entered the Following Information <br>"e;;
echo "e;First Number="e;,$_POSTї"e;t1"e;],"e;<br>"e;;
echo "e;Second Number="e;,$_POSTї"e;t2"e;],"e;<br>"e;;
$_SESSIONї"e;t1"e;]=$_POSTї"e;t1"e;];
$_SESSIONї"e;t2"e;]=$_POSTї"e;t2"e;];
echo "e;Hit the button if the information is correct otherwise click the Back text<br>"e;;
?>
<table><tr><td>
<input type="e;Submit"e; name="e;SS"e; Value ="e;Hit me"e;></td><td><a
href="e;http://192.168.0.111/uj/table1.php"e;>Back and Enter new Nos</a>
</td></tr>
</table>
</form>
</body>
</html>Code: Select all
<?php
session_start();
?>
<html>
<head>
<title>
Result
</title>
</head>
<body>
<?php
echo "e;<b> First Number</b>="e;, $_SESSIONї't1'];
echo "e;<br>"e;;
echo "e;<b> Second Number</b>="e;,$_SESSIONї't2'];
echo "e;<br>"e;;
$tt=$_SESSIONї't1']+$_SESSIONї't2'];
echo "e;The Sum of Two Numbers="e;,$tt;
?>
<a href="e;http://192.168.0.111/uj/table1.php"e;>New Query</a>
</body>
</html>Dos'nt Work
edit patrikG: use
Code: Select all
-tags when posting code[/b][/color]
After Writing the Code in the final page.
[syntax=php]<?php
session_start();
?>
<html>
<head>
<title>
Result
</title>
</head>
<body>
<?php
echo "<b> First Number</b>=",$_Session['t1'];
echo "<br>";
echo "<b> Second Number</b>=",$_Session['t2'];
echo "<br>";
$tt=$_Session['t1']+$_Session['t2'];
echo "The Sum of Two Numbers=",$tt;
?>
<a href="http://192.168.0.111/uj/table1.php">New Query</a>
</body>
</html>[/syntax]
[b]It Shows The Following Error[/b]
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at d:\htdocs\uj\result.php:2) in d:\htdocs\uj\result.php on line 3
First Number=
Second Number=
The Sum of Two Numbers=0 New Query
[color=red][b]edit patrikG: use [syntax=php]-tags when posting code[/b][/color][/syntax]regarding your error, see nielsene's post and read viewtopic.php?t=1157
Simple Problem
I have only simple Problem
That there are Two text boxes in form 1 with 1 button
the value of the Text boxes will be displayed on the Second Page when i click on the Button.
But these value will not be Printed on the Thirds Page.
That's the problem please see the Code in the above post I already Used the Session variable and Cookies.
That there are Two text boxes in form 1 with 1 button
the value of the Text boxes will be displayed on the Second Page when i click on the Button.
But these value will not be Printed on the Thirds Page.
That's the problem please see the Code in the above post I already Used the Session variable and Cookies.
Session Variable
It Works
thanks nielsene
thanks nielsene