Problems with post to email

Discussion in 'PHP' started by uLaTGauK, Sep 27, 2009.

  1. #1
    Hello there,

    Currently I have a problem to post all my values in the field to an email but when i checked it the variable seems to be empty. I'm quite new in PHP programming. I dont know if i could paste the long coding here.hope friendly people could notice my mistakes.Im making this form for more than a month now and my brain is almost overheated. I just try to attachment here..
     

    Attached Files:

    Last edited: Sep 27, 2009
    uLaTGauK, Sep 27, 2009 IP
  2. prasanthmj

    prasanthmj Member

    Messages:
    62
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    There are many inconsistent variable names.
    You are getting the form submission using 'name'
    
    $name = $_POST['name'];
    
    PHP:
    and then using $Cname to compose the message
    
     $email_body = "You have received a new message from the user $Cname.\n".
    
    PHP:
    Note also that variable names are case sensitive

    Also
    1. start from simple to iteratively add more stuff
    2. separate the display(HTML) from the logic. Example: create a page to display the form and another script to handle the form
     
    prasanthmj, Sep 28, 2009 IP
  3. uLaTGauK

    uLaTGauK Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ok, I've tried that already. there is still no output. i forget to change it btw.:p the only problem is i'm trying to display all the input in the form and when i click the submit/send button the information in the variable should go to the email of the recipient but somehow the variable seems to be empty. any other solution?

    i've tried the
    <label for="">
    Code (markup):
    but the only problem is how could i display it with my output as i want it to display in the email like

    eg output: Company Name: Capsule Corp
    Company Address: London Street 11345

    i make the <label> code for form2mail.php is

    <?php
    
    $name = $_POST['name'];
    $visitor_email = $_POST['email'];
    $message = $_POST['message']; 
    
    $email_from = 'blahblahblah@hotmail.com';
    $email_subject = "New Form submission";
    $email_body = "You have received a new message from the user $name.\n".
        "Here is the message:\n $message".
        
    $to = "recipient@hotmail.com";
    $headers = "From: $email_from \r\n";
    $headers .= "Reply-To: $visitor_email \r\n";
    //Send the email!
    mail($to,$email_subject,$email_body,$headers);
    //done. 
    ?> 
    Code (markup):
    this is only for one variable,eg: 'CName',
    $message = $_POST['CName']; 
    Code (markup):
    how about multiple variables like my form, CName,CAddress?how to extract it? is there any other way other than repeating eg:
    $message1 = $_POST['CAddress']; 
    Code (markup):
    $message2 = $_POST['CPoscode']; 
    Code (markup):
     
    uLaTGauK, Sep 29, 2009 IP