Results 1 to 4 of 4

Thread: php popup box to replace form redirect page?

  1. #1
    Join Date
    Jul 2005
    Location
    UK
    Posts
    159
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Lightbulb php popup box to replace form redirect page?

    i've installed a simple php mail script, which redirects to a thank you / follow-up page after verifying user-inputted content. rather than ending up here, i'd prefer to not leave page with the form at all, and instead have a popup alert box simply say "thanks for your message!" with an "ok" button. then, when you click ok, it refreshes the page so you are right back where you started off.

    heres my php code:

    PHP Code:
    <?php

    $ip 
    $_POST['ip'];
    $httpref $_POST['httpref'];
    $httpagent $_POST['httpagent'];
    $visitor $_POST['visitor'];
    $visitormail $_POST['visitormail'];
    $notes $_POST['notes'];
    $attn $_POST['attn'];


    if (
    eregi('http:'$notes)) {
    die (
    "Do NOT try that! ! ");
    }
    if(!
    $visitormail == "" && (!strstr($visitormail,"@") || !strstr($visitormail,".")))
    {
    echo 
    "<h2>Go Back - Enter valid e-mail</h2>\n";
    $badinput "<h2>Feedback was NOT submitted</h2>\n";
    echo 
    $badinput;
    die (
    "Go back! ! ");
    }


    $todayis date("l, F j, Y, g:i a") ;

    $attn $attn ;
    $subject 'Message from mydomain.com';

    $notes stripcslashes($notes);

    $message $todayis [EST] \n
    Message: 
    $notes \n
    From: 
    $visitor ($visitormail)\n
    "
    ;

    $from "From: $visitormail\r\n";


    mail("myemail@mydomain.com"$subject$message$from);

    ?>
    how can i achieve this?

  2. #2
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Right now I don't see where your redirecting the user. But one thing that you do to validate that the email has been sent is:
    PHP Code:
    if(@mail($data..)){
      
    header();

    To not re-load the page at all. You would have to learn/use ajax. If your lazy and don't really want to learn an extension to javascript - use jquery - an extension to javascript . And for the popup, use the "Open Dialog" button(you'd need to download a jquery style/format) located here.

    Good luck - Your brave, I would never attempt this.
    Jeremy | jfein.net

  3. The Following User Says Thank You to Nile For This Useful Post:

    moscarda (02-02-2009)

  4. #3
    Join Date
    Jul 2005
    Location
    UK
    Posts
    159
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Default

    hmm, i dont think what i'm trying to do is as advanced as youre thinking.

    the code pasted above IS the page that gets redirected to when the form posts:

    HTML Code:
    <form method="post" action="email.php">
    i could just append the php file with something like:

    PHP Code:
     ?>
    <script type="text/javascript">
        alert("Thanks for your message!");
        history.go(-2);
      </script>
    <?php
    but that still won't keep me from navigating away from the original page with the form. am i making sense?

  5. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    You can't do this without ajax... Try this. Then with ajax you would have to send the POST data... (if your validating to make sure that the page is valid.
    Jeremy | jfein.net

  6. The Following User Says Thank You to Nile For This Useful Post:

    moscarda (02-02-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
  •