Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using POST without user submit?

Status
Not open for further replies.

KempCGDR

Programmer
Joined
Jan 10, 2003
Messages
445
Location
GB
I have two pages and I need to pass values from one to the other, preferably via a form and POST because:

1) The user shouldn't be able to change them, and they could if I included them on the address.

2) It needs to be automatic, and it kinda defeats the object if the user has to click a submit button.

Is there a way to automatically submit a form? I can easily put one together with hidden fields, I just can't submit it.
 
Does the user control the action to go to the next page via a link or something? If so, you can use that link to submit the form using javascript if you don't want a button:

<a href=&quot;JavaScript:form.submit();&quot;>click here</a>

Sorry, if this isn't what you wanted!
 
No, the user preferably shouldn't even know they were at that page, it just checks their login information, then redirects them to the page they're meant to be on, it needs to be totally automatic.
 
Sounds nefarious...

So they aren't entering any info? Where are you getting it from? I only ask, because there're alot of variables you can get from PHP such that what you're talking about would be totally unnecessary.

However, if you need to grab variables form javascript or somewhere else that's easy to setup as you said, just put them into your form, then have a <body onload=&quot;document.formname.submit()&quot;>, which will of course take them to the submit page, which can process whatever you like and either close the browser, or redirect them onward or whatever.

-Rob
 
My original intention was for the page to process the info it had recieved via POST from the login page and then redirect them to anothe rpage, sending info retrieved from the database via POST. It suddenly twigged that I could send the session ID and get the info from the database on the next page.

Oh well, sometimes you can't see the solution for the details. (forest for the trees if anyone's wondering)
 
The solution for automatically posting a form using JavaScript is valid, but does anyone know if it is possible to do without using JavaScript.


thanks,

Barry
 
what's about using "$_SESSION" instead POST?

I don't understand what are you doing (my poor english), but you can share the info retreived from de DB to all the pages with SESSIONs vars.

Cheers.
 
Yes that's true, but in my case I need to validate my form then post to someone else's web site. I don't want the user to have to click submit twice.

I wonder if header('Location: would work?
I believe I read in a tutorial somewhere that you can't POST or GET with a redirect, but I could be wrong.


Barry
 
with redirect you could send only GET vars.

header("Location:
I would like to clarify the issue, the procedure is the following?

1. client fill form and click submit (POST)
2. your server recevie the data (via POST) and check DB
3. client is checked and valid
4. you send the client data to other site via POST
5. next page client sees is in your site or the another one?

Cheers.
 
Next page is the site I'm posting to.

So I can do a GET assuming the site I'm posting to doesn't require a POST.


Barry
 
If you want submit data via POST to the other site, I think the only way is using javascript as the other guys recommends you and I don't think that the other site is based on GET form, too much open...

you can create a php page in order to:

validate the client data to the DB
if(client exist)
<form name="form" action="anothersite.com/page-to-receive" method=POST>
<input type=hidden name="var1" value=$var1>
<input type=hidden name="var2" value=$var2>
<input type=hidden name="var3" value=$var3>
...
</form>
<script language="javascript">
document.form.submit();
</script>

all vars must be the same as the "anothersite.com/page-to-receive" expects to receive.

I don't see another way.

Sorry, but hope this help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top