Hello everyone. I am new with PHP. I would like to ask if it is possible to pass the values placed in a textbox to another php page without using Javascript.
What i do until now is use Javascript to send the values to a new php page.
Can it be placed in a session? And if it is possible, can you write some code so that i can understand how it is done.
Thanks.
Without using Javascript, can you pass value of textbox?
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
used session and it seems working.
Mac, thanks for the advice.I tried to use session and it looks as if it works fine. I created 3 test files. The fist posts the entered values in the text box. The second receives the values and puts it into session. And the third gets the data from the session.
it looks somewhat like this.
test001.php
<?php
session_start();
print<<<EOF
<form method="post" action="test002.php">
<table>
<input type=text name=dbname><br>
</table>
<input type=submit value="send">
<form>
EOF;
?>
----------------------
test002.php
<?php
session_start();
$dbname = $_POST[dbname];
echo $dbname."<br>";
$_SESSION["value1"]=$dbname;
?>
<input type="button" name="button" onclick=location.href="test003.php">
-----------------------
test003.php
<?php
session_start();
<---unset, second position
$value1 = $_SESSION["value1"];
echo $value1."<br>";
<---unset, first position
?>
-----------------------
However, i have a question with regards to unset().
I created a fourth file (test004.php), written below.
test004.php
<?php
session_start();
$value1 = $_SESSION["value1"];
echo $value1."<br>";
?>
And inserted unset($_SESSION["value1"]) in the third file. At first, I inserted it after echo (see test003 above), and when i changed to the fourth file the session's variable is still set. However, when i inserted it after session_start() and changed to the fourth file the session's variable was unset.
Why was the first position ineffective?
Thanks in advance.
it looks somewhat like this.
test001.php
<?php
session_start();
print<<<EOF
<form method="post" action="test002.php">
<table>
<input type=text name=dbname><br>
</table>
<input type=submit value="send">
<form>
EOF;
?>
----------------------
test002.php
<?php
session_start();
$dbname = $_POST[dbname];
echo $dbname."<br>";
$_SESSION["value1"]=$dbname;
?>
<input type="button" name="button" onclick=location.href="test003.php">
-----------------------
test003.php
<?php
session_start();
<---unset, second position
$value1 = $_SESSION["value1"];
echo $value1."<br>";
<---unset, first position
?>
-----------------------
However, i have a question with regards to unset().
I created a fourth file (test004.php), written below.
test004.php
<?php
session_start();
$value1 = $_SESSION["value1"];
echo $value1."<br>";
?>
And inserted unset($_SESSION["value1"]) in the third file. At first, I inserted it after echo (see test003 above), and when i changed to the fourth file the session's variable is still set. However, when i inserted it after session_start() and changed to the fourth file the session's variable was unset.
Why was the first position ineffective?
Thanks in advance.