Results 1 to 2 of 2

Thread: Update my mailform to PHP4 or 5

  1. #1
    Join Date
    Jan 2006
    Posts
    14

    Update my mailform to PHP4 or 5

    I have a form on my flash website that needs to be upgraded to PHP4 or 5. I have no idea how this is done. Can anyone help me with this conversion if it's not too much to ask? Here is my present code.

    PHP Code:

    <?php

    $adminaddress 
    "klm@somewhere.com";
    $siteaddress ="http://www.somewhere.com";
    $sitename "somewhere";

    // Gets the date and time from your server
    $date date("m/d/Y H:i:s");

    // Gets the IP Address
    if ($REMOTE_ADDR == "") {
        
    $ip "no ip";
    } else {
        
    $ip getHostByAddr($REMOTE_ADDR);
    }

    // Gets the POST Headers - the Flash variables
    $action $HTTP_POST_VARS['action'] ;
    $email $HTTP_POST_VARS['email'] ;
    $name $HTTP_POST_VARS['name'] ;
    $comments $HTTP_POST_VARS['comments'] ;

    //Process the form data!
    // and send the information collected in the Flash form to Your nominated email address

    if ($action == "send") {
        
    $mRecipient $adminaddress;
        
    $mSubject "Info Request";
        
    $mBody "A visitor at $sitename has left the following information\n
    Name: 
    $name
    Email: 
    $email\n
    The visitor commented:
    ------------------------------
    $comments
        
    Logged Info :
    ------------------------------
    Using: 
    $HTTP_USER_AGENT
    Hostname: 
    $ip
    IP address: 
    $REMOTE_ADDR
    Date/Time:  
    $date";
        
    $mHeaders "MIME-Version: 1.0\n";
        
    $mHeaders .= "From: $name <$email>\n";
        
    mail($mRecipient$mSubject$mBody$mHeaders);


        
    //This sends a confirmation to your visitor
        
    $mRecipient $email;
        
    $mSubject "Thank You for visiting $sitename";
        
    $mBody "Hi $name,\n
    Thank you for your interest in 
    $sitename!
    We will respond to your inquiry as soon as possible.\n
    Cheers,
    $sitename
    $siteaddress";
        
    $mHeaders "MIME-Version: 1.0\n";
        
    $mHeaders .= "From: $sitename <$adminaddress>\n"// you can change $siteaddress to whatever address you wish if you expect reply to the confirmation email
        
    mail($mRecipient$mSubject$mBody$mHeaders);

        
    $sendresult "Thank you. You will receive a confirmation email shortly.";
        
    $send_answer '&answer=';
        
    $send_answer .= rawurlencode($sendresult) . '&';
        echo 
    $send_answer;
    }
    ?>

  2. #2
    Join Date
    Mar 2005
    Posts
    36
    Quote Originally Posted by dude9er
    I have a form on my flash website that needs to be upgraded to PHP4 or 5. I have no idea how this is done. Can anyone help me with this conversion if it's not too much to ask? Here is my present code.
    I think I did the code right... but I wonder what the last few lines were for.

    PHP Code:

    <?php

    $adminaddress 
    "klm@somewhere.com";
    $siteaddress ="http://www.somewhere.com";
    $sitename "somewhere";

    // Gets the date and time from your server
    $date date("m/d/Y H:i:s");

    // Gets the IP Address
    if ($_SERVER['REMOTE_ADDR'] == "") {
        
    $ip "no ip";
    } else {
        
    $ip gethostbyaddr($_SERVER['REMOTE_ADDR']);
    }

    // Gets the POST Headers - the Flash variables
    $action $_POST['action'] ;
    $email $_POST['email'] ;
    $name $_POST['name'] ;
    $comments $_POST['comments'] ;

    //Process the form data!
    // and send the information collected in the Flash form to Your nominated email address

    if ($action == "send") {
        
    $mRecipient $adminaddress;
        
    $mSubject "Info Request";
        
    $mBody "A visitor at $sitename has left the following information\n
    Name: 
    $name
    Email: 
    $email\n
    The visitor commented:
    ------------------------------
    $comments
        
    Logged Info :
    ------------------------------
    Using: 
    $HTTP_USER_AGENT
    Hostname: 
    $ip
    IP address: "
    .$_SERVER['REMOTE_ADDR']."
    Date/Time:  
    $date";
        
    $mHeaders "MIME-Version: 1.0\n";
        
    $mHeaders .= "From: $name <$email>\n";
        
    mail($mRecipient$mSubject$mBody$mHeaders);

        
    //This sends a confirmation to your visitor
        
    $mRecipient $email;
        
    $mSubject "Thank You for visiting $sitename";
        
    $mBody "Hi $name,\n
    Thank you for your interest in 
    $sitename!
    We will respond to your inquiry as soon as possible.\n
    Cheers,
    $sitename
    $siteaddress";
        
    $mHeaders "MIME-Version: 1.0\n";
        
    $mHeaders .= "From: $sitename <$adminaddress>\n"
    // you can change $siteaddress to whatever address you wish if you expect // reply to the confirmation email
        
    mail($mRecipient$mSubject$mBody$mHeaders);

        
    $sendresult "Thank you. You will receive a confirmation email shortly.";
        
    $send_answer '&answer=';
        
    $send_answer .= rawurlencode($sendresult) . '&';
        echo 
    $send_answer;
    }
    ?>
    I hope that works well. If the post variables don't work, you could go back to $HTTP_POST_VARS if you want.
    Sincerely, Aaron Abaci

    PHP Designer looking for experience. Please contact me with ideas. Will work for free. See my forum

Posting Permissions

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