Transfering a variable to the next site
Moderator: General Moderators
Transfering a variable to the next site
Hello !!!
This is my problem. I need to transfer the variable $var, when I click "SUBMIT" in the form, from the index.php site to the submit.php site and I want to access the variable with the $_POST function or with something else.
Any ideas how to do this. It is probably simple, but I don't know it.
Thanks, anyway.
This is my problem. I need to transfer the variable $var, when I click "SUBMIT" in the form, from the index.php site to the submit.php site and I want to access the variable with the $_POST function or with something else.
Any ideas how to do this. It is probably simple, but I don't know it.
Thanks, anyway.
hey
all you have to do is to give whatever your input is a name and then access it through $_POST['name']
like this:
this is your index.php
Now in yout php code you do following to access it
To write out your POST-array to see what it contains do
regards thallish
edit: just edditted the code for index.php. Now it's like it should be
all you have to do is to give whatever your input is a name and then access it through $_POST['name']
like this:
this is your index.php
Code: Select all
<form action="e;submit.php"e; method="e;post"e;>
<input type="e;text"e; name="e;foo"e; />
<input type="e;submit"e; value="e;button"e; />
</form>Code: Select all
$_POST['foo']Code: Select all
print_r($_POST);edit: just edditted the code for index.php. Now it's like it should be
Last edited by thallish on Sat Mar 26, 2005 10:24 am, edited 3 times in total.
I don't know how to explain that... O.K. On index.php in my php code I have specified the variable $var = "blablabla". That variable musn't be "blablabla", it can be anything else. Now, when I click "Submit" in my form (form's action is next.php), I want read the variable in next.php. How can I do it so???
Thanks.
Thanks.
So you want to use your variables internally ?
You can use session variables (http://www.php.net/manual/en/ref.session.php) - but this will ultimately store it in your server's file or database (which ever way you use sessions).
Each script you run will be like a brand new script - whatever variables you want passed accross will either be through GET, POST, media storage (files or database), SESSIONS (ultimately media storage).
When I started coding in PHP I too thought I could store some variables in some location in some global RAM or something.
Web languages will not have the flexibility of C/C++ due to security etc.
But I understand in C# some tweaking like this can be done ?
You can use session variables (http://www.php.net/manual/en/ref.session.php) - but this will ultimately store it in your server's file or database (which ever way you use sessions).
Each script you run will be like a brand new script - whatever variables you want passed accross will either be through GET, POST, media storage (files or database), SESSIONS (ultimately media storage).
When I started coding in PHP I too thought I could store some variables in some location in some global RAM or something.
Web languages will not have the flexibility of C/C++ due to security etc.
But I understand in C# some tweaking like this can be done ?
OK, ok... I don't want to use sessions or something like that. I know it can be done by placing a hidden field in index.php and later I can access the variable by $_POST.
But is this safe??? I uploaded the file on my localhost server, and then I saved index.php on my hard disk. Then I opened the file in Dreamweaver and in the value of input was $var.
But is this safe??? I uploaded the file on my localhost server, and then I saved index.php on my hard disk. Then I opened the file in Dreamweaver and in the value of input was $var.
Oh. Frankly, I dont know what Dreamweaver will do to php code. May be its showing the variable name ?
Check it using any simple text editor (like Context : http://www.context.cx)
Do a echo $_POST['hiddenValue'];
$_POST cannot be considered safe - anybody can change the html code and have the input hidden field change its value. Should be used only for client side interaction.
Check it using any simple text editor (like Context : http://www.context.cx)
Do a echo $_POST['hiddenValue'];
$_POST cannot be considered safe - anybody can change the html code and have the input hidden field change its value. Should be used only for client side interaction.