Re: HELP <> PLEASE PHP
| From: | Jas | Date: | Thu, 29 Jan 2004 16:45:06 +0000 |
| Subject: | Re: HELP <> PLEASE PHP | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-176228@lists.php.net to get a copy of this message | ||
John Nichel wrote:
Hello Patrick. Where to start, where to start.... Patrick wrote:if(empty($firstname)) { $message .= ".... } elseif(empty($lastname)) { $message .= ".... You might have to use it like this though depending on if your using GET or POST if(empty($_POST["$firstname"]) { $message .= ".... } elseif(empty($_POST["$lastname"]) { $message .= ".... Or you could just combine them all like so... if((empty($_POST["$firstname"]) || (emtpy($_POST["$lastname"])) || ... { $message = "nothing filled out... HTH JasHi, I have an situation on my hands I have a form that I am stuck using PHP for thanks to my friends choice of hosting company, I have no idea on how to setup a form in PHP other than HTML or in Flash, I need some one any one to give me some advice on this Posted layout it seems to work but not really, I managed to get it set up but for some reason when you hit Submit and an error message goes off at the top the form is Reset. Other than that I am not sure I wrote all the code correctly. Sorry About the long post.... Any advice would be great. www.mdycentrutionmtg.com/formtest.php ------------------------Formtest.php------------------------------ <?PHPChances are, all your variables here are going to be empty, since I'm sure the hosting company has register_globals turned off. You can use the global _POST array... $_POST['firstname']...$_POST['lastname']...etc, etc Also, for your 'error' messages, ahhhh, well, I would.... if ( ! isset ( $_POST['firstname'] ) ) {$message .= "Please enter your first name.<br />\n";} Get rid of the 'else's, and use ".=" when setting your message value so that if multiple items are not filled out, you won't be constantly overwriting the error message.if ($submit) { or you could use this...
if ($firstname <= "")Don't know what $yo is here...I'm guessing that you're testing something? However, 'mail()' below here is going to crap out, and give you an error. Look here.... http://us2.php.net/manual/en/function.mail.php$message = "Please enter your first name.";else if ($lastname <= "")$message = "Please enter your last name.";else if ($homephone <= "")$message = "Please enter your home phone number.";else if ($address <= "")$message = "Please enter your current home address.";else if ($city <= "")$message = "Please enter which city you currently live in.";else if ($state <= "")$message = "Please enter which state you currently live in.";else if ($zip <= "")$message = "Please enter your zip code.";else if ($monthlypayment <= "")$message = "Please enter the amount of your monthly payment.";else if ($presentemployer <= "")$message = "Please enter the name of your present employer.";else if ($rateofpay <= "")$message = "Please enter your rate of pay.";else if ($hoursperweek <= "")$message = "Please enter the average amount of hours worked in a week.";else if ($deposit <= "")$message = "Please enter the amount of your deposit.";else if ($maxpayment <= "")$message = "Please enter an average payment your comfortable with.";if ($message) echo ($yo);else { mail("theptsman@hotmail.com", "Form Results", "First Name $firstname", "Middle Initial $middleinital", "Last Name $lastname", "Social Security Number $ss", "Marital Status $maritalstatus", "Home Phone $homephone", "Address $address", "City $city", "State $state", "Zip $zip", "Apt Number $apt", "Time at address $monthsataddress Months $yearsataddress Years", "Type of residence $typeofres", "Monthly Payment $monthlypayment", "Current Employer $presentemployer", "Time with Employer $monthswithemployer Months $yearswithemployer Years", "Rate of Pay $rateofpay Dollars per $rateofpayper", "Hours per week $hoursperweek", "Work Phone $workphone", "Work History $workhistory", "Other Income $otherincome", "Deposit $deposit", "Maximum Payment $maxpayment", "Type of Loan $typeofloan", "Co First Name $cofirstname", "Co Middle Initial $comiddleinital", "Co Last Name $colastname", "Co Social Security Number $coss", "Co Marital Status $comaritalstatus", "Co Home Phone $cohomephone", "Co Address $coaddress", "Co City $cocity", "Co State $costate", "Co Zip $cozip", "Co Apt Number $coapt", "Co Time at address $comonthsataddress Months $coyearsataddress Years", "Co Type of residence $cotypeofres", "Co Monthly Payment $comonthlypayment", "Co Current Employer $copresentemployer", "Co Time with Employer $comonthswithemployer Months $coyearswithemployer Years", "Co Rate of Pay $corateofpay Dollars per $corateofpayper", "Co Hours per week $cohoursperweek", "Co Work Phone $coworkphone", "From: $firstname $lastname", "Subject: Online Form Application"); $message = "Thank You."; } } ?><snip>