473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Knowing the form action

Hi!

Is there a way to know if the page is:
- directly called from the browser
- called by the submit button pressed in POST mode
- called by the submit button pressed in GET mode

?

Thanks
Aug 21 '07 #1
6 2800
If you had a button like

<input type=button name=btn value=" OK ">

You could check:

if (isset($_POST['btn'])) {
echo 'Button post.';
} elseif (isset($_GET['btn'])) {
echo 'Button get.';
} else {
echo 'Page view.';
}

On Aug 21, 3:16 am, "Fabio" <znt.fa...@virgilio.itwrote:
Hi!

Is there a way to know if the page is:
- directly called from the browser
- called by the submit button pressed in POST mode
- called by the submit button pressed in GET mode

?

Thanks

Aug 21 '07 #2
"petersprc" <pe*******@gmail.comha scritto nel messaggio
news:11*********************@q3g2000prf.googlegrou ps.com...
if (isset($_POST['btn'])) {
echo 'Button post.';
} elseif (isset($_GET['btn'])) {
echo 'Button get.';
} else {
echo 'Page view.';
}
mmm... I'm doing something like

if (count($_POST)0) {
echo 'Button post.';
} elseif (count($_GET)0) {
echo 'Button get.';
} else {
echo 'Page view.';
}

but if I visit

http://www.mysite.com/?submitted=false

I get "Button get." also if I didn't pressed nothing :(

Aug 21 '07 #3
rf

"Fabio" <zn*******@virgilio.itwrote in message
news:46***********************@reader1.news.tin.it ...
"petersprc" <pe*******@gmail.comha scritto nel messaggio
news:11*********************@q3g2000prf.googlegrou ps.com...
>if (isset($_POST['btn'])) {
echo 'Button post.';
} elseif (isset($_GET['btn'])) {
echo 'Button get.';
} else {
echo 'Page view.';
}

mmm... I'm doing something like

if (count($_POST)0) {
echo 'Button post.';
} elseif (count($_GET)0) {
echo 'Button get.';
} else {
echo 'Page view.';
}

but if I visit

http://www.mysite.com/?submitted=false

I get "Button get." also if I didn't pressed nothing :(
Because that is how get data is sent to the server. Sever side you simply
can not tell. Why do you need to?

--
Richard.
Aug 21 '07 #4
$_SERVER['REQUEST_METHOD']

Contains which method you used to access the page

Aug 21 '07 #5
On 21 Aug, 10:07, "Fabio" <znt.fa...@virgilio.itwrote:
"petersprc" <peters...@gmail.comha scritto nel messaggionews:11*********************@q3g2000prf.g ooglegroups.com...
if (isset($_POST['btn'])) {
echo 'Button post.';
} elseif (isset($_GET['btn'])) {
echo 'Button get.';
} else {
echo 'Page view.';
}

mmm... I'm doing something like

if (count($_POST)0) {
echo 'Button post.';} elseif (count($_GET)0) {

echo 'Button get.';} else {

echo 'Page view.';

}

but if I visit

http://www.mysite.com/?submitted=false

I get "Button get." also if I didn't pressed nothing :(
elseif (count($_GET)0) {
echo 'Button get.';}

if you access the url http://www.mysite.com/?submitted=false, then you
have something in your $_GET variable, that's why it displays button
get ^^

Aug 21 '07 #6
NC
On Aug 21, 12:16 am, "Fabio" <znt.fa...@virgilio.itwrote:
>
Is there a way to know if the page is:
- directly called from the browser
Directly meaning by typing the URL into the browser's address bar?
Yes, but it's not 100% reliable; $_SERVER['HTTP_REFERER'] should be
empty.
- called by the submit button pressed in POST mode
- called by the submit button pressed in GET mode
You can use $_SERVER['REQUEST_METHOD'], but you would do well to
remember that almost anything a browser does to access content can be
emulated by other programs.

Cheers,
NC

Aug 21 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
6
by: tencip | last post by:
Hi everyone, So, i've got a form that is very simple. It hold three elements: username, password, and domain. The goal here is to have the form submit the login to an administrative section...
2
by: Myk Quayce | last post by:
I have a small .aspx page that uses old style forms with client-side JavaScript validation. Everything works fine until I try to upate the database with some new information. I must be doing...
4
by: Lee Chapman | last post by:
Hi, Can anyone tell me why in the code below, the call to ClearChildViewState() has no effect? To paraphrase the code: I'm using view state. I have a textbox and a submit button (and a label...
4
by: mflll | last post by:
I am looking into the different techniques of handling arrays of edit boxes in Java Script. The first program below works fine. However, are there better ways of doing this, where the person...
13
by: deko | last post by:
I have a basic feedback form with a submit button. After the "send" button is clicked, I want the user to be redirected to a different page that says "Your message has been sent." How do I do...
16
by: whyyyy | last post by:
The script below works fine if the form is filled out and submitted. But a (blank) e-mail is sent whenever the page loads, even when the form is not submitted. I would like to receive the e-mail...
6
by: Arthur | last post by:
Hello. How might it be possible to change where a form action is directed based on a selected option. For example I have this: <FORM METHOD = "post" ACTION = ""> And a drop down such as
12
by: Daniel Klein | last post by:
I'm pretty new at php and web stuff so please be gentle with me. I'm trying to get a form to submit when the user presses the Enter key. I do not want to use javascript. I've googled this to...
1
by: chromis | last post by:
Hi, I'm having trouble fully implementing the edit section of a contact admin system, so far I have written the following: - Bean (Contact.cfc) - Data Access object (ContactDAO.cfc) - Gateway...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
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...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.