User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 401,693 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,724 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 17366 | Replies: 8 | Solved
Reply
Join Date: Jun 2005
Location: USA
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

HYPERLINK with PHP POST

  #1  
Sep 15th, 2005
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:
<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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation: sarahk is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: HYPERLINK with PHP POST

  #2  
Sep 16th, 2005
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
<form action='index.php' method='get'>
<input type='text' name='page' value='whatever' />
<input type='submit'>
</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
Reply With Quote  
Join Date: Jun 2005
Location: USA
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Re: HYPERLINK with PHP POST

  #3  
Sep 16th, 2005
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.
Reply With Quote  
Join Date: Aug 2005
Location: Oklahoma
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 21
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: HYPERLINK with PHP POST

  #4  
Sep 16th, 2005
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.
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Reply With Quote  
Join Date: Apr 2005
Location: Auckland, New Zealand
Posts: 136
Reputation: sarahk is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: HYPERLINK with PHP POST

  #5  
Sep 16th, 2005
Here's an example from Chris' suggestion

<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
		<title>Submit Form example from sarahk.pcpropertymanager.com/blog/submit-form-using-javascript/192/</title>
		<script>function submitMe()
{
alert('In submitMe()');
document.submitForm.submit();
return;
}
	</script>
	</head>

	<body bgcolor="#ffffff">
		<form name="submitForm" action="selfsubmit.html" method="post">
			<input type="hidden" value="page" name="whatever"> 
			 <a href="javascript:document.submitForm.submit()">submit direct</a><br>
			 <a href="javascript:submitMe()">submit via a function</a><br>
		     <input type="image" src="https://scgi.ebay.com/saw/pics/sitewide/processBar1_16x16.gif">
		</form>
	</body>
</html>
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: HYPERLINK with PHP POST

  #6  
Sep 16th, 2005
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.)
Reply With Quote  
Join Date: Jun 2005
Location: USA
Posts: 147
Reputation: ashneet is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
ashneet's Avatar
ashneet ashneet is offline Offline
Junior Poster

Solution Re: HYPERLINK with PHP POST

  #7  
Sep 16th, 2005
Can any one give me a good example of the submit() as the one above have a lot of stuff in it an comfusing.
Reply With Quote  
Join Date: Dec 2004
Posts: 1,590
Reputation: tgreer is an unknown quantity at this point 
Rep Power: 7
Solved Threads: 34
Colleague
tgreer tgreer is offline Offline
Made Her Cry

Re: HYPERLINK with PHP POST

  #8  
Sep 16th, 2005
It's very simple. If you have a single form on the page, then this hyperlink would submit it:

<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:

<form id="myForm" method="post" action="myFormProcessor.php">

then your hyperlink could be:


<a href="#" onclick="document.getElementById('myForm').submit();">Submit form</a>

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


<a href="javascript:document.forms[0].submit();">Submit form</a>
Reply With Quote  
Join Date: Sep 2005
Posts: 139
Reputation: aarya is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
aarya's Avatar
aarya aarya is offline Offline
Junior Poster

Re: HYPERLINK with PHP POST

  #9  
Sep 16th, 2005
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 8:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC