problem with form" s:"

Discussion in 'PHP' started by saturn100, Nov 18, 2012.

  1. #1
    I am currently moving a website thats in static HTML to a CMS system
    The site has a regular form that is working on the old site but not on the new one

    It is posting to the document OK but in the email its mention to send me it is not giving me info from the fields.
    Instead I get an email with s: email, s: message and so on

    Other than that the form is working I am getting the thankyou page and the email confirmation

    But I am not been sent the info

    Does this s: email mean anything

    Thanks
     
    saturn100, Nov 18, 2012 IP
  2. ronaldsg

    ronaldsg Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    How does the code handling form submit and sending the email look?
    The problem is probably there.
     
    ronaldsg, Nov 18, 2012 IP
  3. saturn100

    saturn100 Well-Known Member

    Messages:
    465
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    111
    #3
    well this is the full code but as I said I have the code on another

    <?php
    $to = 'info6@mail.com' ;
    $from = $_REQUEST['Email'] ;
    $name = $_REQUEST['Name'] ;
    $subject =$_REQUEST ['subject'];
    $occupation =$_REQUEST ['occupation'];
    $readbook =$_REQUEST ['readbook'];
    
    $message = $_REQUEST['message'];
    $tandc =$_REQUEST ['tandc'];
    $headers = "From: $from";
    $subject = "email recieved";
    
    $fields = array();
    $fields{"Name"} = "Name";
    $fields{"subject"} = "subject";
    $fields{"occupation"} = "occupation";
    $fields{"readbook"} = "readbook";
    $fields{"message"} = "message";
    $fields{"Email"} = "Email";
    $fields{"tandc"} = "tandc";
    
    
    
    
    $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf(" s: %s\n",$b,$_REQUEST[$a]); }
    
    $headers2 = "From: noreply@xxxl.com";
    $subject2 = "Thanks for you email";
    $autoreply = "Thank you for contacting us.  A response will be sent to you within one week.  We thank you for your patience.";
    
    
    if($name == '') {print "You have not entered a name, please go back and try again";}
    else {
    if($subject == '') {print "please select a subject and try again";}
    else {
    if($occupation == '') {print "please select an occupation";}
    else {
    if($readbook == '') {print "please say if you have read the book";}
    else {
    if($from == '') {print "You have not entered an email, please go back and try again";}
    else {
    if($message== '') {print "Please enter your comments or questions and try again";}
    else {
    if($tandc== '') {print "Please agree to the terms and conditions";}
    else {
    
    $send = mail($to, $subject, $body, $headers);
    
    if($send)
    {header( "Location: http://www.xxl.com/thankyou.php" );}
    else
    {print "We encountered an error sending your mail, please try again later"; }
    }
    }
    }
    }
    }
    }
    }
    ?> 
    
    PHP:
     
    Last edited: Nov 18, 2012
    saturn100, Nov 18, 2012 IP
  4. ronaldsg

    ronaldsg Peon

    Messages:
    17
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #4
    Vow, some weird syntax for adding elements to array, usually it's $array['key'] = 'value';

    Anyway, the problem is in this line:

    $body.=sprintf(" s: %s\n",$b,$_REQUEST[$a]);
    
    //should be this
    
    $body.=sprintf(" %s: %s\n",$b,$_REQUEST[$a]);
    
    PHP:
     
    ronaldsg, Nov 18, 2012 IP
  5. kangmid

    kangmid Member

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #5
    $body.=sprintf(" s: %s\n",$b,$_REQUEST[$a]);
    
    //should be this
    
    $body.=sprintf(" %s: %s\n",$b,$a);
    
    PHP:
    Good Luck
     
    Last edited: Nov 18, 2012
    kangmid, Nov 18, 2012 IP