Hi All,
I have a shoppping basket like page and I need to submit it to a processing script one item at a time.
How can I submit a form without it redirecting - prefferably with a wait of half a second between each item?
I'm able to use php and javascript
Thanks in advance - James
how can I submit a form multiple times - without redirecting
Moderator: General Moderators
-
jrswastaken
- Forum Newbie
- Posts: 3
- Joined: Fri Sep 08, 2006 1:52 am
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
-
jrswastaken
- Forum Newbie
- Posts: 3
- Joined: Fri Sep 08, 2006 1:52 am
Thanks for your reply
I've looked into ajax and can see how to do it on the client side using javascript but I'd like php to do it as there is some sensitive data I'd preffer to not have transmitted to the client.
Here is some of the java script method I've found - I've been assuming there is something similar in php to allow requests to be created and sent but can't find anything.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try
{
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
I've looked into ajax and can see how to do it on the client side using javascript but I'd like php to do it as there is some sensitive data I'd preffer to not have transmitted to the client.
Here is some of the java script method I've found - I've been assuming there is something similar in php to allow requests to be created and sent but can't find anything.
if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
try
{
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp = false;
}
}
return xmlhttp;
-
jrswastaken
- Forum Newbie
- Posts: 3
- Joined: Fri Sep 08, 2006 1:52 am
Hi Thanks for your help so far
Maybe i'm not being clear - or just stupid
but how do I make the php script I have access to do multiple form submissions? My shopping basket page will submit a list of items to my processing script which needs to individually submit these items to a checkout script which I don't have any access to or control over.
In javascript I can do document.my_form.submit() but then I get redirected by the script which handles this form - I need to have this not happen (until the last item) so that my processing script can submit all the items to this checkout script.
How do I make a function in PHP that I can call with the form data (required by the checkout) such that it submits and doesn't redirect me - a function that doesnt return
Maybe i'm not being clear - or just stupid
but how do I make the php script I have access to do multiple form submissions? My shopping basket page will submit a list of items to my processing script which needs to individually submit these items to a checkout script which I don't have any access to or control over.
In javascript I can do document.my_form.submit() but then I get redirected by the script which handles this form - I need to have this not happen (until the last item) so that my processing script can submit all the items to this checkout script.
How do I make a function in PHP that I can call with the form data (required by the checkout) such that it submits and doesn't redirect me - a function that doesnt return
You don't "submit" with PHP (serverside). That's what you do with HTML (clientside). In PHP you handle data and you can send it to another place (script, database, session, server, whatever) and you can do so repeatedly with a loop (e.g. for , foreach(), while , do-while ).jrswastaken wrote:but how do I make the php script I have access to do multiple form submissions? My shopping basket page will submit a list of items to my processing script which needs to individually submit these items to a checkout script which I don't have any access to or control over.
There are many solutions, the easiest one would probably be to have the form submit to itself a lajrswastaken wrote:In javascript I can do document.my_form.submit() but then I get redirected by the script which handles this form - I need to have this not happen (until the last item) so that my processing script can submit all the items to this checkout script.
How do I make a function in PHP that I can call with the form data (required by the checkout) such that it submits and doesn't redirect me - a function that doesnt return
Code: Select all
<form action="<?PHP echo $_SERVER['PHP_SELF']?>">
... html stuff
</form>