Anotel Posted May 30, 2008 Share Posted May 30, 2008 Hi, I am pulling out my hair, I have a form that contains 3 values i want to evaluate. This is a real estate questionaire. 1. the first form data is the "bottom price they will except for me to buy it. example 150,000.00 2. The second is the field that says what they think the repair cost will be. 2. TneThird is the data they enter that says what they think the property is worth. example 200,000.00 My Question is. in the form handler, i want to see if the bottom price plus the repair cost is greater than 30% of the property worth field. example is 150000.00 + repair cost +> than 30% of 200,000.00. if it is i want to return doc1 if it isnt i want to return doc 2. Is this even possible? I hesitate to post my messy noobie code but so far it works. so here it is. The fields i am concerned about are bprice, rcost, pworth "is bprice + rcost => 30% of pworth" Thanks Scott <?php include("../cgi-bin/dbconnect.php"); ?> <?php # this is processed when the form is submitted # back on to this page (POST METHOD) if ($REQUEST_METHOD=="POST") { # double-up apostrophes $description = str_replace("'","''",$description); $sitename = str_replace("'","''",$sitename); # setup SQL statement for names $SQL = " INSERT INTO names "; $SQL = $SQL . " (fname, lname, email, hphone, wphone, cphone, address, city, state, zipcode, county, stories, bedroom, bathroom, garage, squareft, ybuilt, yowned, ccondition, rneeded, rcost, bprice, occupied, lsale, rlisted, lexpire, lprevious, csituation, pworth, taxes, ayear, takeover, questions) VALUES "; $SQL = $SQL . "('$fname','$lname','$email','$hphone','$wphone','$cphone','$address','$city','$state','$zipcode','$county','$stories','$bedroom', '$bathroom','$garage','$squareft','$ybuilt','$yowned','$ccondition','$rneeded','$rcost','$bprice','$occupied','$lsale', '$rlisted', '$lexpire','$lprevious','$csituation','$pworth','$taxes','$ayear','$takeover','$questions') "; #execute SQL statement $result = mysql_db_query($db,"$SQL",$cid); # check for error if (!$result) { echo("ERROR: " . mysql_error() . "\n$SQL\n"); } } ?> <?php # email to me. $to = "[email protected]"; $subject = "Real Estate Mail"; $message = "('$fname','$lname','$email','$hphone','$wphone','$cphone','$address','$city','$state','$zipcode', '$county','$stories','$bedroom', '$bathroom','$garage','$squareft','$ybuilt','$yowned','$ccondition','$rneeded','$rcost','$bprice','$occupied','$lsale', '$rlisted', '$lexpire','$lprevious','$csituation','$pworth','$taxes','$ayear','$takeover','$questions')"; $from = "$email"; $headers = "From: $from"; mail($to,$subject,$message,$headers); //echo "Mail Sent."; ////////////////////////////////////////////////i wish the email i get from above looked readable. ///////////////////////// ?> <?php include("contract1.php"); ?> Scott Link to comment https://forums.phpfreaks.com/topic/108027-validation-to-decide-on-what-document-to-return-to-user/ Share on other sites More sharing options...
craygo Posted May 30, 2008 Share Posted May 30, 2008 here is a function <?php function check_worth($asking, $repair, $worth){ $max = $worth * .3; $cost = $asking + $repair; $doc = $cost > $max ? "doc1" : "doc2"; return $doc; } ?> now to get which doc just use something like this $document = check_worth($bprice, $rcost, $pworth); Ray Link to comment https://forums.phpfreaks.com/topic/108027-validation-to-decide-on-what-document-to-return-to-user/#findComment-553727 Share on other sites More sharing options...
Anotel Posted June 4, 2008 Author Share Posted June 4, 2008 Thanks Ray! Link to comment https://forums.phpfreaks.com/topic/108027-validation-to-decide-on-what-document-to-return-to-user/#findComment-557497 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.