1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

form submit error

Discussion in 'PHP' started by reginaong88, May 23, 2007.

  1. #1
    Hi,

    I have a form which uses php script. I obtain this script from a friend and tried to make some changes. However, the result when someone enters and submit the form, the recepient email would receive the following result:

    Company: aaa\nName: \nAddress: aa\nEmail: \nTel: a\nFax: \nMobile: \nEnquiry: bb\n


    Is there a way to remove the \n from the script? I'm unfamilliar with .php script and unsure on how to modify it. Thanks if can help
     

    Attached Files:

    reginaong88, May 23, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    Use double quotes around the \n instead of single quotes.
     
    nico_swd, May 23, 2007 IP
  3. Chamaro Zwinkels

    Chamaro Zwinkels Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Exactly:
    echo "Company: aaa\nName: \nAddress: aa\nEmail: \nTel: a\nFax: \nMobile: \nEnquiry: bb\n";
    PHP:
    And not:
    echo 'Company: aaa\nName: \nAddress: aa\nEmail: \nTel: a\nFax: \nMobile: \nEnquiry: bb\n';
    PHP:
    Because, echo with single quotes gives the real word etc.
     
    Chamaro Zwinkels, May 23, 2007 IP
  4. reginaong88

    reginaong88 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Thanks guys! But I'm still not sure where to put the double quotes...below is how the script look like in the php file:

    $message = 'Company: '.$_POST['txtCompany'].'\n'.
    'Name: '.$_POST['txtName'].'\n'.
    'Address: '.$_POST['txtAddress'].'\n'.
    'Email: '.$_POST['txtEmail'].'\n'.
    'Tel: '.$_POST['txtTel'].'\n'.
    'Fax: '.$_POST['txtFax'].'\n'.
    'Mobile: '.$_POST['txtMobile'].'\n'.
    'Enquiry: '.$_POST['txtEnquiry'].'\n';

    where should the double quotes be placed?
     
    reginaong88, May 23, 2007 IP
  5. lemaitre

    lemaitre Peon

    Messages:
    61
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Put double quotes instead of single quotes around each "\n". The rest you can leave as-is.
     
    lemaitre, May 23, 2007 IP
  6. Chamaro Zwinkels

    Chamaro Zwinkels Peon

    Messages:
    44
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    $message = 'Company: '.$_POST['txtCompany'].'\n'.
    PHP:
    Should be:
    $message = "Company: '.$_POST['txtCompany'].'\n".
    PHP:
    and can also be:
    $message = "Company: ".$_POST['txtCompany']."\n".
    PHP:
     
    Chamaro Zwinkels, May 24, 2007 IP