1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Resolved Website design formmail-php.php and thankyou page

Discussion in 'General Internet' started by wyobison, 2009/09/08.

  1. 2009/09/08
    wyobison

    wyobison Inactive Thread Starter

    Joined:
    2009/08/10
    Messages:
    98
    Likes Received:
    0
    I know enough about programming to be dangerous. I have a website where a guests fills out a form and I am using a formmail-php.php which by the way works fine but I am also trying to get a thank you page to come up. I thought I had this working at one time.
    Below is the website form code in red. Below that code is the formmail-php.php in blue.
    Any help would be appreciated.

    <div style= "float: right ">
    <form method= "post" action= "formmail-php.php ">
    <input type= "hidden" name= "send" value= "1" />
    <input type= "hidden" name= "redirect" value= "http://www.phastingsstudio.com/thank_you.html ">
    <table border= "0" cellspacing= "0" cellpadding= "7" class= "form_table ">
    <tr>
    <td class= "Name "><strong>Name:</strong></td>
    <td>
    <input name= "*Name" type= "text" style= "width: 185px" class= "formelements" /></td>
    </tr>
    <tr>
    <td class= "Phone "><strong>Phone:</strong></td>
    <td>
    <input name= "*phone" type= "text" style= "width: 185px" class= "formelements" /></td>
    </tr>
    <tr>
    <td class= "Email "><strong>Email:</strong></td>
    <td>
    <input name= "*email" type= "text" style= "width: 185px" class= "formelements" /></td>
    </tr>
    <tr>
    <td class= "Inquiry "><strong>Comment:</strong></td>
    <td>
    <textarea name= "*inquiry" style= "width: 190px; height: 142px" rows= "1" cols= "20" class= "formelements "></textarea></td>
    </tr>
    <tr>
    <td style= "height: 36px "></td>
    <td style= "height: 36px ">
    <input name= "Submit" input type= "image" src= "buttons/2submit.png" value= "submit" onClick= "parent.location.href='thank_you.html'" style= "height: 21px "></td>
    </tr>
    </table>
    </form>
    </div>




    <?php
    /* $Id: formmail-php.php,v 1.0 2007-07-06 22:22:40-08 scoutt Exp $ */
    // vim: expandtab sw=4 ts=4 sts=4:
    ########################################################################
    ## ##
    ## ---------------------------------------------------------------- ##
    ## Copyright © Big Resources, Inc. All Rights Reserved. ##
    ## This software must be used in accordance with its licensing ##
    ## Built for use with templates from http://www.boxedart.com ##
    ## ##
    ## This copyright notice may not be removed. ##
    ## ---------------------------------------------------------------- ##
    ########################################################################
    session_start();

    ###########################################
    ## SETUP: First we need to edit a few varaibles
    ## so the script will work correctly.
    ##
    ## For any field that you want to be required,
    ## meaning you want them to have to fill it in,
    ## put a * in front of the name of the field
    ## example: <input type= "text" name= "*fname" value=" " />
    ##
    ##
    ## FORM SETUP:
    ## Your form has to have 1 element in it and
    ## It has to be a hidden element. Please add
    ## this line to your form:
    ## <input type= "hidden" name= "send" value= "1" />
    ##
    ## If you do not add it the script will not work
    ##
    ## Also it is best to name your form fileds where
    ## they make since. Like :
    ## <input type= "text" name= "*fname" value=" " />
    ## 4<input type= "text" name= "*email" value=" " />
    ## where fname symbolizes their first name and email
    ## is for there email.

    ###########################################
    ##
    ## Please change this to your email address
    ###########################################

    $_email_to = "hsroberts@hughes.net ";

    ###########################################
    ##
    ## Next we need to change this variable
    ## This controls line spacing, default is
    ## perfect (\r\n) but if you want more space
    ## between each row than add one more of
    ## what you see below eg: \r\n\r\n
    ##

    $_lines_ = "\r\n ";

    ############################################
    ##
    ## This sets the time between each email
    ## the user is allow to send. Used for spam
    ## control. 1800 is 1 hour waiting time.
    ##
    ##

    $_flood_time_ = 1800;

    #############################################
    ##
    ## Change this varaible for the subject
    ## of the email
    ##
    ##

    $_subject_ = "Contact form ";

    ##########################################
    ## This affects how the date is displayed,
    ## see http://www.php.net/date
    ## for more info

    $today = gmdate ( "M d Y H:i:s" );

    #############################################



    ## Main script below. Please do not edit unless you
    ## change the language (text) only.
    #############################################


    function print_form($parray,$body) {
    global $_lines_;
    while (list($index, $sub) = each($parray)) {
    $index = ereg_replace( "\* ", " ", $index);
    $index = ereg_replace( "_ ", " ", $index);
    if (eregi('submit',$index)){ continue;}
    elseif (eregi('reset',$index)){ continue;}
    $body .= "$index: ".htmlentities($sub). "$_lines_ ";
    }
    return $body;
    }

    function check_input(){
    global $flood;
    if (isset($_SESSION['FloodControl']) AND $_SESSION['FloodControl'] >= $flood){
    echo "Contact already sent ";
    return false;
    }
    if(gettype($_POST)== "array ") {
    while (list($index, $subarray) = each($_POST) ) {
    if(ereg( "\* ", $index) && (($subarray == " ") || ($subarray == " "))) {
    $index = ereg_replace( "\* ", " ", $index);
    $index = ereg_replace( "_ ", " ", $index);
    echo "There is a problem with your submission. The field <span style=\ "color:red\ ">$index</span> is required, please press the back button on your browser.</div> ";
    return false;

    } elseif(eregi( "email ", $index)){
    if(!ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.'[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.'[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $subarray)){
    $index = ereg_replace( "\* ", " ", $index);
    echo "There is a problem with your submission. The E-mail address you provided, <span style=\ "color:red\ ">$subarray</span>, does not appear to be valid, please press the back button on your browser and give a valid address. ";
    return false;
    }
    }
    }
    return true;
    } else {
    return false;
    }
    }

    $flood = time()-$_flood_time_;

    if ((isset($_POST['send']) AND $_POST['send']== "1 ")){
    if (check_input()){
    $_SESSION['FloodControl'] = time();
    $info = "On $today, a visitor submitted '$_subject_' from the your website.{$_lines_}{$_lines_} ";
    $contact_body = print_form($_POST,$info);
    $headers = "From: $_email_to<{$_email_to}>\r\n ";
    // send e-mail
    mail($_email_to, $_subject_, stripslashes($contact_body), $headers);


    echo "Message sent successfully\n ";
    exit;
    }

    }



    ?>
     
  2. 2009/09/09
    TonyT

    TonyT SuperGeek Staff

    Joined:
    2002/01/18
    Messages:
    9,072
    Likes Received:
    400
    The above will not do anything because there is no reference to that input variable in the php script.

    You can eliminate the line completely and use the code below after the message gets sent. (obviously, thank_you.html MUST exist on the server)

    Code:
    echo  "Message sent successfully\n ";
    // content=3 is the timer, redirects after 3 seconds
    // retain the single quotes in the line else will fail
    echo  "<meta http-equiv='refresh' content='3; url=http://www.phastingsstudio.com/thank_you.html'> ";
    exit;
     

  3. to hide this advert.

  4. 2009/09/09
    wyobison

    wyobison Inactive Thread Starter

    Joined:
    2009/08/10
    Messages:
    98
    Likes Received:
    0
    Works great!
    Thanks a ton. That is what I wanted but I didn't know how to write the code.
     
  5. 2009/09/09
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    I've marked this thread as 'Resolved'.

     
    Arie,
    #4

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.