Hi all
I have been using PHP in combination with forms to do all sorts of things, and now I am in a situation where I wonder why is the form necessary at all.
Could I acheive the same with simple <a href="*"> links?
For example I made a simple content management interface where all editable pages are listed, and I placed a radio button next to each page name so that the user can choose the page by selecting the radio button, and then click on a submit button to go to the editor for the page...
Could I do just the same but by just clicking on the page name, which would be a link with a PHP action attached?
In other words, could I use any html links and attach to them PHP actions just as if these links were forms elements?
Like:
<a href="onClick='<?php do this; ?>'">myLink</a>
Thanks for any suggestions
acheive the same as a form would, without the form
Moderator: General Moderators
-
sebnewyork
- Forum Commoner
- Posts: 43
- Joined: Wed Mar 17, 2004 10:20 pm
-
sebnewyork
- Forum Commoner
- Posts: 43
- Joined: Wed Mar 17, 2004 10:20 pm
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Code: Select all
<a href="foo.php?name=value">foo</a>Code: Select all
echo $_GET['name'];-
sebnewyork
- Forum Commoner
- Posts: 43
- Joined: Wed Mar 17, 2004 10:20 pm
thanks.
I'm not sure I understand how this would work with a concrete example. I need one more push, please.
How would I do if I want some php function to run if the link is clicked on?
(sorry I don't understand code if code elements are default names, could you give me any example where
"name" would be something concrete, "value" would be something concrete, etc?... My brain can't grasp abstraction)
say, if the link is clicked, pass a session variable called $bla, and go to a page called "newPage.htm".
Sorry for my lack of intuition
I'm not sure I understand how this would work with a concrete example. I need one more push, please.
How would I do if I want some php function to run if the link is clicked on?
(sorry I don't understand code if code elements are default names, could you give me any example where
"name" would be something concrete, "value" would be something concrete, etc?... My brain can't grasp abstraction)
say, if the link is clicked, pass a session variable called $bla, and go to a page called "newPage.htm".
Sorry for my lack of intuition
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
typically, you don't get session variables to pass, as they are already available to the called script... so a basic example...
Code: Select all
<a href="foo.php?concrete=toys">foo</a>Code: Select all
if( isset($_GETї'concrete']) )
{
switch($_GETї'concrete'])
{
case 'toys':
header('Location: newPage.htm');
break;
default:
# something else...
}
}-
sebnewyork
- Forum Commoner
- Posts: 43
- Joined: Wed Mar 17, 2004 10:20 pm