Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Line Breaks PHP Form

Community Beginner ,
Jul 19, 2010 Jul 19, 2010

Copy link to clipboard

Copied

Hi All,

Admittedly, I know nothing about PHP. Trying to get a simple contact form to work has been a frustrating process.

Below is the PHP that I am using. When the contact form is received, all the info is on one line, strung together without line breaks. I'm wondering how to add breaks to the submitted email.

Your help is greatly appreciated. Thank you.

<?php

  $name = $_REQUEST['name'] ;

  $email = $_REQUEST['email'] ;

  $phone = $_REQUEST['phone'] ;

  $message = $_REQUEST['message'] ;

  mail( "name@anysite.com", "Feedback Form Results",

    $name.=$phone.$message ;  "From: $email" );

  header( "Location: http://www.anysite.com/thankyou.html" ) ;

  ?>

TOPICS
Server side applications

Views

778
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 19, 2010 Jul 19, 2010

Copy link to clipboard

Copied

LATEST

Couple of things to note,

You should have a ","not a ";" separating the message and headers fields.

Secondly, "$name.=$phone.$message" is meaningless. If you are trying to concatenate the three fields together, you have to use "." and add in whatever spaces of carriage returns/linefeeds you want. So:

$name."<br>".$phone."<br>".$message

It's frequently good to add labels to the fields so the reader knows what sorts of information should be there.

The text in any line should not exceed70 characters, according to the PHP rules. You will have to break up the message if it's longer than that.

Unless you are doing a lot of error checking for bad input, you are exposing yourself to a lot of harm using this function, like opening you and your server up to all sorts of nasty attacks.

Never trust any input from the user.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines