Without using Javascript, can you pass value of textbox?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Gerard_P
Forum Newbie
Posts: 6
Joined: Thu May 01, 2003 6:44 am

Without using Javascript, can you pass value of textbox?

Post by Gerard_P »

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.
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Yes you can use sessions to share information between pages - could you show us how far you have got with coding this as we will then be able to help you better.

Mac
Gerard_P
Forum Newbie
Posts: 6
Joined: Thu May 01, 2003 6:44 am

used session and it seems working.

Post by Gerard_P »

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.
Post Reply