Results 1 to 8 of 8

Thread: HTML/PHP Form

  1. #1
    Join Date
    Jul 2009
    Location
    Washington (USA)
    Posts
    94
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Question HTML/PHP Form

    Hello everyone!

    I was looking for a form that will let the user submit the location of an iframe (on the same page) to mein an email.

    Any Ideas???

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    you mean the iframe source?
    Is it always one/several urls, or could it be any url (user-determined)? Do you want them to enter the url manually or simply submit the form and it would determine the url automatically?

  3. #3
    Join Date
    Jul 2009
    Location
    Washington (USA)
    Posts
    94
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default

    Yeah, it should submit the url automatically. I plan on using this for people wh need to report an error on my site.

  4. #4
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    how is the iframe source set? If it's set by a button, link, or referrer, you could use the same method to POST it via a hidden form and send the email from there. Otherwise, you'd have to use something like jQuery to find the iframe source. Javascript is not my strongest suit, but if you post your code I'd be happy to help you figure it out.

  5. #5
    Join Date
    Jul 2009
    Location
    Washington (USA)
    Posts
    94
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default

    Here's the code:

    HTML Code:
    <form><input type="submit" value="Report Broken Page"></form>
    <br><br>
    <iframe src="page-name.html" height=500 width=550 frameborder=0></iframe>
    if there could be an alert box before it sends the email to say 'Duble check your browser first' or something like that...

  6. #6
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,643
    Thanks
    63
    Thanked 516 Times in 502 Posts
    Blog Entries
    5

    Default

    here's the question we need answered: what determines the source of the iframe ( src="page-name.html" )? Is that always the same or is it sometimes "otherpage-name.html" or is there some way to allow the user to choose a page ( "whateverpageIlike.html" )? How is the source set?

  7. #7
    Join Date
    Jul 2009
    Location
    Washington (USA)
    Posts
    94
    Thanks
    3
    Thanked 3 Times in 3 Posts

    Default

    Yes, the iframe src changes, a lot. that's the point of the script: and error reporter

  8. #8
    Join Date
    Mar 2007
    Location
    New York, NY
    Posts
    557
    Thanks
    8
    Thanked 66 Times in 66 Posts

    Default

    Then get the source of the current SRC of the iframe.

    PHP Code:
    <?php

    if(isset($_POST['submit'])) {

    $to "someone@example.com";
    $subject "Iframe source";
    $message $_POST['hidden'];
    $from "someonelse@example.com";
    $headers "From: $from";

    mail($to,$subject,$message,$headers);

    echo 
    "Mail successfully sent";

    }

    ?>

    <script type="text/javascript">
    function sendSource() {
    var source = document.getElementById('sourceFrame').document.body.innerHTML;
    var hidden = document.getElementById('hidden');
    hidden.value = source;
    }
    </script>

    <iframe src="blah blah" id="sourceFrame"></iframe>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <input type="hidden" name="hidden" value="hidden">
    <input type="submit" name="submit" value="Send Mail!">
    </form>
    Make changes to fit your needs.

    HTH
    - Josh

  9. The Following User Says Thank You to JShor For This Useful Post:

    kaos (09-01-2009)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •