944,193 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 47263
  • PHP RSS
Sep 15th, 2005
0

HYPERLINK with PHP POST

Expand Post »
Hello all

what i am really trying to do is to use POST method to send info to next page with just HYPERLINK; Here is what i want:

Get method:
PHP Syntax (Toggle Plain Text)
  1. <a href="http://www.someting.com?date=9/15/05&age=21">age and time</a>
I want this to be in POST method without using forms.
also i am making this in php so is there a way to do this on click instead of using fourms because i really dont want to use those boxs with submit in them to submit the info.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

I think you have some confusion about a normal url, a get form and and post form

a url such as index.php?page=whatever simulates the results of this get form
PHP Syntax (Toggle Plain Text)
  1. <form action='index.php' method='get'>
  2. <input type='text' name='page' value='whatever' />
  3. <input type='submit'>
  4. </form>

If the method was post you wouldn't see the variables on the page (exception in the exception where the action is 'index.php?page=whatever' but that's not recommended).

The intention of post forms is twofold
  1. to allow large amounts of data to be submitted, exceeding the 256 char limit on a url
  2. to prevent the user from saving the form data as a bookmark and running again later. This is appropriate in a great many cases
If you can help us to understand the problem you are trying to resolve we may be able to help you. Is this your site you are working with, or are you trying to submit to another site from your site?

Sarah
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

ok mainly what i want to do is to use the POST method without using forms only because i dont what the HTML button box there:

[HTML]
<input type='text' name='page' value='whatever' />
[/HTML]
I just want to use a plain link or an image instead that input box.
I can use forms but i just dont want to use the input boxes to submit info.
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

I guess you could create a form that uses POST and has no visible elements (use hidden inputs). A hyperlink could then use javascript to submit the form. It's not extremely compatible with older browsers, but it could work if you absolutely had to have it work that way.
Reputation Points: 38
Solved Threads: 25
Posting Shark
chrisbliss18 is offline Offline
902 posts
since Aug 2005
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

Here's an example from Chris' suggestion

PHP Syntax (Toggle Plain Text)
  1. <html>
  2. <head>
  3. <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
  4. <title>Submit Form example from sarahk.pcpropertymanager.com/blog/submit-form-using-javascript/192/</title>
  5. <script>function submitMe()
  6. {
  7. alert('In submitMe()');
  8. document.submitForm.submit();
  9. return;
  10. }
  11. </script>
  12. </head>
  13.  
  14. <body bgcolor="#ffffff">
  15. <form name="submitForm" action="selfsubmit.html" method="post">
  16. <input type="hidden" value="page" name="whatever">
  17. <a href="javascript:document.submitForm.submit()">submit direct</a><br>
  18. <a href="javascript:submitMe()">submit via a function</a><br>
  19. <input type="image" src="https://scgi.ebay.com/saw/pics/sitewide/processBar1_16x16.gif">
  20. </form>
  21. </body>
  22. </html>
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

So, in fact you DO want to POST a FORM, you just don't want an "ugly button". Right? Then either style the button using CSS, or code almost any other HTML element, such as a hyperlink, to fire the form's "submit()" method.

(You might have had more answers, sooner, if you'd posted in the HTML/JavaScript forum rather than PHP.)
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

Can any one give me a good example of the submit() as the one above have a lot of stuff in it an comfusing.
Reputation Points: 10
Solved Threads: 1
Junior Poster
ashneet is offline Offline
147 posts
since Jun 2005
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

It's very simple. If you have a single form on the page, then this hyperlink would submit it:

PHP Syntax (Toggle Plain Text)
  1. <a href="#" onclick="document.forms[0].submit();">Submit form</a>

There are a couple of variations. I prefer to refer to all HTML elements via their ID property. So if you give your form an ID, like:

PHP Syntax (Toggle Plain Text)
  1. <form id="myForm" method="post" action="myFormProcessor.php">

then your hyperlink could be:


PHP Syntax (Toggle Plain Text)
  1. <a href="#" onclick="document.getElementById('myForm').submit();">Submit form</a>

Lastly, if you don't like having that href, you can also code it:


PHP Syntax (Toggle Plain Text)
  1. <a href="javascript:document.forms[0].submit();">Submit form</a>
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Sep 16th, 2005
0

Re: HYPERLINK with PHP POST

i hope u are looking for this script.
<a href=details.php?id=<?echo $id?>&city=<?echo $city?>&state=<?echo $state?>>click here</a>
u will go to details.php and get all the i nformation of that particular id.
and without using forms and submit button u will go to details .php
i have used state city ext u change the variables.
Reputation Points: 11
Solved Threads: 0
Junior Poster
aarya is offline Offline
139 posts
since Sep 2005

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: How to display TIFF file on web page?
Next Thread in PHP Forum Timeline: numbering the pages





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC