Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts

    Message is not working in form

    I have this form that I use for my sites, but the message bit is not showing on submit. It must be the php code of the message bit can anyone help?
    Code:
    <?php  
    session_start();
    
    require_once('recaptchalib.php');
      $privatekey = "removed";
      $resp = recaptcha_check_answer ($privatekey,
                                    $_SERVER["REMOTE_ADDR"],
                                    $_POST["recaptcha_challenge_field"],
                                    $_POST["recaptcha_response_field"]);
    
    // Get variables from your form ...  
    $username = $_POST['name'];
    $useremail = $_POST['email'];
    $usersubject = $_POST ['subject'];
    
    // Save the form variables in SESSION
    // We will be using this later.
    $_SESSION['username'] = $_POST['name'];
    $_SESSION['useremail'] = $_POST['email'];
    $_SESSION['usersubject'] = $_POST['skills'];
    
    // Who the form gets sent to ...  
    $recipient = "removed";
    $subject = "Website Form";  
    
    // Where to go after the user submits the form ...  
    $redirect = "../venue/venue_thank_you.html";  
    
    if (!$resp->is_valid) {
        // What happens when CAPTCHA entered incorrectly ...$redirect = "../thanks.html";  
        // What happens when CAPTCHA entered incorrectly ...
    die ("<div id='captcha_error'>The reCAPTCHA wasn't entered correctly. Go back and try it again." .
             "(reCAPTCHA said: " . $resp -> error . ")</div>");
       } else {
        // Successful captcha, so continue on with the email ...
      }
    
    $message = "
    ================================
    Name:  $username
    Email:  $useremail
    Subject: $usersubject
    -----------------------------------------
    $fmessage
    ================================
    ";  
    
    $extraheaders = "From: $useremail\r\nReply-To: $useremail\r\n";  
    
    if (! mail($recipient, $subject, $message, $extraheaders))
      echo "Mail did not send for some reason.";  
    
    header('Location:'.$redirect);  
    
    ?>

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,352
    Thanks
    61
    Thanked 528 Times in 515 Posts
    With 763 posts i'm sure you've read about using [php] tags but just in case there is a link in my signature for you
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #3
    Regular Coder
    Join Date
    Apr 2005
    Location
    Ohio
    Posts
    254
    Thanks
    1
    Thanked 63 Times in 63 Posts
    Quote Originally Posted by quartzy View Post
    Code:
    <?php  
    // Get variables from your form ...  
    $username = $_POST['name'];
    $useremail = $_POST['email'];
    $usersubject = $_POST ['subject'];
    
    // Should be an
    $fmessage = $_POST['something'];
    // somewhere around here
    You're using "$fmessage" variable in your $message variable but I don't see where you're actually assigning anything to "$fmessage"

  • #4
    Regular Coder
    Join Date
    May 2009
    Posts
    813
    Thanks
    123
    Thanked 24 Times in 24 Posts
    Hello
    Thanks you for offering to help but there is no help here. I dont know php. And just need the code to work.


  •  

    Posting Permissions

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