deotpit
September 28, 2018, 3:05pm
1
Hi everyone,
My php code is consisted of 2 buttons as follows:
<!DOCTYPE HTML>
<html>
<body>
<button type="submit" onclick="myPHP.php/'1'">Click Me!</button>
<button type="submit" onclick="myPHP.php/'2'">Click Me!</button>
</body>
</html>
When user clicks left button I want the script to run “myPHP.php” with ‘1’ as a parameter, with
right button clicked I want “myPHP.php” to run with parameter ‘2’.
Is it possible to do?
Could anyone kindly explain me how?
Thanks
deotpit:
Is it possible to do?
Yes, if you familiarise with the syntax of URLs:
A Uniform Resource Locator (URL), colloquially termed a web address, is a reference to a web resource that specifies its location on a computer network and a mechanism for retrieving it. A URL is a specific type of Uniform Resource Identifier (URI), although many people use the two terms interchangeably.[a] URLs occur most commonly to reference web pages (HTTP/HTTPS) but are also used for file transfer (FTP), email (mailto), database access (JDBC), and many other applications.
Most web brows...
Gandalf
September 28, 2018, 3:27pm
3
The format for a (relative) url with a parameter is something like
myfile.php?param=1
which passes a parameter named param
with a value of 1
.
1 Like
rpkamp
September 28, 2018, 3:37pm
4
Yes, using query strings is the easiest approach.
For gandalf’s example you can use $_GET['param']
to get the value.
1 Like
system
Closed
December 28, 2018, 11:45pm
6
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.