Need Help on Website CGI Script Best answer on the web

Author: mike  //  Category: xn--g7qx97f.com
  • On my website www.dynamicsacappella.com/contact.html I have put up a form that I want to send mail to me when the form is filled out and submitted. I am looking for someone who will be able to write the cgi script or any script that will be supported like asp or php or perl ect. I need this script tailored to my form to get it to work. You can view source and see what I have so far. I am not looking for resources on how to fix this, I am look for an answer on how to fix it to get it to work. Perribly step by step in easy instructions that a novice in this area can understand. Thank you!


  • Hi,

    Your webserver is not parsing the code as PHP.

    You will probably need to rename the file with a .php extension.

    If this does not work, contact your hosting provider to ensure PHP is enabled for your site, and check if any other changes should be made to allow it to be processed.
    The script requires no external libraries or classes and uses only core PHP commands.
    Also, you have not set the '$email_to' variable in the script. It needs a valid email address or no email will be received. Something like: $email_to = "user@domain.com"

    Regards,
    Sycophant


  • Sorry about that, I seem to have left some debug commands in the code I pasted here.
    They two lines that should be removed are in do_form()

    echo "

    Submit: ".$_POST."

    ";

    and process_form()

    print_r($_POST);

    Once those two are changed it should simply return what is defined in $success_message - which can contain HTML if you would like to further style it.
    Regards,
    Sycophant


  • The php is working now, but the confirmation page looks like it is all over the place. Could you please fix the code so it just says Thank you for you submission. And not what looks like 10 lines of php code? The website is www.dynamicsacappella.com/bookus.php


  • Sycophant was very helpful and knowledgeable and quickly tended to my question and clarifacations.


  • The address is htm not html. www.dynamicsacappella.com/contact.htm


  • Hi,

    A form mail script is very simple. There are a number of applications that will do what you want, good places to look for these types of things (in PHP anyway) are: PHP Resource Index
    http://php.resourceindex.com/

    Hotscripts: PHP
    http://www.hotscripts.com/PHP

    However, as you have asked for a customised solution, here is a script I have written for your form as it exists on that page (if you have problems copying and pasting the following code, please check here: http://www.upload2.net/page/download/ua8alfqJAhsYkPo/form.php.html)
    Please note, I have removed email addressed to comply with Google Answers terms.

    They can all be replaced exactly as they are in your current version, also the '$email_to' address will need to be filled in.
    It is fairly simple and should be easy to change later if you like.

    I have changed the names of the form fields for clarity.

    Let me know if you have any questions.

    ---CODE BEGINS---




    Dynamics Acappella: Umass's Hottest Acappella Group





     


     






    Home About Us
    Members
    Auditions Events
    Repertiore Contact Us http://www.cafepress.com/umassdynamics">Dynamics Store







    Please do not hesitate to contact us with any questions you have about the group, our performances and recordings, or in regards to auditioning.


    General Group E-mail



    EMAIL ADDRESS


    General Manager


    Andrew Rozynski - EMAIL ADDRESS


    Music Director


    Emily Hall - EMAIL ADDRESS




    Booking information: The Dynamics
    love to sing and spread the joy of singing to others. Because of this,
    we offer extremely competitive, flexible rates. For your next party, conference, wedding, anniversary celebration or other social engagement, consider
    hiring an a cappella group! We are available for singing engagements in
    the Amherst/Hartford/Boston area throughout the academic year, and tour
    around the nation during academic break.



    do_form();
    ?>







    If you would like the Dynamics to sing at your
    next Benefit, Fund Raiser, or Show please Contact Us 
    at EMAIL ADDRESS








    Website and All contents © Dynamics Acappella 2006







    function do_form() {
    echo "

    Submit: ".$_POST."

    ";
    if (!empty($_POST)) {
    process_form();
    } else {
    draw_form();
    }
    }

    function get_val($varname) {
    if (!empty($_POST)) {
    echo $_POST;
    }
    }

    function get_checked($varname,$value,$default=FALSE) {
    if (empty($_POST) && $default) {
    echo "checked";
    } elseif (strtolower($_POST) == strtolower($value)) {
    echo "checked";
    }
    }

    function get_selected($varname,$value,$default=FALSE) {
    if (empty($_POST) && $default) {
    echo "selected";
    } elseif (strtolower($_POST) == strtolower($value)) {
    echo "selected";
    }
    }

    function draw_form() {

    ?>
    ">



    > Serenade
    > 2-3 Songs
    > Full Concert
    > Special Event





    Other:
    ">

     





     


















    Name
    ">
    E-mail

    ">
    Tel
    ">
    Fax
    ">





     


    > Please contact us as soon as possible for this gig.


     



     





    }

    function process_form() {
    $variables = array("Name","Email","Telephone","Fax","Event_Dur","Event_Type","Other_Detail","Contact_Requested"); $required = array("Name","Email");

    print_r($_POST);

    $email_to = "EMAIL ADDRESS";
    $email_subject = "Website Contact Form";
    $email_from = $_POST ." <". $_POST .">";
    $email_headers = "From: $email_from\r\n";
    $time = date("h:i:sa d-M-y"); // See 'date' docunmentation at php.org
    $error = "";

    $success_message = "Thank you. Your information has been received. We will be in contact shortly.";
    // WINDOWS ONLY
    // If the webserver is running Windows, uncomment the following two lines and replace <> with a // valid SMTP server address.

    // ini_set("SMTP","<>");
    // ini_set("sendmail_from",$_POST);

    $email_body = "A visitor to the website submitted a contact form at $time with the following information: \r\n";
    foreach ($variables as $var) {
    if (empty($_POST)) {
    $value = "EMPTY";
    if (in_array($var,$required)) {
    $error .= "$var needs to be filled out.
    \n";
    }
    } else {
    $value = $_POST;
    }
    $email_body .= str_replace("_"," ",$var).": $value\r\n";

    }

    $email_body .= "\r\n\r\nRemote IP Address: ".$_REQUEST."\r\n";

    if (empty($error)) {
    $success = mail($email_to,$email_subject,$email_body,$email_headers);
    if ($success) {
    echo $success_message;
    } else {
    echo "An error occured sending your form. We cannot deliver it at present. Please contact one of us directly by email instead."; }
    } else {
    echo "Please correct the following errors, then try again:
    $error";
    draw_form();
    }
    }


    ?>

    ---CODE ENDS---

    Regards,
    Sycophant


  • I have posted your code on http://www.dynamicsacappella.com/trial.htm however it does not look or work properly, Could you please view source on this and clarify what I need to do? I copy and pasted the code and it does not work.









  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about Need Help on Website CGI Script , Please add it free.