First off, yes, I understand the crapload of tutorials out there, (well,
rather, I understand there /are/ a crapload of tutorials out there), the
problem is my comprehension.
I'm trying to pass variables, and can do so just fine with a URL, and $_GET.
What I would like to learn, and be very adept at using is the Form functions
and how you pass through that.
The problem in my comprehending this, is how does the original page know how
to post the data to the new page? Or do you create the form on the original
page, and somehow, magically, the new page can read from it?
Can someone break it down into the most basic steps, remembering that i'm a
2-week newbie? :)
Sometimes, all we need is a little one on one attention.
-Thank you,
Humbly,
Khai 7 2761
>I'm trying to pass variables, and can do so just fine with a URL, and $_GET. What I would like to learn, and be very adept at using is the Form functions and how you pass through that.
The problem in my comprehending this, is how does the original page know how to post the data to the new page? Or do you create the form on the original page, and somehow, magically, the new page can read from it?
Yes -- you create the form on the original page and specify where the
form should be submitted. Suppose on page1.php you had something like
this:
<form action="page2.php" method="post">
<input type="text" name="foo"/>
<input type="submit" name="submit" value="Submit"/>
</form>
So when someone fills in this form and hits submit, the browser will
post the form data to page2.php. On page2.php you can access foo and
submit through the $_POST superglobal (in exactly the same way you get
to the GET variables). Also note that there is nothing that prevents
you from putting the current page into the "action" attribute -- that
is, it is perfectly valid (and often quite useful) to have a page with
a form post to itself.
So, can I post variables to another page without user interaction?
Say, I have 3 different pages linked off the primary page, and each link
needs the same or different information for different purposes.
Can I programmatically tell it which vars to pass, without having someone
click on something other than the <a href>?
*starting to understand*
...i think.
-Khai
----- Original Message -----
From: "ZeldorBlat" <ze********@gmail.com>
Newsgroups: comp.lang.php
Sent: Thursday, November 17, 2005 9:30 AM
Subject: Re: Passing Variables I'm trying to pass variables, and can do so just fine with a URL, and
$_GET.What I would like to learn, and be very adept at using is the Form
functionsand how you pass through that.
The problem in my comprehending this, is how does the original page know
howto post the data to the new page? Or do you create the form on the
originalpage, and somehow, magically, the new page can read from it?
Yes -- you create the form on the original page and specify where the form should be submitted. Suppose on page1.php you had something like this:
<form action="page2.php" method="post"> <input type="text" name="foo"/> <input type="submit" name="submit" value="Submit"/> </form>
So when someone fills in this form and hits submit, the browser will post the form data to page2.php. On page2.php you can access foo and submit through the $_POST superglobal (in exactly the same way you get to the GET variables). Also note that there is nothing that prevents you from putting the current page into the "action" attribute -- that is, it is perfectly valid (and often quite useful) to have a page with a form post to itself.
>So, can I post variables to another page without user interaction? Say, I have 3 different pages linked off the primary page, and each link needs the same or different information for different purposes.
Can I programmatically tell it which vars to pass, without having someone click on something other than the <a href>?
How are you going to get the user's browser to go to a different page
without them clicking on something? You just said that the 3 pages are
"linked" off the main page -- I read that as meaning that there are
hyperlinks or forms that post to those pages...
ZeldorBlat said: You just said that the 3 pages are "linked" off the main page -- I read that as meaning that there are hyperlinks or forms that post to those pages...
Yes, that's correct. What I mean to ask is, do I have to use a form button
or something for the action to trigger? Or can I create the hyperlink to
run some function that posts those vars to whichever page I send to the
function?
function postmyvars (strPageName) {
}
or something-ish. I've yet to actually create any user-defined functions..
>Yes, that's correct. What I mean to ask is, do I have to use a form button or something for the action to trigger? Or can I create the hyperlink to run some function that posts those vars to whichever page I send to the function?
PHP operates on the server-side. That is: client makes request,
webserver/PHP process request, webserver sends output to browser. If
you want things to happen on the client-side in between (i.e. redirect
to a different page when the user rolls his mouse over some image) then
you need something like JavaScript.
Khai wrote: ZeldorBlat said:
You just said that the 3 pages are "linked" off the main page -- I read that as meaning that there are hyperlinks or forms that post to those pages...
Yes, that's correct. What I mean to ask is, do I have to use a form button or something for the action to trigger? Or can I create the hyperlink to run some function that posts those vars to whichever page I send to the function?
You can put the variable in a hyper link. http://site.com/mypage.php?cit=cinncinati
In mypage.php , $_GET will be an array with a member named 'city' with a
value of 'cincinatti';
$mycity=$_GET[city];
function postmyvars (strPageName) {
}
or something-ish. I've yet to actually create any user-defined functions..
>From my understanding the variables are passed along from a form depending on the "method" in your HTML code. If you use the "GET" method, the form adds the variable to the URL (e.g. http://www.domain.com/phpscript?var1=1+var2=2 ) and would access them in PHP with the $_GET variables.
Yes.
If the form uses the "POST" method though, the variable are passed along more transparently, so you don't see them on the URL, and can get the using the $_POST variables.
Also true. It's also worth noting that this is no way makes POST more
secure than GET. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Amr Mostafa |
last post by:
Hello :)
I'm trying to write a script that deals with a web service.
I'm using NuSoap class.
my question is : Can I pass some variables By Reference to the web
service and get the result back...
|
by: Jason Us |
last post by:
Does anyone have experience with passing variables from an ASP page to
a JSP page.
The way it currently works in passing the SSN in the URL. This cannot
be good.
I thought that storing a...
|
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: Jack |
last post by:
Hi,
I need to pass multple variables in a link in order to go to a asp page with
the
two varables.
The following are the values of the variables using response.write:
<%'Response.Write Mypage...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: Gregory Piñero |
last post by:
Hey guys, would someone mind giving me a quick rundown of how
references work in Python when passing arguments into functions? The
code below should highlight my specific confusion:
<code>
...
|
by: Scott Zabolotzky |
last post by:
I'm trying to pass a custom object back and forth between forms.
This custom object is pulled into the app using an external reference
to an assembly DLL that was given to me by a co-worker. A...
|
by: Lee |
last post by:
Hi All
How can I pass options from one webpage into another webpage. When the user
clicks on the hyperlink I want them to be go to the next page but I need to
pass in a number that the next...
|
by: Andrew Bullock |
last post by:
Hi,
I have two classes, A and B,
B takes an A as an argument in its constructor:
A a1 = new A();
B b = new B(a1);
|
by: BezerkRogue |
last post by:
This is the most fundamental action I am sure, but I can't seem to make it happen.
I am familiar with passing variables in ASP. But that doesn't seem to be the preferred method in .NET. I have...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |