efficient code

This is a discussion on "efficient code" within the PHP Forum section. This forum, and the thread "efficient code are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 5th, 2006, 18:07
Junior Member
Join Date: Jul 2006
Location: Maine
Posts: 49
Thanks: 0
Thanked 0 Times in 0 Posts
efficient code

Is there a more efficient or cleaner way to code this php mail form?

PHP: Select all

<?php

    
//PHP Mail Form Code//

    //Get vaules from contact form//
    
$companyname $_POST['companyname'];
    
$contactname $_POST['contactname'];
    
$contactphone $_POST['contactphone'];
    
$contactemail $_POST['contactemail'];
    
$contactaddress $_POST['contactaddress'];
    
$contactcity $_POST['contactcity'];
    
$contactstate $_POST['contactstate'];
    
$contactzip $_POST['contactzip'];
    
$streetaddress $_POST['streetaddress'];
    
$county $_POST['county'];
    
$city $_POST['city'];
    
$zip $_POST['zip'];
    
$singlefamily $_POST['singlefamily'];
    
$multifamily $_POST['multifamily'];
    
$condo $_POST['condo'];
    
$other $_POST['other'];
    
$sellingprice $_POST['sellingprice'];
    
$mortgageamount $_POST['mortgageamount'];
    
$valueestimate $_POST['valueestimate'];
    
$owner $_POST['owner'];
    
$homephone $_POST['homephone'];
    
$alternatephone $_POST['alternatephone'];
    
$borrowerclient $_POST['borrowerclient'];
    
$homephone2 $_POST['homephone2'];
    
$alternatephone2 $_POST['alternatephone2'];
    
$homephone3 $_POST['homephone3'];
    
$alternatephone3 $_POST['alternatephone3'];
    
$comments $_POST['comments'];
    
    
//Assign variables//
    
$companynameX "Company Name: $companyname \n";
    
$contactnameX "Contact Name: $contactname \n";
    
$contactphoneX "Contact Phone: $contactphone \n";
    
$contactemailX "Contact E-mail: $contactemail \n";
    
$contactaddressX "Contact Address: $contactaddress \n";
    
$contactcityX "Contact City: $contactcity \n";
    
$contactstateX "Contact State: $contactstate \n";
    
$contactzipX "Contact City: $contactzip \n\n";
    
$streetaddressX "Property Information\nStreet Address: $streetaddress \n";
    
$countyX "County: $county \n";
    
$cityX "City: $city \n";
    
$zipX "Zip Code: $zip \n";
    
$classX "Class: $singlefamily.$multifamily.$condo.$other \n";
    
$sellingpriceX "Selling Price: $sellingprice \n";
    
$mortgageamountX "Mortgage Amount: $mortgageamount \n";
    
$valueestimateX "Value Estimate if Refinancing: $valueestimate \n\n";
    
$ownerX "Owner Information\nOwner: $owner \n";
    
$homephoneX "Home Phone: $homephone \n";
    
$alternatephoneX "Alternate Phone: $alternatephone \n\n";
    
$borrowerclientX "Borrower/Client\nBorrower/Client: $borrowerclient \n";
    
$homephone2x "Home Phone: $homephone2 \n";
    
$alternatephone2X "Alternate Phone: $alternatephone2 \n\n";
    
$homephone3x "Real Estate Broker Information\nHome Phone: $homephone3 \n";
    
$alternatephone3X "Alternate Phone: $alternatephone3 \n";
    
$commentsX "Comments: $comments";
    
 
    
    
    
    
    
//Extend variables for email//
    
$totalmessage $companynameX.$contactnameX.$contactphoneX.$contactemailX.$contactaddressX.$contactcityX.$contactstateX.$contactzipX.$streetaddressX.$countyX.$cityX.$zipX.$classX.$sellingpriceX.$mortgageamountX.$valueestimateX.$ownerX.$homephoneX.$alternatephoneX.$borrowerclientX.$homephone2x.$alternatephone2X.$homephone3x.$alternatephone3X.$commentsX;
    

    
mail ("eric@sebagowebdesign.com""Appraisal Request Email"$totalmessage);
    echo 
"Thank you for choosing Jordan Bay Appraisal $contactname.";
    echo 
" A response will be sent to $contactemail as soon as possible.";
    
?>
Reply With Quote

  #2 (permalink)  
Old Sep 6th, 2006, 01:20
Up'n'Coming Member
Join Date: Feb 2006
Location: London
Age: 25
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Re: efficient code

Where you have 'get values from contact form', you can just use a foreach to do the same thing...

foreach($_POST as $var => $value) {}

Last edited by jimz; Sep 6th, 2006 at 01:25.
Reply With Quote
Reply

Tags
efficient, code

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
code behind code doesnt work skat ASP.NET Forum 4 Feb 18th, 2008 10:05
[SOLVED] Can this be made more efficient AdRock Databases 0 Nov 19th, 2007 23:05
live search code and styleswitcher code hebel JavaScript Forum 0 May 12th, 2007 06:16
Can somebody give me the code to hide the source code? renren JavaScript Forum 7 Mar 7th, 2006 12:27
seeking more efficient code jswebdev PHP Forum 4 Oct 21st, 2005 16:22


All times are GMT. The time now is 08:18.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43