SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    641
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Contact Form Not Working

    Hello,

    This says its working but I dont see it when I check my email it shows new email but when I open it doesnt show the name, email or message.

    http://godfatherrecords.com

    Any ideas what I did wrong?

    Thanks,

    Mike

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    You'll need to show the code you are using to process the form.

  3. #3
    SitePoint Guru
    Join Date
    Aug 2009
    Posts
    641
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Here is the php for the contactengine.php...

    Code:
    <?php
    
    $EmailFrom = $_POST['email'];
    $EmailTo = "info@godfatherrecords.com";
    $Subject = "Godfather Records Email Form";
    $name = Trim(stripslashes($_POST['Name'])); 
    $email = Trim(stripslashes($_POST['Email'])); 
    $comments = Trim(stripslashes($_POST['Message'])); 
    
    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $email;
    $Body .= "\n";
    $Body .= "Message: ";
    $Body .= $comments;
    $Body .= "\n";
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
    }
    ?>

  4. #4
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    5,142
    Mentioned
    152 Post(s)
    Tagged
    0 Thread(s)
    Check the name of your form fields and make sure these are correct:
    PHP Code:
    $name Trim(stripslashes($_POST['Name'])); 
    $email Trim(stripslashes($_POST['Email'])); 
    $comments Trim(stripslashes($_POST['Message'])); 
    From what I can tell, it should be
    PHP Code:
    $name Trim(stripslashes($_POST['name'])); 
    $email Trim(stripslashes($_POST['email'])); 
    $comments Trim(stripslashes($_POST['comments'])); 

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,200
    Mentioned
    456 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by cpradio View Post
    From what I can tell, it should be ... $_POST['name'] ...
    Yes, it's better never to use capitals in code (except perhaps when camel casing), as it's just one extra way to get things messed up.

  6. #6
    SitePoint Member
    Join Date
    Nov 2013
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    Yes, it's better never to use capitals in code (except perhaps when camel casing), as it's just one extra way to get things messed up.
    And I believe it's better to use underscore to divide variable name than using camel casing. It describe the variable better.
    But of course it's up to the programmer's style.


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
  •