+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Submitting a form without leaving a page

  1. #1
    drf1229 is offline x10Hosting Member drf1229 is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    71

    Submitting a form without leaving a page

    I am trying to automatically submit a form without the user knowing. I want the form to run anonymously and not change the page. The issue I have is that I do not have access to the php page that is the action of the form. Is it possible to do this without changing anything in the action page?

    Edit: I have found my answer! What I do is add a hidden iFrame to submit the form in the background!
    Ex.


    Formsubmit.php:

    Code:
    <form id="form">
    </form>
    <script type="text/javascript">
    document.getElementById("form").submit();
    </script>
    index.php:
    Code:
    <iframe src="Formsubmit.php" height="0" width="0"></iframe>
    Last edited by drf1229; 01-01-2010 at 08:59 PM.
    Your 14 year old web developer. If I can do it, you can!
    My site
    My iPhone App

  2. #2
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Submitting a form without leaving a page

    Use AJAX rather than submitting the form. You can add a submit handler to the form that cancels the default action (to prevent the form handler page from loading).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  3. #3
    Twinkie is offline Banned Twinkie is an unknown quantity at this point
    Join Date
    Sep 2007
    Location
    Ft. Lauderdale, Florida
    Posts
    1,389

    Re: Submitting a form without leaving a page

    I am assuming you know that the proper way to do that would be AJAX, but (for security reasons) it is not allowed to send data to files on another server than the page you are viewing.

    My only idea would be to gather the data from the forms (without submitting it) via HTML DOM, send it with AJAX to your own server, then fsock it with PHP to its destination.

    Other than that, you would need an assisting technology like Flash or Java, which could probably do it better. However, nothing *in the browser* that I know of.

    I was going to say client side, but I think that is technically incorrect.
    Edit:
    *facepalm* how could I forget about iframes...
    Last edited by Twinkie; 01-01-2010 at 09:04 PM. Reason: Automerged Doublepost

  4. #4
    phpmain2 is offline x10Hosting Member phpmain2 is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    9

    Re: Submitting a form without leaving a page

    That is the simplest way to do so (believe it or not, when I read your post title a minute ago, IFrames popped into my head). However (albeit relatively small), some browsers do not support IFrames.

  5. #5
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Submitting a form without leaving a page

    Quote Originally Posted by drf1229 View Post
    Edit: I have found my answer! What I do is add a hidden iFrame to submit the form in the background!
    Quote Originally Posted by Twinkie View Post
    Edit: *facepalm* how could I forget about iframes...
    Iframes count as AJAX, believe it or not. XMLHttpRequest is just a newer option. Iframes are still used, especially if you want cross-domain communication.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  6. #6
    drf1229 is offline x10Hosting Member drf1229 is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    71

    Re: Submitting a form without leaving a page

    Quote Originally Posted by misson View Post
    Iframes count as AJAX, believe it or not. XMLHttpRequest is just a newer option. Iframes are still used, especially if you want cross-domain communication.
    thanks for the useful post. I had no idea iframes could be so helpful/harmful. Have you ever seen any severe iframe attacks?
    Your 14 year old web developer. If I can do it, you can!
    My site
    My iPhone App

  7. #7
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Submitting a form without leaving a page

    Quote Originally Posted by drf1229 View Post
    Have you ever seen any severe iframe attacks?
    Do you have a particular exploit scenario in mind? The current iframe security model goes a long way towards securing iframes. Bugs in the implementation of same still present exploits, however, and XSS exploits are ever a problem.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

  8. #8
    smoke.sessions is offline x10Hosting Member smoke.sessions is an unknown quantity at this point
    Join Date
    Nov 2009
    Posts
    7

    Re: Submitting a form without leaving a page

    Yeah, I would use AJAX for that. Otherwise, I think jQuery has functions like that.

  9. #9
    drf1229 is offline x10Hosting Member drf1229 is an unknown quantity at this point
    Join Date
    Jun 2009
    Posts
    71

    Re: Submitting a form without leaving a page

    Quote Originally Posted by misson View Post
    Do you have a particular exploit scenario in mind? The current iframe security model goes a long way towards securing iframes. Bugs in the implementation of same still present exploits, however, and XSS exploits are ever a problem.
    Ok, I was just curious what to watch out for in the future.
    Your 14 year old web developer. If I can do it, you can!
    My site
    My iPhone App

  10. #10
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: Submitting a form without leaving a page

    In terms of sites you develop, consider page access (which cross-domain restrictions help secure) and injection attacks (which is entirely up to you to prevent).
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Use PHP to add Content to page through Admin
    By goldy30 in forum Programming Help
    Replies: 1
    Last Post: 11-12-2008, 11:13 PM
  2. Update Form not submitting
    By ChiBuki in forum Programming Help
    Replies: 6
    Last Post: 11-02-2008, 03:50 PM
  3. Load Pages from one Page via URI
    By VPmase in forum Tutorials
    Replies: 1
    Last Post: 05-02-2008, 01:35 AM
  4. Ways around submitting a form using a hyperlink?
    By slpixe in forum Programming Help
    Replies: 6
    Last Post: 04-02-2008, 12:41 PM
  5. How to put a direct contact form on my page
    By monster061 in forum Scripts & 3rd Party Apps
    Replies: 6
    Last Post: 11-01-2007, 06:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers