frez Posted February 24, 2009 Share Posted February 24, 2009 I am definitely a .php newbie, although I am trying to do something that should be relatively simple. I have created an .html form at http://www.kontrazd.com/SDS/loaninfo.html and I have posted the form action to call up loaninfo.php, however for some reason there are errors being recognized within the .php file. I think it has to do with the list of $message parameters being called, but I don't know the fix. Can anyone please provide some insight?! Thanks! Here's the <funky> .php code: <?$propertyuse = $_POST['propertyuse'] ; $loantype = $_POST['loantype'] ; $interestrate = $_POST['interestrate'] ; $loanamount = $_POST['loanamount'] ; $propvalue = $_POST['propvalue'] ; $downpayment = $_POST['downpayment'] ; $propaddress = $_POST['propaddress'] ; $city = $_POST['city'] ; $state = $_POST['state'] ; $zipcode = $_POST['zipcode'] ; $firstname = $_POST['firstname'] ; $middleinitial = $_POST['middleinitial'] ; $lastname = $_POST['lastname'] ; $ss1 = $_POST['ss1'] ; $ss2 = $_POST['ss2'] ; $ss3 = $_POST['ss3'] ; $maritalstatus = $_POST['maritalstatus'] ; $homephone1 = $_POST['homephone1'] ; $homephone2 = $_POST['homephone2'] ; $homephone3 = $_POST['homephone3'] ; $email = $_POST['email'] ; $age = $_POST['age'] ; $yearsofschool = $_POST['yearsofschool'] ; $dobmonth = $_POST['dobmonth'] ; $dobday = $_POST['dobday'] ; $dobyear = $_POST['dobyear'] ; $coborrower = $_POST['coborrower'] ; $cofirstname = $_POST['cofirstname'] ; $comiddleinitial = $_POST['comiddleinitial'] ; $colastname = $_POST['colastname'] ; $coss1 = $_POST['coss1'] ; $coss2 = $_POST['coss2'] ; $coss3 = $_POST['coss3'] ; $comaritalstatus = $_POST['comaritalstatus'] ; $cohomephone1 = $_POST['cohomephone1'] ; $cohomephone2 = $_POST['cohomephone2'] ; $cohomephone3 = $_POST['cohomephone3'] ; $coemail = $_POST['coemail'] ; $coage = $_POST['coage'] ; $coyearsofschool = $_POST['coyearsofschool'] ; $codobmonth = $_POST['codobmonth'] ; $codobday = $_POST['codobday'] ; $codobyear = $_POST['codobyear'] ; mail ("aferrino@imstradingusa.com", "Loan Information", $message [$propertyuse, $loantype, $interestrate, $loanamount, $propvalue, $downpayment, $propaddress, $city, $state, $zipcode, $firstname, $middleinitial, $lastname, $ss1, $ss2, $ss3, $maritalstatus, $homephone1, $homephone, $homephone3, $email, $age, $yearsofschool, $dobmonth, $dobday, $dobyear, $coborrower, $cofirstname, $comiddleinitial, $colastname, $coss1, $coss2, $coss3, $comaritalstatus, $cohomephone1, $cohomephone2, $cohomephone3, $coemail, $coage, $coyearsofschool, $codobmonth, $codobday, $codobyear]) ?> Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/ Share on other sites More sharing options...
rhodesa Posted February 24, 2009 Share Posted February 24, 2009 this: $message [$propertyuse, $loantype, $interestrate, $loanamount, $propvalue, $downpayment, $propaddress, $city, $state, $zipcode, $firstname, $middleinitial, $lastname, $ss1, $ss2, $ss3, $maritalstatus, $homephone1, $homephone, $homephone3, $email, $age, $yearsofschool, $dobmonth, $dobday, $dobyear, $coborrower, $cofirstname, $comiddleinitial, $colastname, $coss1, $coss2, $coss3, $comaritalstatus, $cohomephone1, $cohomephone2, $cohomephone3, $coemail, $coage, $coyearsofschool, $codobmonth, $codobday, $codobyear] Try this for a PHP file instead: <?php $message = ""; foreach($_POST as $key=>$value){ $message .= "$key: $value\n"; } mail ("aferrino@imstradingusa.com","Loan Information", $message); ?> Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/#findComment-770498 Share on other sites More sharing options...
jonsjava Posted February 24, 2009 Share Posted February 24, 2009 a cleaned up version. <?php $propertyuse = $_POST['propertyuse'] ; $loantype = $_POST['loantype'] ; $interestrate = $_POST['interestrate'] ; $loanamount = $_POST['loanamount'] ; $propvalue = $_POST['propvalue'] ; $downpayment = $_POST['downpayment'] ; $propaddress = $_POST['propaddress'] ; $city = $_POST['city'] ; $state = $_POST['state'] ; $zipcode = $_POST['zipcode'] ; $firstname = $_POST['firstname'] ; $middleinitial = $_POST['middleinitial'] ; $lastname = $_POST['lastname'] ; $ss1 = $_POST['ss1'] ; $ss2 = $_POST['ss2'] ; $ss3 = $_POST['ss3'] ; $maritalstatus = $_POST['maritalstatus'] ; $homephone1 = $_POST['homephone1'] ; $homephone2 = $_POST['homephone2'] ; $homephone3 = $_POST['homephone3'] ; $email = $_POST['email'] ; $age = $_POST['age'] ; $yearsofschool = $_POST['yearsofschool'] ; $dobmonth = $_POST['dobmonth'] ; $dobday = $_POST['dobday'] ; $dobyear = $_POST['dobyear'] ; $coborrower = $_POST['coborrower'] ; $cofirstname = $_POST['cofirstname'] ; $comiddleinitial = $_POST['comiddleinitial'] ; $colastname = $_POST['colastname'] ; $coss1 = $_POST['coss1'] ; $coss2 = $_POST['coss2'] ; $coss3 = $_POST['coss3'] ; $comaritalstatus = $_POST['comaritalstatus'] ; $cohomephone1 = $_POST['cohomephone1'] ; $cohomephone2 = $_POST['cohomephone2'] ; $cohomephone3 = $_POST['cohomephone3'] ; $coemail = $_POST['coemail'] ; $coage = $_POST['coage'] ; $coyearsofschool = $_POST['coyearsofschool'] ; $codobmonth = $_POST['codobmonth'] ; $codobday = $_POST['codobday'] ; $codobyear = $_POST['codobyear'] ; mail ("aferrino@imstradingusa.com", "Loan Information", $propertyuse."\n".$loantype."\n".$interestrate."\n".$loanamount."\n". $propvalue."\n". $downpayment."\n". $propaddress."\n". $city.", ". $state.", ". $zipcode."\n". $firstname." ".$middleinitial." ".$lastname."\n". $ss1."-". $ss2."-".$ss3."\n". $maritalstatus."\n (".$homephone1.") ".$homephone."-".$homephone3."\n". $email."\n". $age."\n". $yearsofschool."\n". $dobmonth, $dobday, $dobyear, $coborrower."\n". $cofirstname." ".$comiddleinitial." ".$colastname."\n". $coss1."-".$coss2."-".$coss3."\n". $comaritalstatus."\n(". $cohomephone1.") ".$cohomephone2."-".$cohomephone3."\n". $coemail."\n". $coage."\n". $coyearsofschool."\n". $codobmonth."\n". $codobday."\n". $codobyear."\n"); ?> It keeps your desired formatting. Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/#findComment-770500 Share on other sites More sharing options...
Maq Posted February 24, 2009 Share Posted February 24, 2009 What are the errors...? 1) Use tags 2) Use <?php NOT , you are using what is called short tags that could cause problems if you don't have them enabled. 3) If you put this at the top of your page it may help you in the future as a debugging tool: ini_set ("display_errors", "1"); error_reporting(E_ALL); 4) You can just do something like this: foreach($_POST as $key => $value) { $message .= $value . "\n\r"; } mail ("aferrino@imstradingusa.com", "Loan Information", $message); EDIT: beaten to it, but I'll leave it up because I have a few tips in it. Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/#findComment-770502 Share on other sites More sharing options...
Stephen68 Posted February 24, 2009 Share Posted February 24, 2009 Not sure if this is a help but why not loop through the form to make your messgae? foreach ($_POST as $field=>$value) {//Start foreach loop $message .= "$field was sent as $value \r\n"; }// end of foreach loop mail($to, $subject, $message,"From: you@yourdomain.com\r\n"); Not sure if it would work but I did something like that I think a while back... hope its some help Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/#findComment-770505 Share on other sites More sharing options...
frez Posted February 24, 2009 Author Share Posted February 24, 2009 Thank you everyone! (especially 'maq' and 'rodesa') It works, but now how do I get the incoming email to appear better? It shows up as a bunch of broken lines! Very ugly Also, I know there's a way to make the message appear from the person who filled out the form. Do I put that in my parameters? Thanks again for any help...Sincerely. Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/#findComment-770600 Share on other sites More sharing options...
Maq Posted February 25, 2009 Share Posted February 25, 2009 Thank you everyone! (especially 'maq' and 'rodesa') It works, but now how do I get the incoming email to appear better? By better you mean, separated by commas or a custom format? If you have a custom format, I would do something like this: You can replace this part of your code with the excerpt below it: $propertyuse = $_POST['propertyuse'] ; $loantype = $_POST['loantype'] ; $interestrate = $_POST['interestrate'] ; $loanamount = $_POST['loanamount'] ; $propvalue = $_POST['propvalue'] ; $downpayment = $_POST['downpayment'] ; $propaddress = $_POST['propaddress'] ; $city = $_POST['city'] ; $state = $_POST['state'] ; $zipcode = $_POST['zipcode'] ; $firstname = $_POST['firstname'] ; $middleinitial = $_POST['middleinitial'] ; $lastname = $_POST['lastname'] ; $ss1 = $_POST['ss1'] ; $ss2 = $_POST['ss2'] ; $ss3 = $_POST['ss3'] ; $maritalstatus = $_POST['maritalstatus'] ; $homephone1 = $_POST['homephone1'] ; $homephone2 = $_POST['homephone2'] ; $homephone3 = $_POST['homephone3'] ; $email = $_POST['email'] ; $age = $_POST['age'] ; $yearsofschool = $_POST['yearsofschool'] ; $dobmonth = $_POST['dobmonth'] ; $dobday = $_POST['dobday'] ; $dobyear = $_POST['dobyear'] ; $coborrower = $_POST['coborrower'] ; $cofirstname = $_POST['cofirstname'] ; $comiddleinitial = $_POST['comiddleinitial'] ; $colastname = $_POST['colastname'] ; $coss1 = $_POST['coss1'] ; $coss2 = $_POST['coss2'] ; $coss3 = $_POST['coss3'] ; $comaritalstatus = $_POST['comaritalstatus'] ; $cohomephone1 = $_POST['cohomephone1'] ; $cohomephone2 = $_POST['cohomephone2'] ; $cohomephone3 = $_POST['cohomephone3'] ; $coemail = $_POST['coemail'] ; $coage = $_POST['coage'] ; $coyearsofschool = $_POST['coyearsofschool'] ; $codobmonth = $_POST['codobmonth'] ; $codobday = $_POST['codobday'] ; $codobyear = $_POST['codobyear'] ; The above code can be condensed to this: foreach($_POST as $key => $value) { //this will dynamically create all of your post variables with the name of your //POST and assign the value to the value of the POST. $$key = $value; } Now you can use the variables you assigned before and format them in your desired manner. Hope this is what you mean, let me know if it's not and provide more detail so we can work out an appropriate solution. Quote Link to comment https://forums.phpfreaks.com/topic/146759-html-calling-php-incorrectly/#findComment-770981 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.