Results 1 to 5 of 5

Thread: Form filling, confirming and sending it via email

  1. #1

    Form filling, confirming and sending it via email (PHP)

    I am testing a form (called "one.php") with 4 fields (login, password, fullname, url) when the submit button is clicked it goes to "two.php"

    On page "two.php" I would like to print again the values of the variables that it obtained from "one.php" to confirm, and have a button that when clicked the results of the variables to be send to an email, and if not they can click the "Return Back" button that will take them back to and make changes.

    I have the following, but it just does not work with the "two.php" - it does not like that if statement I think. I will keep making changes to this, and hope to make it work. If you have any ideas I would appreciate them once more. Thanks!



    one.php
    -----------------------------------------------------------------

    <HTML><BODY>

    <FORM NAME="TheForm" METHOD="post" ACTION="two.php">
    ...
    </FORM>

    </BODY></HTML>




    two.php
    -----------------------------------------------------------------

    <?

    if ($submit == "click")
    {
    mail("tester@hotmail.com", "Form Testing", "$login<BR>$password<BR>$fullname<BR>$url");
    PRINT "Thank you, your message was sent";
    }

    echo '
    <html><body>
    <FORM METHOD="POST" "<? echo $PHP_SELF; ?>">
    <TR><TD>
    <?
    PRINT "Greetings $login, thank you for filling the form<BR>";
    PRINT "Your password is $password!<BR>";
    PRINT "The fullname is $fullname..<BR>";
    PRINT "The URL is: $url<BR>";
    ?>
    <input type="submit" name="submit" value="click">
    <input type="submit" value ="Go Back">
    </FORM>
    </body></html>
    ';
    ?>
    Last edited by George W. Bush; 15th June 2001 at 04:44.

  2. #2
    Okay... this is something cool cooking here... this is a working script. Also, thanks to jonsteele for assistance on writting the form content to a text file...

    This will write to a text file, send you an email!! I still would like to incorporate into this one, or the one above (or both) an option where one will have a confirmation written to the page indicating the person what he/she has inputed in the fields, if the info is correct then click on another button to continue (to send email and write it to the text file!)

    Quite niffty I must say...



    <?
    $file_name = "result.txt";
    ?>

    <?php

    if ($submit == "click"){
    {
    $mailTo = "youremail@supermonkeyboy.com";
    $msgSubject = "Downloading MediaKit";
    $msgBody = "$login, $password, $fullname, $url";
    mail ($mailTo, $msgSubject, $msgBody);
    }

    // check existence of file (or try to create it)
    // a better alternative to touch() would be is_file, is_writable and so on.
    $try = touch($file_name);
    if (!$try) {
    echo "<p>Sorry I can't open a file, something is wrong";
    exit;
    }

    // so we can make a big string with tabs between the elements
    // note that we add a \n (line break) to the end of the string.
    $output_line = "LOGIN:\t$login\nPASSWORD:\t$password\nFULLNAME:\t$fullname\nURL:\t$url\n\n";

    // Now open the file (get a file pointer)
    // We will append to it and therefore use the "a" option
    $output_stream = fopen($file_name, "a");

    // and dump the string into the file
    $result = fputs ($output_stream, $output_line);

    // close the file pointer
    fclose($output_stream);


    PRINT "Thank you $name very much.\nYour form was send via email to us, and written to a text file for record keeping.\nPlease buzz off now.\nThank you!";
    }

    else{
    echo '
    <html><body>

    <FORM METHOD="POST" "<? echo $PHP_SELF; ?>">

    Login
    <input type="text" name="login"><br>
    Password
    <input type="text" name="password"><br>
    Fullname
    <input type="text" name="fullname"><br>
    URL
    <input type="text" name="url"><br>
    <input type="submit" name="submit" value="click">

    ';
    }

    ?>
    </body></html>

  3. #3
    just to let you know, this may be the error you had at first?

    if you submit a form with javascript this.form.submit();
    it will NOT submit the submit button name:value pair.
    and you ARE checking the submit button. Another error
    MAY be that you can't name the submit button name="submit"
    as it is a keyword.

    lastly in the second reply you made I don't see any ending form tags and open tags like that can be bad in Netscape.

    Lorddog

  4. #4
    The two scripts are different, yet they should perform the same thing. I just cannot get it to display the results on a page before another button is clicked to submit and send it. Still trying to figure this one out...

    And yes, the </FORM> should be closed.

  5. #5
    to have a middle page that displays the info with a confirmation submit button you can
    make the middle page recieve the form data and put it all into
    hidden form values and print it out.
    Then with THAT submit button go to the final page that sends it.

    Lorddog

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help with sending email
    By Tasmanian Devil in forum Server-side Forum
    Replies: 2
    Last Post: 27th March 2004, 20:10
  2. sending email to email via form
    By ripper in forum Client-side forum
    Replies: 1
    Last Post: 24th May 2002, 13:31
  3. sending email
    By stryker321 in forum Server-side Forum
    Replies: 1
    Last Post: 14th January 2002, 11:13
  4. Sending Form details as email
    By bernaj98 in forum Client-side forum
    Replies: 2
    Last Post: 13th July 2001, 15:08
  5. help with sending form to email
    By Sic84 in forum Client-side forum
    Replies: 1
    Last Post: 1st March 2001, 08:33

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
  •