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!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi i am quite new to php and would like to get some help. My problem is that i want to get a value from a textbox in the same php form and pass it to another page. For example i have this:
so essentially i want to create a variable and assign the value in the textbox to it and pass it to a new page. I have tried $_GET, $_POST and $_REQUEST and all of them dont work. Can someone please help me?
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Is there another way besides using sessions? It seems like a simple task, which i htink should be something like $var = textbox.value or something like that, but in php it seems so complicated
Call session_start at the beginning of every page that utilizes the session, and save the session variables in the $_SESSION array. They will last until the user closes the browser (or waits about 30 minutes doing nothing).
xrez wrote:So how do i do it without the use of sessions?
You simply need a normal link.
Take this very thread's link: viewtopic.php?t=69421 .. you're doing, pretty much, the exact same thing in Javascript. You just need to shift it from Javascript to a standard link.
if [s]u[/s] you have an html form then in action give like this action = <? $_SERVER["PHP_SELF"] ?>
then [s]u[/s] you can get the varible valuse with in the php ,
pass the variable value in hidden to next page.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:11. Please use proper, complete spelling when posting in the forums. AOL Speak, leet speak and other abbreviated wording can confuse those that are trying to help you (or those that you are trying to help). Please keep in mind that there are many people from many countries that use our forums to read, post and learn. They do not always speak English as well as some of us, nor do they know these aberrant abbreviations. Therefore, use as few abbreviations as possible, especially when using such simple words.
Some examples of what not to do are ne1, any1 (anyone); u (you); ur (your or you're); 2 (to too); prolly (probably); afaik (as far as I know); etc.
if(!empty($_SESSION['someValue']))
{
echo '<textarea name="whatever">' . $_SESSION['someValue'] . '</textarea>';
}
else
{
// Redirect them back to a page or show a default version or something
}