Skip to main content
Known Participant
November 29, 2007
Answered

PHP help for a Novice please

  • November 29, 2007
  • 6 replies
  • 846 views
Hi,

I am learning php, because I am working on a site that uses it, so, there is some syntax which I don't understand its function, so I thought if I post it here somebody may be able to tell me what it would do.....

A page has a form on it, the form begins with this
<?php $ref = $_GET['ref'];

then has the form tag with action="details_process.php?ref='.$ref.

now, the bit i'm not understanding what it does is the $ref = $_GET['ref']; and the ref='.$ref. at the end of the for action.

I appreciate this is taken out of the page so may make no sense, but if it is a standard function could somebody please tell me what it is?

Many many thanks in advance

that form action is set to go to a process.php page
This topic has been closed for replies.
Correct answer Newsgroup_User
Well, the PHP function $_GET parses the URL for any variables, and is a
different entity entirely from the form method of "GET".

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"simbull" <webforumsuser@macromedia.com> wrote in message
news:fimnr2$j2h$1@forums.macromedia.com...
> Thanks Murray
>
> So $_GET['ref'] has no relevance to GET/POST or getting data from
> the form or anything, it's literally just a string of code php uses to do
> what you say it does

6 replies

Inspiring
November 29, 2007
.oO(Gary White)

>> http://www.example.com/details_process.php?ref=whatever
>
>If the form's action attribute includes the parameter, the form's method
>should be GET if you want to pass that. It would actually be more
>correct to write the value to a hidden field instead of appending the
>parameter to the form's action uri, then it wouldn't matter which method
>was used:

><form action=" http://www.example.com/details_process.php"
>method="whatever">
><input type="hidden" name="ref" value="<?php echo $_GET['ref'];?>

I disagree. The form's action attribute is a URL, and a URL might
contain a query string. This is completely independent from the form
itself. In some cases there are reasons to use both, POST and GET.

Micha
Known Participant
November 30, 2007
Well you all lost me ages ago! :)
Inspiring
November 29, 2007
> If the form's action attribute includes the parameter, the form's method
> should be GET if you want to pass that.

No kidding? Hmmm - I do it that way often and it seems to work fine.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Gary White" <reply@newsgroup.please> wrote in message
news:r3fuk3diiphbourimcpa66mqif7nk0sd8u@4ax.com...
> On Thu, 29 Nov 2007 11:59:12 -0500, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>> It might also be worth noting that the form's method must be "get", not
>>> "post" for this to all work correctly.
>>
>>Not in the context of my reply, though. Based on the original post (which
>>is not completely clear), the form page LOADS with the $_GET, so I assumed
>>that a variable was being passed to it, which was then relayed to the
>>processing page. I didn't think of the alternate interpretation that you
>>mention.
>
> Well, here's what you wrote:
>
>>The form's action would create a URL like this -
>>
>> http://www.example.com/details_process.php?ref=whatever
>
> If the form's action attribute includes the parameter, the form's method
> should be GET if you want to pass that. It would actually be more
> correct to write the value to a hidden field instead of appending the
> parameter to the form's action uri, then it wouldn't matter which method
> was used:
>
> <form action=" http://www.example.com/details_process.php"
> method="whatever">
> <input type="hidden" name="ref" value="<?php echo $_GET['ref'];?>
>
> Gary

Inspiring
November 29, 2007
On Thu, 29 Nov 2007 11:59:12 -0500, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>> It might also be worth noting that the form's method must be "get", not
>> "post" for this to all work correctly.
>
>Not in the context of my reply, though. Based on the original post (which
>is not completely clear), the form page LOADS with the $_GET, so I assumed
>that a variable was being passed to it, which was then relayed to the
>processing page. I didn't think of the alternate interpretation that you
>mention.

Well, here's what you wrote:

>The form's action would create a URL like this -
>
> http://www.example.com/details_process.php?ref=whatever

If the form's action attribute includes the parameter, the form's method
should be GET if you want to pass that. It would actually be more
correct to write the value to a hidden field instead of appending the
parameter to the form's action uri, then it wouldn't matter which method
was used:

<form action=" http://www.example.com/details_process.php"
method="whatever">
<input type="hidden" name="ref" value="<?php echo $_GET['ref'];?>

Gary
Inspiring
November 29, 2007
> It might also be worth noting that the form's method must be "get", not
> "post" for this to all work correctly.

Not in the context of my reply, though. Based on the original post (which
is not completely clear), the form page LOADS with the $_GET, so I assumed
that a variable was being passed to it, which was then relayed to the
processing page. I didn't think of the alternate interpretation that you
mention.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"Gary White" <reply@newsgroup.please> wrote in message
news:m7qtk3dbo771mr5t2u56qj1985jfsqnqru@4ax.com...
> On Thu, 29 Nov 2007 10:27:37 -0500, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>That's just a way of passing a variable to a page. Let's assume that the
>>form page is loaded using a URL like this -
>>
>> http://www.example.com/yourformpage.php?ref=whatever
>>
>>When the form page loads, it parses the ref variable from the link, so now
>>$ref has the value "whatever".
>
> Just in case someone were to read this message out of context, it might
> be more correct to say that $_GET['ref'] contains the value "whatever"
> and that the code $ref=$_GET['ref'] copies that into the $ref variable.
>
>
>>so that when the form is processed by details_process.php, that process
>>page
>>can act according to the value of the $ref variable, carried through from
>>the page calling the form, to the form, then to the page processing the
>>form.
>
> It might also be worth noting that the form's method must be "get", not
> "post" for this to all work correctly.
>
> Gary

Inspiring
November 29, 2007
On Thu, 29 Nov 2007 10:27:37 -0500, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>That's just a way of passing a variable to a page. Let's assume that the
>form page is loaded using a URL like this -
>
> http://www.example.com/yourformpage.php?ref=whatever
>
>When the form page loads, it parses the ref variable from the link, so now
>$ref has the value "whatever".

Just in case someone were to read this message out of context, it might
be more correct to say that $_GET['ref'] contains the value "whatever"
and that the code $ref=$_GET['ref'] copies that into the $ref variable.


>so that when the form is processed by details_process.php, that process page
>can act according to the value of the $ref variable, carried through from
>the page calling the form, to the form, then to the page processing the
>form.

It might also be worth noting that the form's method must be "get", not
"post" for this to all work correctly.

Gary
Inspiring
November 29, 2007
That's just a way of passing a variable to a page. Let's assume that the
form page is loaded using a URL like this -

http://www.example.com/yourformpage.php?ref=whatever

When the form page loads, it parses the ref variable from the link, so now
$ref has the value "whatever".

The form's action would create a URL like this -

http://www.example.com/details_process.php?ref=whatever

so that when the form is processed by details_process.php, that process page
can act according to the value of the $ref variable, carried through from
the page calling the form, to the form, then to the page processing the
form.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
==================


"simbull" <webforumsuser@macromedia.com> wrote in message
news:fimjjr$eep$1@forums.macromedia.com...
> Hi,
>
> I am learning php, because I am working on a site that uses it, so, there
> is
> some syntax which I don't understand its function, so I thought if I post
> it
> here somebody may be able to tell me what it would do.....
>
> A page has a form on it, the form begins with this
> <?php $ref = $_GET['ref'];
>
> then has the form tag with action="details_process.php?ref='.$ref.
>
> now, the bit i'm not understanding what it does is the $ref =
> $_GET['ref'];
> and the ref='.$ref. at the end of the for action.
>
> I appreciate this is taken out of the page so may make no sense, but if it
> is
> a standard function could somebody please tell me what it is?
>
> Many many thanks in advance
>
> that form action is set to go to a process.php page
>

Known Participant
November 29, 2007
Thanks Murray

So $_GET['ref'] has no relevance to GET/POST or getting data from the form or anything, it's literally just a string of code php uses to do what you say it does