SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question about this form script

    How can I change it so that is displays the name or the variable and then the actual variable itself. Eg it will say "name:" and then the name the user has input into the name field.

    Code PHP:
    <?php 
    		$mail_recipient = "Jeremywoods@xtra.co.nz";
    		$mail_subject = "Enquiries";
    					$Name = Trim(stripslashes($_REQUEST['Name']));
    					$Email = Trim(stripslashes($_REQUEST['Email']));
    					$Company = Trim(stripslashes($_REQUEST['Company']));
    					$Address = Trim(stripslashes($_REQUEST['Address']));
    					$Phone = Trim(stripslashes($_REQUEST['Phone']));
    					$Comments = Trim(stripslashes($_REQUEST['Comments']));
    		$Body = "";
    					$Body .= $Name;
    					$Body .= $Email;
    					$Body .= $Company;
    					$Body .= $Address;
    					$Body .= $Phone;
    					$Body .= $Comments;
    									$headers  = 'MIME-Version: 1.0' . "\r\n";
    									$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     
    			// send email 
    $success = mail($mail_recipient, $mail_subject, $Body, $headers);
    	if($success==true) 
    	echo "Your mail has been Sent Successfully";
    	else
    	echo "Your mail has Not Sent Successfully";
     
    			?>

  2. #2
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I may be stating the obvious, but:
    PHP Code:
    $Body .= "Name: ".$Name."\n";
    /* etc... */ 
    ?

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Whistler, Canada
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Or, put them in an array and use foreach();

    PHP Code:
    $field = array(
      
    'Name' => Trim(stripslashes($_REQUEST['Name'])),
      
    'Email' => Trim(stripslashes($_REQUEST['Email'])),
      
    'Company' => Trim(stripslashes($_REQUEST['Company'])),
      
    'Address' => Trim(stripslashes($_REQUEST['Address'])),
      
    'Phone' => Trim(stripslashes($_REQUEST['Phone'])),
      
    'Comments' => Trim(stripslashes($_REQUEST['Comments']))
    );

    $Body "";

    foreach(
    $field as $key => $value) {
      
    $Body .= $key.": ".$value."\n";

    Cheers,
    Pepe

  4. #4
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, but what is the "\n" for?

  5. #5
    SitePoint Zealot
    Join Date
    May 2006
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do I make it so there is a new line after every item in the list?

  6. #6
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    IP-Dope's script should have you covered. Just append the "\n" string to each $value:
    PHP Code:
    $value1 "\n";
    $value2 "\n"
    The dot is what appends the newline to the values.


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
  •