Posting data via hyperlinks

I want to publish the data ($ _GET, as well as $ _POST) by clicking on the links (attached to <a> ), and not on the usual "send" form. preferred language: PHP

I have seen this in many of today's sites where forms are submitted by clicking on buttons that look like hyperlinks. it was so interesting how this can be done.

Thanks in advance

+6
post php hyperlink
source share
6 answers

This post about Ajaxian may help. He refers to a fairly detailed blog post that shows how to apply CSS to buttons so that they look like links.

The advantage here is to use the correct link - this "fake link" actually has a button, so it behaves exactly like a button, only it looks like a link. Spiders will not follow him, screen readers will treat him differently, this is a more β€œright” thing to do in terms of launching an http message.

+12
source share

Forms are designed to be sent using buttons. You can use JavaScript to send a link, but this will break when JS is unavailable. Even if JavaScript is available, using the link will use a control that will not be displayed when the screen reader is in "form mode", leaving users of the screen reader with no obvious way to submit the form.

CSS is a safer alternative (see http://tom.me.uk/scripting/submit.html ).

+7
source share

You can do something like:

 <a href='myform.php?name=Bob&surname=Terrier'>Click here</a> 

This will send name and surname as GET variables to the form.

Beware of any form that modifies data, as search engines and spiders will follow links where they do not cross the forms.

+2
source share

As you can see from the other answers, you must use JavaScript if you want to send user data from a form with a link. This means that you exclude anyone who has JavaScript disabled, inaccessible, or incompatible with your code. On the other hand, you can try styling the button with CSS to make it look like a link.

+2
source share

Beware of publishing data by clicking on the links! Spiders can follow these links and modify data.

You probably want something like:

 <a href="#" onclick="form.Submit();">submit</a> 
0
source share

You can use Javascript to submit the form.

 <a href='document.myform.submit()'>Submit Button</a> 
0
source share

All Articles