Jump to content

PHP Form Help


defpdp

Recommended Posts

OK, I have a question.

 

I have a pretty large form and I am trying to send results via email to the clients.

 

My question is. If there is no data in a field how do I make it NOT appear in the email results so I don't get field names with empty values?

 

Also, know of anyway to display the results in a eye friendly manner?

 

Below is the code

 

Thank you for your help.

<?php


// Receiving variables
@$Name = addslashes($_POST['Name']);
@$Date = addslashes($_POST['Date']);
@$DOB = addslashes($_POST['DOB']);
@$Age = addslashes($_POST['Age']);
@$Weight = addslashes($_POST['Weight']);
@$Problem1 = addslashes($_POST['Problem1']);
@$Problem2 = addslashes($_POST['Problem2']);
@$Problem3 = addslashes($_POST['Problem3']);
@$CurrentMed1 = addslashes($_POST['CurrentMed1']);
@$CurrentMed2 = addslashes($_POST['CurrentMed2']);
@$CurrentMed11 = addslashes($_POST['CurrentMed11']);
@$CurrentMed4 = addslashes($_POST['CurrentMed4']);
@$CurrentMed5 = addslashes($_POST['CurrentMed5']);
@$CurrentMed6 = addslashes($_POST['CurrentMed6']);
@$CurrentMed7 = addslashes($_POST['CurrentMed7']);
@$CurrentMed8 = addslashes($_POST['CurrentMed8']);
@$CurrentMed9 = addslashes($_POST['CurrentMed9']);
@$CurrentMed10 = addslashes($_POST['CurrentMed10']);
@$MedicationAllergies1 = addslashes($_POST['MedicationAllergies1']);
@$MedicationAllergies2 = addslashes($_POST['MedicationAllergies2']);
@$CurrentMed3 = addslashes($_POST['CurrentMed3']);
@$MedicationAllergies4 = addslashes($_POST['MedicationAllergies4']);
@$Anxiety_nervousness = addslashes($_POST['Anxiety_nervousness']);
@$Paranoid = addslashes($_POST['Paranoid']);
@$Depression1 = addslashes($_POST['Depression1']);
@$ObsessiveThoughts = addslashes($_POST['ObsessiveThoughts']);
@$MoodSwings1 = addslashes($_POST['MoodSwings1']);
@$ObsessiveHabits = addslashes($_POST['ObsessiveHabits']);
@$Insomnia_Oversleeping = addslashes($_POST['Insomnia_Oversleeping']);
@$LowEnergy = addslashes($_POST['LowEnergy']);
@$ProblemsConcentrating = addslashes($_POST['ProblemsConcentrating']);
@$HopelessFeelings = addslashes($_POST['HopelessFeelings']);
@$HearingVoices = addslashes($_POST['HearingVoices']);
@$ThoughtsAboutDeath = addslashes($_POST['ThoughtsAboutDeath']);
@$Visions = addslashes($_POST['Visions']);
@$Suicide = addslashes($_POST['Suicide']);
@$Year1 = addslashes($_POST['Year1']);
@$Reasonforvisit1 = addslashes($_POST['Reasonforvisit1']);
@$Year2 = addslashes($_POST['Year2']);
@$ReasonforVisit2 = addslashes($_POST['ReasonforVisit2']);
@$Year3 = addslashes($_POST['Year3']);
@$Reasonforvisit3 = addslashes($_POST['Reasonforvisit3']);
@$AnxietyNervousness = addslashes($_POST['AnxietyNervousness']);
@$Alcoholism = addslashes($_POST['Alcoholism']);
@$Depression = addslashes($_POST['Depression']);
@$DrugAddiction = addslashes($_POST['DrugAddiction']);
@$MoodSwings = addslashes($_POST['MoodSwings']);
@$AttentionDeficit = addslashes($_POST['AttentionDeficit']);
@$Schizophrenia = addslashes($_POST['Schizophrenia']);
@$ObsessiveCompulsiveDisorder = addslashes($_POST['ObsessiveCompulsiveDisorder']);
@$Cigarettes_Yes = addslashes($_POST['Cigarettes_Yes']);
@$Cigarettes_No = addslashes($_POST['Cigarettes_No']);
@$Cigarettes_Amount_Used = addslashes($_POST['Cigarettes_Amount_Used']);
@$Cigarettes_LastUsed = addslashes($_POST['Cigarettes_LastUsed']);
@$Alcohol_Yes = addslashes($_POST['Alcohol_Yes']);
@$Alcohol_No = addslashes($_POST['Alcohol_No']);
@$Alcohol_Amount_Used = addslashes($_POST['Alcohol_Amount_Used']);
@$Alcohol_LastUsed = addslashes($_POST['Alcohol_LastUsed']);
@$Opiates_Yes = addslashes($_POST['Opiates_Yes']);
@$Opiates_No = addslashes($_POST['Opiates_No']);
@$Opiates_Amount_Used = addslashes($_POST['Opiates_Amount_Used']);
@$Opiates_LastUsed = addslashes($_POST['Opiates_LastUsed']);
@$Cocaine_Yes = addslashes($_POST['Cocaine_Yes']);
@$Cocaine_No = addslashes($_POST['Cocaine_No']);
@$Cocaine_Amount_Used = addslashes($_POST['Cocaine_Amount_Used']);
@$Cocaine_LastUsed = addslashes($_POST['Cocaine_LastUsed']);
@$Marijuana_Yes = addslashes($_POST['Marijuana_Yes']);
@$Marijuana_No = addslashes($_POST['Marijuana_No']);
@$Marijuana_Amount_Used = addslashes($_POST['Marijuana_Amount_Used']);
@$Marijuana_LastUsed = addslashes($_POST['Marijuana_LastUsed']);
@$Speed_Yes = addslashes($_POST['Speed_Yes']);
@$Speed_No = addslashes($_POST['Speed_No']);
@$Speed_Amount_Used = addslashes($_POST['Speed_Amount_Used']);
@$Speed_LastUsed = addslashes($_POST['Speed_LastUsed']);
@$Sedatives_Yes = addslashes($_POST['Sedatives_Yes']);
@$Sedatives_No = addslashes($_POST['Sedatives_No']);
@$Sedatives_Amount_Used = addslashes($_POST['Sedatives_Amount_Used']);
@$Sedatives_LastUsed = addslashes($_POST['Sedatives_LastUsed']);
@$Other_Yes1 = addslashes($_POST['Other_Yes1']);
@$Other_No1 = addslashes($_POST['Other_No1']);
@$Other_Amount_Used1 = addslashes($_POST['Other_Amount_Used1']);
@$Other_LastUsed1 = addslashes($_POST['Other_LastUsed1']);
@$Other_Yes = addslashes($_POST['Other_Yes']);
@$Other_No = addslashes($_POST['Other_No']);
@$Other_Amount_Used = addslashes($_POST['Other_Amount_Used']);
@$Other_LastUsed = addslashes($_POST['Other_LastUsed']);
@$Nose_EyesRunning = addslashes($_POST['Nose_EyesRunning']);
@$Nausea = addslashes($_POST['Nausea']);
@$Sneezing = addslashes($_POST['Sneezing']);
@$Vomiting = addslashes($_POST['Vomiting']);
@$Sweating = addslashes($_POST['Sweating']);
@$Diarrhea = addslashes($_POST['Diarrhea']);
@$Chills_HotFlashes = addslashes($_POST['Chills_HotFlashes']);
@$Problems_Sleeping = addslashes($_POST['Problems_Sleeping']);
@$Anxiety = addslashes($_POST['Anxiety']);
@$Headache = addslashes($_POST['Headache']);
@$Tremors = addslashes($_POST['Tremors']);
@$Hallucinations = addslashes($_POST['Hallucinations']);
@$MuscleJointAches = addslashes($_POST['MuscleJointAches']);
@$Other = addslashes($_POST['Other']);
@$Other_Withdrawal_Symptoms = addslashes($_POST['Other_Withdrawal_Symptoms']);
@$CurrentMedicalProblems1 = addslashes($_POST['CurrentMedicalProblems1']);
@$CurrentMedicalProblems2 = addslashes($_POST['CurrentMedicalProblems2']);
@$CurrentMedicalProblems3 = addslashes($_POST['CurrentMedicalProblems3']);
@$Other_Withdrawal_Symptoms4 = addslashes($_POST['Other_Withdrawal_Symptoms4']);
@$CurrentMedicalProblems5 = addslashes($_POST['CurrentMedicalProblems5']);
@$CurrentMedicalProblems6 = addslashes($_POST['CurrentMedicalProblems6']);
@$CurrentMedicalProblems7 = addslashes($_POST['CurrentMedicalProblems7']);
@$CurrentMedicalProblems8 = addslashes($_POST['CurrentMedicalProblems8']);
@$CurrentMedicalProblems9 = addslashes($_POST['CurrentMedicalProblems9']);
@$CurrentMedicalProblems10 = addslashes($_POST['CurrentMedicalProblems10']);
@$DateOfLastPeriod = addslashes($_POST['DateOfLastPeriod']);
@$BirthControl_Yes = addslashes($_POST['BirthControl_Yes']);
@$BirthControl_No = addslashes($_POST['BirthControl_No']);
@$TypeofBirthControl = addslashes($_POST['TypeofBirthControl']);

// Validation
if (strlen($Name) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>");
}

if (strlen($Date) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid date</font></p>");
}

if (strlen($DOB) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid dob</font></p>");
}

if (strlen($Problem1) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid problem1</font></p>");
}

//Sending Email to form owner
$pfw_header = "From: $Name\n"
  . "Reply-To: $Name\n";
$pfw_subject = "WCBM - Health Questionnaire";
$pfw_email_to = "pploesser@gmail.com";
$pfw_message = "Name: $Name\n"
. "Date: $Date\n"
. "DOB: $DOB\n"
. "Age: $Age\n"
. "Weight: $Weight\n"
. "\n"
. "Reason for the visit:\n"
. "Problem/Symptom $1: Problem1\n"
. "Problem/Symptom $2: Problem2\n"
. "Problem/Symptom $3: Problem3\n"
. "\n"
. "Current Medication (and Doses)\n"
. "Current Medication $1: CurrentMed1\n"
. "Current Medication $2: CurrentMed2\n"
. "Current Medication $3: CurrentMed11\n"
. "Current Medication $4: CurrentMed4\n"
. "Current Medication $5: CurrentMed5\n"
. "Current Medication $6: CurrentMed6\n"
. "Current Medication $7: CurrentMed7\n"
. "Current Medication $8: CurrentMed8\n"
. "Current Medication $9: CurrentMed9\n"
. "Current Medication $10: CurrentMed10\n"
. "\n"
. "Medication Allergies\n"
. "Medication Allergies  $1: MedicationAllergies1\n"
. "Medication Allergies  $2: MedicationAllergies2\n"
. "Medication Allergies  $3: CurrentMed3\n"
. "Medication Allergies  $4: MedicationAllergies4\n"
. "\n"
. "Past Psychiatric History\n"
. "\n"
. "Anxiety / Nervousness:  $Anxiety_nervousness\n"
. "Paranoid Feeliongs: $Paranoid\n"
. "Depression : $Depression1\n"
. "Obsessive Thoughts: $ObsessiveThoughts\n"
. "Mood Swings: $MoodSwings1\n"
. "Obsessive Habits: $ObsessiveHabits\n"
. "Insomnia / Oversleeping: $Insomnia_Oversleeping\n"
. "Low Energy: $LowEnergy\n"
. "Problems Concentrating: $ProblemsConcentrating\n"
. "Hopeless Feelings: $HopelessFeelings\n"
. "Hearing Voices: $HearingVoices\n"
. "Thoughts About Death: $ThoughtsAboutDeath\n"
. "Visions: $Visions\n"
. "Suicide: $Suicide\n"
. "\n"
. "Past Hospitalizations\n"
. "\n"
. "Year: $Year1\n"
. "Reason for the hospital visit: $Reasonforvisit1\n"
. "Year: $Year2\n"
. "Reason for the hospital visit: $ReasonforVisit2\n"
. "Year: $Year3\n"
. "Reason for the hospital visit: $Reasonforvisit3\n"
. "\n"
. "Family History\n"
. "\n"
. "Anxiety / Nervousness: $AnxietyNervousness\n"
. "Alcoholism: $Alcoholism\n"
. "Depression: $Depression\n"
. "Drug Addiction: $DrugAddiction\n"
. "Mood Swings: $MoodSwings\n"
. "Attention Deficit: $AttentionDeficit\n"
. "Schizophrenia: $Schizophrenia\n"
. "Obsessive Compulsive Disorder: $ObsessiveCompulsiveDisorder\n"
. "Cigarettes: $Cigarettes_Yes\n"
. "Cigarettes No: $Cigarettes_No\n"
. "Cigarettes_Amount_Used: $Cigarettes_Amount_Used\n"
. "Cigarettes_LastUsed: $Cigarettes_LastUsed\n"
. "Alcohol_Yes: $Alcohol_Yes\n"
. "Alcohol_No: $Alcohol_No\n"
. "Alcohol_Amount_Used: $Alcohol_Amount_Used\n"
. "Alcohol_LastUsed: $Alcohol_LastUsed\n"
. "Opiates_Yes: $Opiates_Yes\n"
. "Opiates_No: $Opiates_No\n"
. "Opiates_Amount_Used: $Opiates_Amount_Used\n"
. "Opiates_LastUsed: $Opiates_LastUsed\n"
. "Cocaine_Yes: $Cocaine_Yes\n"
. "Cocaine_No: $Cocaine_No\n"
. "Cocaine_Amount_Used: $Cocaine_Amount_Used\n"
. "Cocaine_LastUsed: $Cocaine_LastUsed\n"
. "Marijuana_Yes: $Marijuana_Yes\n"
. "Marijuana_No: $Marijuana_No\n"
. "Marijuana_Amount_Used: $Marijuana_Amount_Used\n"
. "Marijuana_LastUsed: $Marijuana_LastUsed\n"
. "Speed_Yes: $Speed_Yes\n"
. "Speed_No: $Speed_No\n"
. "Speed_Amount_Used: $Speed_Amount_Used\n"
. "Speed_LastUsed: $Speed_LastUsed\n"
. "Sedatives_Yes: $Sedatives_Yes\n"
. "Sedatives_No: $Sedatives_No\n"
. "Sedatives_Amount_Used: $Sedatives_Amount_Used\n"
. "Sedatives_LastUsed: $Sedatives_LastUsed\n"
. "Other_Yes1: $Other_Yes1\n"
. "Other_No1: $Other_No1\n"
. "Other_Amount_Used1: $Other_Amount_Used1\n"
. "Other_LastUsed1: $Other_LastUsed1\n"
. "Other_Yes: $Other_Yes\n"
. "Other_No: $Other_No\n"
. "Other_Amount_Used: $Other_Amount_Used\n"
. "Other_LastUsed: $Other_LastUsed\n"
. "Nose_EyesRunning: $Nose_EyesRunning\n"
. "Nausea: $Nausea\n"
. "Sneezing: $Sneezing\n"
. "Vomiting: $Vomiting\n"
. "Sweating: $Sweating\n"
. "Diarrhea: $Diarrhea\n"
. "Chills_HotFlashes: $Chills_HotFlashes\n"
. "Problems_Sleeping: $Problems_Sleeping\n"
. "Anxiety: $Anxiety\n"
. "Headache: $Headache\n"
. "Tremors: $Tremors\n"
. "Hallucinations: $Hallucinations\n"
. "MuscleJointAches: $MuscleJointAches\n"
. "Other: $Other\n"
. "Other_Withdrawal_Symptoms: $Other_Withdrawal_Symptoms\n"
. "CurrentMedicalProblems1: $CurrentMedicalProblems1\n"
. "CurrentMedicalProblems2: $CurrentMedicalProblems2\n"
. "CurrentMedicalProblems3: $CurrentMedicalProblems3\n"
. "Other_Withdrawal_Symptoms4: $Other_Withdrawal_Symptoms4\n"
. "CurrentMedicalProblems5: $CurrentMedicalProblems5\n"
. "CurrentMedicalProblems6: $CurrentMedicalProblems6\n"
. "CurrentMedicalProblems7: $CurrentMedicalProblems7\n"
. "CurrentMedicalProblems8: $CurrentMedicalProblems8\n"
. "CurrentMedicalProblems9: $CurrentMedicalProblems9\n"
. "CurrentMedicalProblems10: $CurrentMedicalProblems10\n"
. "\n"
. "For women only:\n"
. "\n"
. "DateOfLastPeriod: $DateOfLastPeriod\n"
. "BirthControl_Yes: $BirthControl_Yes\n"
. "BirthControl_No: $BirthControl_No\n"
. "TypeofBirthControl: $TypeofBirthControl\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: pploesser@gmail.com\n"
  . "Reply-To: pploesser@gmail.com\n";
$pfw_subject = "test";
$pfw_email_to = "$Name";
$pfw_message = "test";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Test</font></p>");
?>

Link to comment
Share on other sites

<?php
if (!empty($variable)) {
   ..add it to the e-mail..
} else {
   ..leave it..
}
?>

 

P.S. Wouldn't it be better to separate the form into steps so you don't have to fill in and process those one million fields or create some sort of categories where the customer selects his category and get's a form specialized for his kind of problem.

Link to comment
Share on other sites

Well, since the field names are the same as the ones in the email list, you can just create a function (or better yet a class) that checks if the field is empty, and if not, don't add it. You can keep track of the email in a variable. A class is better than a function IMO.

 

ignace's post is correct as well. The only problem is it's not efficient. Very wordy, but it gets the job done.

 

empty($e) is better than strlen($e) == 0.

 

Edit: I'm sure you can loop through all the $_POST instead of checking each individually.

Link to comment
Share on other sites

Something like:

 

<?php
function createMailBody ($postdata, $requiredfields) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$mail_body = createMailBody($_POST);

// call to mail function
?>

Link to comment
Share on other sites

I'm new to PHP. so would I just add the top part to my existing script?

Well I don't know how many $_POST data you have, but if you're using them all in the email, then just use what I wrote with a bit of modification of course.

 

Actually there's an error in my script. Use this:

<?php
function createMailBody ($postdata = array(), $requiredfields = array()) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$mail_body = createMailBody($_POST, $requiredfields);

// call to mail function
?>

Link to comment
Share on other sites

Would it look like this?

 

<?php

function createMailBody ($postdata = array(), $requiredfields = array()) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$mail_body = createMailBody($_POST, $requiredfields);

// Receiving variables
@$Name = addslashes($_POST['Name']);
@$Date = addslashes($_POST['Date']);
@$DOB = addslashes($_POST['DOB']);
@$Age = addslashes($_POST['Age']);
@$Weight = addslashes($_POST['Weight']);
@$Problem1 = addslashes($_POST['Problem1']);
@$Problem2 = addslashes($_POST['Problem2']);
@$Problem3 = addslashes($_POST['Problem3']);
@$CurrentMed1 = addslashes($_POST['CurrentMed1']);
@$CurrentMed2 = addslashes($_POST['CurrentMed2']);
@$CurrentMed11 = addslashes($_POST['CurrentMed11']);
@$CurrentMed4 = addslashes($_POST['CurrentMed4']);
@$CurrentMed5 = addslashes($_POST['CurrentMed5']);
@$CurrentMed6 = addslashes($_POST['CurrentMed6']);
@$CurrentMed7 = addslashes($_POST['CurrentMed7']);
@$CurrentMed8 = addslashes($_POST['CurrentMed8']);
@$CurrentMed9 = addslashes($_POST['CurrentMed9']);
@$CurrentMed10 = addslashes($_POST['CurrentMed10']);
@$MedicationAllergies1 = addslashes($_POST['MedicationAllergies1']);
@$MedicationAllergies2 = addslashes($_POST['MedicationAllergies2']);
@$CurrentMed3 = addslashes($_POST['CurrentMed3']);
@$MedicationAllergies4 = addslashes($_POST['MedicationAllergies4']);
@$Anxiety_nervousness = addslashes($_POST['Anxiety_nervousness']);
@$Paranoid = addslashes($_POST['Paranoid']);
@$Depression1 = addslashes($_POST['Depression1']);
@$ObsessiveThoughts = addslashes($_POST['ObsessiveThoughts']);
@$MoodSwings1 = addslashes($_POST['MoodSwings1']);
@$ObsessiveHabits = addslashes($_POST['ObsessiveHabits']);
@$Insomnia_Oversleeping = addslashes($_POST['Insomnia_Oversleeping']);
@$LowEnergy = addslashes($_POST['LowEnergy']);
@$ProblemsConcentrating = addslashes($_POST['ProblemsConcentrating']);
@$HopelessFeelings = addslashes($_POST['HopelessFeelings']);
@$HearingVoices = addslashes($_POST['HearingVoices']);
@$ThoughtsAboutDeath = addslashes($_POST['ThoughtsAboutDeath']);
@$Visions = addslashes($_POST['Visions']);
@$Suicide = addslashes($_POST['Suicide']);
@$Year1 = addslashes($_POST['Year1']);
@$Reasonforvisit1 = addslashes($_POST['Reasonforvisit1']);
@$Year2 = addslashes($_POST['Year2']);
@$ReasonforVisit2 = addslashes($_POST['ReasonforVisit2']);
@$Year3 = addslashes($_POST['Year3']);
@$Reasonforvisit3 = addslashes($_POST['Reasonforvisit3']);
@$AnxietyNervousness = addslashes($_POST['AnxietyNervousness']);
@$Alcoholism = addslashes($_POST['Alcoholism']);
@$Depression = addslashes($_POST['Depression']);
@$DrugAddiction = addslashes($_POST['DrugAddiction']);
@$MoodSwings = addslashes($_POST['MoodSwings']);
@$AttentionDeficit = addslashes($_POST['AttentionDeficit']);
@$Schizophrenia = addslashes($_POST['Schizophrenia']);
@$ObsessiveCompulsiveDisorder = addslashes($_POST['ObsessiveCompulsiveDisorder']);
@$Cigarettes_Yes = addslashes($_POST['Cigarettes_Yes']);
@$Cigarettes_No = addslashes($_POST['Cigarettes_No']);
@$Cigarettes_Amount_Used = addslashes($_POST['Cigarettes_Amount_Used']);
@$Cigarettes_LastUsed = addslashes($_POST['Cigarettes_LastUsed']);
@$Alcohol_Yes = addslashes($_POST['Alcohol_Yes']);
@$Alcohol_No = addslashes($_POST['Alcohol_No']);
@$Alcohol_Amount_Used = addslashes($_POST['Alcohol_Amount_Used']);
@$Alcohol_LastUsed = addslashes($_POST['Alcohol_LastUsed']);
@$Opiates_Yes = addslashes($_POST['Opiates_Yes']);
@$Opiates_No = addslashes($_POST['Opiates_No']);
@$Opiates_Amount_Used = addslashes($_POST['Opiates_Amount_Used']);
@$Opiates_LastUsed = addslashes($_POST['Opiates_LastUsed']);
@$Cocaine_Yes = addslashes($_POST['Cocaine_Yes']);
@$Cocaine_No = addslashes($_POST['Cocaine_No']);
@$Cocaine_Amount_Used = addslashes($_POST['Cocaine_Amount_Used']);
@$Cocaine_LastUsed = addslashes($_POST['Cocaine_LastUsed']);
@$Marijuana_Yes = addslashes($_POST['Marijuana_Yes']);
@$Marijuana_No = addslashes($_POST['Marijuana_No']);
@$Marijuana_Amount_Used = addslashes($_POST['Marijuana_Amount_Used']);
@$Marijuana_LastUsed = addslashes($_POST['Marijuana_LastUsed']);
@$Speed_Yes = addslashes($_POST['Speed_Yes']);
@$Speed_No = addslashes($_POST['Speed_No']);
@$Speed_Amount_Used = addslashes($_POST['Speed_Amount_Used']);
@$Speed_LastUsed = addslashes($_POST['Speed_LastUsed']);
@$Sedatives_Yes = addslashes($_POST['Sedatives_Yes']);
@$Sedatives_No = addslashes($_POST['Sedatives_No']);
@$Sedatives_Amount_Used = addslashes($_POST['Sedatives_Amount_Used']);
@$Sedatives_LastUsed = addslashes($_POST['Sedatives_LastUsed']);
@$Other_Yes1 = addslashes($_POST['Other_Yes1']);
@$Other_No1 = addslashes($_POST['Other_No1']);
@$Other_Amount_Used1 = addslashes($_POST['Other_Amount_Used1']);
@$Other_LastUsed1 = addslashes($_POST['Other_LastUsed1']);
@$Other_Yes = addslashes($_POST['Other_Yes']);
@$Other_No = addslashes($_POST['Other_No']);
@$Other_Amount_Used = addslashes($_POST['Other_Amount_Used']);
@$Other_LastUsed = addslashes($_POST['Other_LastUsed']);
@$Nose_EyesRunning = addslashes($_POST['Nose_EyesRunning']);
@$Nausea = addslashes($_POST['Nausea']);
@$Sneezing = addslashes($_POST['Sneezing']);
@$Vomiting = addslashes($_POST['Vomiting']);
@$Sweating = addslashes($_POST['Sweating']);
@$Diarrhea = addslashes($_POST['Diarrhea']);
@$Chills_HotFlashes = addslashes($_POST['Chills_HotFlashes']);
@$Problems_Sleeping = addslashes($_POST['Problems_Sleeping']);
@$Anxiety = addslashes($_POST['Anxiety']);
@$Headache = addslashes($_POST['Headache']);
@$Tremors = addslashes($_POST['Tremors']);
@$Hallucinations = addslashes($_POST['Hallucinations']);
@$MuscleJointAches = addslashes($_POST['MuscleJointAches']);
@$Other = addslashes($_POST['Other']);
@$Other_Withdrawal_Symptoms = addslashes($_POST['Other_Withdrawal_Symptoms']);
@$CurrentMedicalProblems1 = addslashes($_POST['CurrentMedicalProblems1']);
@$CurrentMedicalProblems2 = addslashes($_POST['CurrentMedicalProblems2']);
@$CurrentMedicalProblems3 = addslashes($_POST['CurrentMedicalProblems3']);
@$Other_Withdrawal_Symptoms4 = addslashes($_POST['Other_Withdrawal_Symptoms4']);
@$CurrentMedicalProblems5 = addslashes($_POST['CurrentMedicalProblems5']);
@$CurrentMedicalProblems6 = addslashes($_POST['CurrentMedicalProblems6']);
@$CurrentMedicalProblems7 = addslashes($_POST['CurrentMedicalProblems7']);
@$CurrentMedicalProblems8 = addslashes($_POST['CurrentMedicalProblems8']);
@$CurrentMedicalProblems9 = addslashes($_POST['CurrentMedicalProblems9']);
@$CurrentMedicalProblems10 = addslashes($_POST['CurrentMedicalProblems10']);
@$DateOfLastPeriod = addslashes($_POST['DateOfLastPeriod']);
@$BirthControl_Yes = addslashes($_POST['BirthControl_Yes']);
@$BirthControl_No = addslashes($_POST['BirthControl_No']);
@$TypeofBirthControl = addslashes($_POST['TypeofBirthControl']);

//Sending Email to form owner
$pfw_header = "From: $Name\n"
  . "Reply-To: $Name\n";
$pfw_subject = "WCBM - Health Questionnaire";
$pfw_email_to = "pploesser@gmail.com";
$pfw_message = "Name: $Name\n"
. "Date: $Date\n"
. "DOB: $DOB\n"
. "Age: $Age\n"
. "Weight: $Weight\n"
. "\n"
. "Reason for the visit:\n"
. "Problem/Symptom $1: Problem1\n"
. "Problem/Symptom $2: Problem2\n"
. "Problem/Symptom $3: Problem3\n"
. "\n"
. "Current Medication (and Doses)\n"
. "Current Medication $1: CurrentMed1\n"
. "Current Medication $2: CurrentMed2\n"
. "Current Medication $3: CurrentMed11\n"
. "Current Medication $4: CurrentMed4\n"
. "Current Medication $5: CurrentMed5\n"
. "Current Medication $6: CurrentMed6\n"
. "Current Medication $7: CurrentMed7\n"
. "Current Medication $8: CurrentMed8\n"
. "Current Medication $9: CurrentMed9\n"
. "Current Medication $10: CurrentMed10\n"
. "\n"
. "Medication Allergies\n"
. "Medication Allergies  $1: MedicationAllergies1\n"
. "Medication Allergies  $2: MedicationAllergies2\n"
. "Medication Allergies  $3: CurrentMed3\n"
. "Medication Allergies  $4: MedicationAllergies4\n"
. "\n"
. "Past Psychiatric History\n"
. "\n"
. "Anxiety / Nervousness:  $Anxiety_nervousness\n"
. "Paranoid Feeliongs: $Paranoid\n"
. "Depression : $Depression1\n"
. "Obsessive Thoughts: $ObsessiveThoughts\n"
. "Mood Swings: $MoodSwings1\n"
. "Obsessive Habits: $ObsessiveHabits\n"
. "Insomnia / Oversleeping: $Insomnia_Oversleeping\n"
. "Low Energy: $LowEnergy\n"
. "Problems Concentrating: $ProblemsConcentrating\n"
. "Hopeless Feelings: $HopelessFeelings\n"
. "Hearing Voices: $HearingVoices\n"
. "Thoughts About Death: $ThoughtsAboutDeath\n"
. "Visions: $Visions\n"
. "Suicide: $Suicide\n"
. "\n"
. "Past Hospitalizations\n"
. "\n"
. "Year: $Year1\n"
. "Reason for the hospital visit: $Reasonforvisit1\n"
. "Year: $Year2\n"
. "Reason for the hospital visit: $ReasonforVisit2\n"
. "Year: $Year3\n"
. "Reason for the hospital visit: $Reasonforvisit3\n"
. "\n"
. "Family History\n"
. "\n"
. "Anxiety / Nervousness: $AnxietyNervousness\n"
. "Alcoholism: $Alcoholism\n"
. "Depression: $Depression\n"
. "Drug Addiction: $DrugAddiction\n"
. "Mood Swings: $MoodSwings\n"
. "Attention Deficit: $AttentionDeficit\n"
. "Schizophrenia: $Schizophrenia\n"
. "Obsessive Compulsive Disorder: $ObsessiveCompulsiveDisorder\n"
. "Cigarettes: $Cigarettes_Yes\n"
. "Cigarettes No: $Cigarettes_No\n"
. "Cigarettes_Amount_Used: $Cigarettes_Amount_Used\n"
. "Cigarettes_LastUsed: $Cigarettes_LastUsed\n"
. "Alcohol_Yes: $Alcohol_Yes\n"
. "Alcohol_No: $Alcohol_No\n"
. "Alcohol_Amount_Used: $Alcohol_Amount_Used\n"
. "Alcohol_LastUsed: $Alcohol_LastUsed\n"
. "Opiates_Yes: $Opiates_Yes\n"
. "Opiates_No: $Opiates_No\n"
. "Opiates_Amount_Used: $Opiates_Amount_Used\n"
. "Opiates_LastUsed: $Opiates_LastUsed\n"
. "Cocaine_Yes: $Cocaine_Yes\n"
. "Cocaine_No: $Cocaine_No\n"
. "Cocaine_Amount_Used: $Cocaine_Amount_Used\n"
. "Cocaine_LastUsed: $Cocaine_LastUsed\n"
. "Marijuana_Yes: $Marijuana_Yes\n"
. "Marijuana_No: $Marijuana_No\n"
. "Marijuana_Amount_Used: $Marijuana_Amount_Used\n"
. "Marijuana_LastUsed: $Marijuana_LastUsed\n"
. "Speed_Yes: $Speed_Yes\n"
. "Speed_No: $Speed_No\n"
. "Speed_Amount_Used: $Speed_Amount_Used\n"
. "Speed_LastUsed: $Speed_LastUsed\n"
. "Sedatives_Yes: $Sedatives_Yes\n"
. "Sedatives_No: $Sedatives_No\n"
. "Sedatives_Amount_Used: $Sedatives_Amount_Used\n"
. "Sedatives_LastUsed: $Sedatives_LastUsed\n"
. "Other_Yes1: $Other_Yes1\n"
. "Other_No1: $Other_No1\n"
. "Other_Amount_Used1: $Other_Amount_Used1\n"
. "Other_LastUsed1: $Other_LastUsed1\n"
. "Other_Yes: $Other_Yes\n"
. "Other_No: $Other_No\n"
. "Other_Amount_Used: $Other_Amount_Used\n"
. "Other_LastUsed: $Other_LastUsed\n"
. "Nose_EyesRunning: $Nose_EyesRunning\n"
. "Nausea: $Nausea\n"
. "Sneezing: $Sneezing\n"
. "Vomiting: $Vomiting\n"
. "Sweating: $Sweating\n"
. "Diarrhea: $Diarrhea\n"
. "Chills_HotFlashes: $Chills_HotFlashes\n"
. "Problems_Sleeping: $Problems_Sleeping\n"
. "Anxiety: $Anxiety\n"
. "Headache: $Headache\n"
. "Tremors: $Tremors\n"
. "Hallucinations: $Hallucinations\n"
. "MuscleJointAches: $MuscleJointAches\n"
. "Other: $Other\n"
. "Other_Withdrawal_Symptoms: $Other_Withdrawal_Symptoms\n"
. "CurrentMedicalProblems1: $CurrentMedicalProblems1\n"
. "CurrentMedicalProblems2: $CurrentMedicalProblems2\n"
. "CurrentMedicalProblems3: $CurrentMedicalProblems3\n"
. "Other_Withdrawal_Symptoms4: $Other_Withdrawal_Symptoms4\n"
. "CurrentMedicalProblems5: $CurrentMedicalProblems5\n"
. "CurrentMedicalProblems6: $CurrentMedicalProblems6\n"
. "CurrentMedicalProblems7: $CurrentMedicalProblems7\n"
. "CurrentMedicalProblems8: $CurrentMedicalProblems8\n"
. "CurrentMedicalProblems9: $CurrentMedicalProblems9\n"
. "CurrentMedicalProblems10: $CurrentMedicalProblems10\n"
. "\n"
. "For women only:\n"
. "\n"
. "DateOfLastPeriod: $DateOfLastPeriod\n"
. "BirthControl_Yes: $BirthControl_Yes\n"
. "BirthControl_No: $BirthControl_No\n"
. "TypeofBirthControl: $TypeofBirthControl\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: pploesser@gmail.com\n"
  . "Reply-To: pploesser@gmail.com\n";
$pfw_subject = "test";
$pfw_email_to = "$Name";
$pfw_message = "test";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Test</font></p>");
?>

Link to comment
Share on other sites

Well, no, not exactly. You don't need all your list of retrieving variables because I took care of that, though the e-mail is a little off. Comment out your list of retrieving variables. Don't delete them. Then comment out the entire block of $pfw_message. Finally, change where I have $mail_body to $pfw_message, just to have the variable names right.

 

Lastly, fill in my $requiredfields array.

if (strlen($Name) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>");
}

if (strlen($Date) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid date</font></p>");
}

if (strlen($DOB) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid dob</font></p>");
}

if (strlen($Problem1) == 0 )
{
die("<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid problem1</font></p>");
}

That's your validation, right? Well I did the first one for you, so you need to do the other ones.

Link to comment
Share on other sites

Ken,

 

Thank you very much for your help, I think I am missing something, as the page is not coming up correctly now. Sorry for the trouble I am a newb!!

 

<?php

function createMailBody ($postdata, $requiredfields) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}


// Receiving variables
'@$Name = addslashes($_POST['Name']);
'@$Date = addslashes($_POST['Date']);
'@$DOB = addslashes($_POST['DOB']);
'@$Age = addslashes($_POST['Age']);
'@$Weight = addslashes($_POST['Weight']);
'@$Problem1 = addslashes($_POST['Problem1']);
'@$Problem2 = addslashes($_POST['Problem2']);
'@$Problem3 = addslashes($_POST['Problem3']);
'@$CurrentMed1 = addslashes($_POST['CurrentMed1']);
'@$CurrentMed2 = addslashes($_POST['CurrentMed2']);
'@$CurrentMed11 = addslashes($_POST['CurrentMed11']);
'@$CurrentMed4 = addslashes($_POST['CurrentMed4']);
'@$CurrentMed5 = addslashes($_POST['CurrentMed5']);
'@$CurrentMed6 = addslashes($_POST['CurrentMed6']);
'@$CurrentMed7 = addslashes($_POST['CurrentMed7']);
'@$CurrentMed8 = addslashes($_POST['CurrentMed8']);
'@$CurrentMed9 = addslashes($_POST['CurrentMed9']);
'@$CurrentMed10 = addslashes($_POST['CurrentMed10']);
'@$MedicationAllergies1 = addslashes($_POST['MedicationAllergies1']);
'@$MedicationAllergies2 = addslashes($_POST['MedicationAllergies2']);
'@$CurrentMed3 = addslashes($_POST['CurrentMed3']);
'@$MedicationAllergies4 = addslashes($_POST['MedicationAllergies4']);
'@$Anxiety_nervousness = addslashes($_POST['Anxiety_nervousness']);
'@$Paranoid = addslashes($_POST['Paranoid']);
'@$Depression1 = addslashes($_POST['Depression1']);
'@$ObsessiveThoughts = addslashes($_POST['ObsessiveThoughts']);
'@$MoodSwings1 = addslashes($_POST['MoodSwings1']);
'@$ObsessiveHabits = addslashes($_POST['ObsessiveHabits']);
'@$Insomnia_Oversleeping = addslashes($_POST['Insomnia_Oversleeping']);
'@$LowEnergy = addslashes($_POST['LowEnergy']);
'@$ProblemsConcentrating = addslashes($_POST['ProblemsConcentrating']);
'@$HopelessFeelings = addslashes($_POST['HopelessFeelings']);
'@$HearingVoices = addslashes($_POST['HearingVoices']);
'@$ThoughtsAboutDeath = addslashes($_POST['ThoughtsAboutDeath']);
'@$Visions = addslashes($_POST['Visions']);
'@$Suicide = addslashes($_POST['Suicide']);
'@$Year1 = addslashes($_POST['Year1']);
'@$Reasonforvisit1 = addslashes($_POST['Reasonforvisit1']);
'@$Year2 = addslashes($_POST['Year2']);
'@$ReasonforVisit2 = addslashes($_POST['ReasonforVisit2']);
'@$Year3 = addslashes($_POST['Year3']);
'@$Reasonforvisit3 = addslashes($_POST['Reasonforvisit3']);
'@$AnxietyNervousness = addslashes($_POST['AnxietyNervousness']);
'@$Alcoholism = addslashes($_POST['Alcoholism']);
'@$Depression = addslashes($_POST['Depression']);
'@$DrugAddiction = addslashes($_POST['DrugAddiction']);
'@$MoodSwings = addslashes($_POST['MoodSwings']);
'@$AttentionDeficit = addslashes($_POST['AttentionDeficit']);
'@$Schizophrenia = addslashes($_POST['Schizophrenia']);
'@$ObsessiveCompulsiveDisorder = addslashes($_POST['ObsessiveCompulsiveDisorder']);
'@$Cigarettes_Yes = addslashes($_POST['Cigarettes_Yes']);
'@$Cigarettes_No = addslashes($_POST['Cigarettes_No']);
'@$Cigarettes_Amount_Used = addslashes($_POST['Cigarettes_Amount_Used']);
'@$Cigarettes_LastUsed = addslashes($_POST['Cigarettes_LastUsed']);
'@$Alcohol_Yes = addslashes($_POST['Alcohol_Yes']);
'@$Alcohol_No = addslashes($_POST['Alcohol_No']);
'@$Alcohol_Amount_Used = addslashes($_POST['Alcohol_Amount_Used']);
'@$Alcohol_LastUsed = addslashes($_POST['Alcohol_LastUsed']);
'@$Opiates_Yes = addslashes($_POST['Opiates_Yes']);
'@$Opiates_No = addslashes($_POST['Opiates_No']);
'@$Opiates_Amount_Used = addslashes($_POST['Opiates_Amount_Used']);
'@$Opiates_LastUsed = addslashes($_POST['Opiates_LastUsed']);
'@$Cocaine_Yes = addslashes($_POST['Cocaine_Yes']);
'@$Cocaine_No = addslashes($_POST['Cocaine_No']);
'@$Cocaine_Amount_Used = addslashes($_POST['Cocaine_Amount_Used']);
'@$Cocaine_LastUsed = addslashes($_POST['Cocaine_LastUsed']);
'@$Marijuana_Yes = addslashes($_POST['Marijuana_Yes']);
'@$Marijuana_No = addslashes($_POST['Marijuana_No']);
'@$Marijuana_Amount_Used = addslashes($_POST['Marijuana_Amount_Used']);
'@$Marijuana_LastUsed = addslashes($_POST['Marijuana_LastUsed']);
'@$Speed_Yes = addslashes($_POST['Speed_Yes']);
'@$Speed_No = addslashes($_POST['Speed_No']);
'@$Speed_Amount_Used = addslashes($_POST['Speed_Amount_Used']);
'@$Speed_LastUsed = addslashes($_POST['Speed_LastUsed']);
'@$Sedatives_Yes = addslashes($_POST['Sedatives_Yes']);
'@$Sedatives_No = addslashes($_POST['Sedatives_No']);
'@$Sedatives_Amount_Used = addslashes($_POST['Sedatives_Amount_Used']);
'@$Sedatives_LastUsed = addslashes($_POST['Sedatives_LastUsed']);
'@$Other_Yes1 = addslashes($_POST['Other_Yes1']);
'@$Other_No1 = addslashes($_POST['Other_No1']);
'@$Other_Amount_Used1 = addslashes($_POST['Other_Amount_Used1']);
'@$Other_LastUsed1 = addslashes($_POST['Other_LastUsed1']);
'@$Other_Yes = addslashes($_POST['Other_Yes']);
'@$Other_No = addslashes($_POST['Other_No']);
'@$Other_Amount_Used = addslashes($_POST['Other_Amount_Used']);
'@$Other_LastUsed = addslashes($_POST['Other_LastUsed']);
'@$Nose_EyesRunning = addslashes($_POST['Nose_EyesRunning']);
'@$Nausea = addslashes($_POST['Nausea']);
'@$Sneezing = addslashes($_POST['Sneezing']);
'@$Vomiting = addslashes($_POST['Vomiting']);
'@$Sweating = addslashes($_POST['Sweating']);
'@$Diarrhea = addslashes($_POST['Diarrhea']);
'@$Chills_HotFlashes = addslashes($_POST['Chills_HotFlashes']);
'@$Problems_Sleeping = addslashes($_POST['Problems_Sleeping']);
'@$Anxiety = addslashes($_POST['Anxiety']);
'@$Headache = addslashes($_POST['Headache']);
'@$Tremors = addslashes($_POST['Tremors']);
'@$Hallucinations = addslashes($_POST['Hallucinations']);
'@$MuscleJointAches = addslashes($_POST['MuscleJointAches']);
'@$Other = addslashes($_POST['Other']);
'@$Other_Withdrawal_Symptoms = addslashes($_POST['Other_Withdrawal_Symptoms']);
'@$CurrentMedicalProblems1 = addslashes($_POST['CurrentMedicalProblems1']);
'@$CurrentMedicalProblems2 = addslashes($_POST['CurrentMedicalProblems2']);
'@$CurrentMedicalProblems3 = addslashes($_POST['CurrentMedicalProblems3']);
'@$Other_Withdrawal_Symptoms4 = addslashes($_POST['Other_Withdrawal_Symptoms4']);
'@$CurrentMedicalProblems5 = addslashes($_POST['CurrentMedicalProblems5']);
'@$CurrentMedicalProblems6 = addslashes($_POST['CurrentMedicalProblems6']);
'@$CurrentMedicalProblems7 = addslashes($_POST['CurrentMedicalProblems7']);
'@$CurrentMedicalProblems8 = addslashes($_POST['CurrentMedicalProblems8']);
'@$CurrentMedicalProblems9 = addslashes($_POST['CurrentMedicalProblems9']);
'@$CurrentMedicalProblems10 = addslashes($_POST['CurrentMedicalProblems10']);
'@$DateOfLastPeriod = addslashes($_POST['DateOfLastPeriod']);
'@$BirthControl_Yes = addslashes($_POST['BirthControl_Yes']);
'@$BirthControl_No = addslashes($_POST['BirthControl_No']);
'@$TypeofBirthControl = addslashes($_POST['TypeofBirthControl']);

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$pfw_message = createMailBody($_POST);

//Sending Email to form owner
'$pfw_header = "From: $Name\n"
  . "Reply-To: $Name\n";
'$pfw_subject = "WCBM - Health Questionnaire";
'$pfw_email_to = "pploesser@gmail.com";
'$pfw_message = "Name: $Name\n"
'. "Date: $Date\n"
'. "DOB: $DOB\n"
'. "Age: $Age\n"
'. "Weight: $Weight\n"
'. "\n"
'. "Reason for the visit:\n"
'. "Problem/Symptom $1: Problem1\n"
'. "Problem/Symptom $2: Problem2\n"
'. "Problem/Symptom $3: Problem3\n"
'. "\n"
'. "Current Medication (and Doses)\n"
'. "Current Medication $1: CurrentMed1\n"
'. "Current Medication $2: CurrentMed2\n"
'. "Current Medication $3: CurrentMed11\n"
'. "Current Medication $4: CurrentMed4\n"
'. "Current Medication $5: CurrentMed5\n"
'. "Current Medication $6: CurrentMed6\n"
'. "Current Medication $7: CurrentMed7\n"
'. "Current Medication $8: CurrentMed8\n"
'. "Current Medication $9: CurrentMed9\n"
'. "Current Medication $10: CurrentMed10\n"
'. "\n"
'. "Medication Allergies\n"
'. "Medication Allergies  $1: MedicationAllergies1\n"
'. "Medication Allergies  $2: MedicationAllergies2\n"
'. "Medication Allergies  $3: CurrentMed3\n"
'. "Medication Allergies  $4: MedicationAllergies4\n"
'. "\n"
'. "Past Psychiatric History\n"
'. "\n"
'. "Anxiety / Nervousness:  $Anxiety_nervousness\n"
'. "Paranoid Feeliongs: $Paranoid\n"
'. "Depression : $Depression1\n"
'. "Obsessive Thoughts: $ObsessiveThoughts\n"
'. "Mood Swings: $MoodSwings1\n"
'. "Obsessive Habits: $ObsessiveHabits\n"
'. "Insomnia / Oversleeping: $Insomnia_Oversleeping\n"
'. "Low Energy: $LowEnergy\n"
'. "Problems Concentrating: $ProblemsConcentrating\n"
'. "Hopeless Feelings: $HopelessFeelings\n"
'. "Hearing Voices: $HearingVoices\n"
'. "Thoughts About Death: $ThoughtsAboutDeath\n"
'. "Visions: $Visions\n"
'. "Suicide: $Suicide\n"
'. "\n"
'. "Past Hospitalizations\n"
'. "\n"
'. "Year: $Year1\n"
'. "Reason for the hospital visit: $Reasonforvisit1\n"
'. "Year: $Year2\n"
'. "Reason for the hospital visit: $ReasonforVisit2\n"
'. "Year: $Year3\n"
'. "Reason for the hospital visit: $Reasonforvisit3\n"
'. "\n"
'. "Family History\n"
'. "\n"
'. "Anxiety / Nervousness: $AnxietyNervousness\n"
'. "Alcoholism: $Alcoholism\n"
'. "Depression: $Depression\n"
'. "Drug Addiction: $DrugAddiction\n"
'. "Mood Swings: $MoodSwings\n"
'. "Attention Deficit: $AttentionDeficit\n"
'. "Schizophrenia: $Schizophrenia\n"
'. "Obsessive Compulsive Disorder: $ObsessiveCompulsiveDisorder\n"
'. "Cigarettes: $Cigarettes_Yes\n"
'. "Cigarettes No: $Cigarettes_No\n"
'. "Cigarettes_Amount_Used: $Cigarettes_Amount_Used\n"
'. "Cigarettes_LastUsed: $Cigarettes_LastUsed\n"
'. "Alcohol_Yes: $Alcohol_Yes\n"
'. "Alcohol_No: $Alcohol_No\n"
'. "Alcohol_Amount_Used: $Alcohol_Amount_Used\n"
'. "Alcohol_LastUsed: $Alcohol_LastUsed\n"
'. "Opiates_Yes: $Opiates_Yes\n"
'. "Opiates_No: $Opiates_No\n"
'. "Opiates_Amount_Used: $Opiates_Amount_Used\n"
'. "Opiates_LastUsed: $Opiates_LastUsed\n"
'. "Cocaine_Yes: $Cocaine_Yes\n"
'. "Cocaine_No: $Cocaine_No\n"
'. "Cocaine_Amount_Used: $Cocaine_Amount_Used\n"
'. "Cocaine_LastUsed: $Cocaine_LastUsed\n"
'. "Marijuana_Yes: $Marijuana_Yes\n"
'. "Marijuana_No: $Marijuana_No\n"
'. "Marijuana_Amount_Used: $Marijuana_Amount_Used\n"
'. "Marijuana_LastUsed: $Marijuana_LastUsed\n"
'. "Speed_Yes: $Speed_Yes\n"
'. "Speed_No: $Speed_No\n"
'. "Speed_Amount_Used: $Speed_Amount_Used\n"
'. "Speed_LastUsed: $Speed_LastUsed\n"
'. "Sedatives_Yes: $Sedatives_Yes\n"
'. "Sedatives_No: $Sedatives_No\n"
'. "Sedatives_Amount_Used: $Sedatives_Amount_Used\n"
'. "Sedatives_LastUsed: $Sedatives_LastUsed\n"
'. "Other_Yes1: $Other_Yes1\n"
'. "Other_No1: $Other_No1\n"
'. "Other_Amount_Used1: $Other_Amount_Used1\n"
'. "Other_LastUsed1: $Other_LastUsed1\n"
'. "Other_Yes: $Other_Yes\n"
'. "Other_No: $Other_No\n"
'. "Other_Amount_Used: $Other_Amount_Used\n"
'. "Other_LastUsed: $Other_LastUsed\n"
'. "Nose_EyesRunning: $Nose_EyesRunning\n"
'. "Nausea: $Nausea\n"
'. "Sneezing: $Sneezing\n"
'. "Vomiting: $Vomiting\n"
'. "Sweating: $Sweating\n"
'. "Diarrhea: $Diarrhea\n"
'. "Chills_HotFlashes: $Chills_HotFlashes\n"
'. "Problems_Sleeping: $Problems_Sleeping\n"
'. "Anxiety: $Anxiety\n"
'. "Headache: $Headache\n"
'. "Tremors: $Tremors\n"
'. "Hallucinations: $Hallucinations\n"
'. "MuscleJointAches: $MuscleJointAches\n"
'. "Other: $Other\n"
'. "Other_Withdrawal_Symptoms: $Other_Withdrawal_Symptoms\n"
'. "CurrentMedicalProblems1: $CurrentMedicalProblems1\n"
'. "CurrentMedicalProblems2: $CurrentMedicalProblems2\n"
'. "CurrentMedicalProblems3: $CurrentMedicalProblems3\n"
'. "Other_Withdrawal_Symptoms4: $Other_Withdrawal_Symptoms4\n"
'. "CurrentMedicalProblems5: $CurrentMedicalProblems5\n"
'. "CurrentMedicalProblems6: $CurrentMedicalProblems6\n"
'. "CurrentMedicalProblems7: $CurrentMedicalProblems7\n"
'. "CurrentMedicalProblems8: $CurrentMedicalProblems8\n"
'. "CurrentMedicalProblems9: $CurrentMedicalProblems9\n"
'. "CurrentMedicalProblems10: $CurrentMedicalProblems10\n"
'. "\n"
'. "For women only:\n"
'. "\n"
'. "DateOfLastPeriod: $DateOfLastPeriod\n"
'. "BirthControl_Yes: $BirthControl_Yes\n"
'. "BirthControl_No: $BirthControl_No\n"
'. "TypeofBirthControl: $TypeofBirthControl\n";
'@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: pploesser@gmail.com\n"
  . "Reply-To: pploesser@gmail.com\n";
$pfw_subject = "test";
$pfw_email_to = "$Name";
$pfw_message = "test";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Test</font></p>");
?>

Link to comment
Share on other sites

Give this a try:

 

<?php

function createMailBody ($postdata = array(), $requiredfields = array()) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$pfw_message = createMailBody($_POST, $requiredfields);

/**
// Receiving variables
@$Name = addslashes($_POST['Name']);
@$Date = addslashes($_POST['Date']);
@$DOB = addslashes($_POST['DOB']);
@$Age = addslashes($_POST['Age']);
@$Weight = addslashes($_POST['Weight']);
@$Problem1 = addslashes($_POST['Problem1']);
@$Problem2 = addslashes($_POST['Problem2']);
@$Problem3 = addslashes($_POST['Problem3']);
@$CurrentMed1 = addslashes($_POST['CurrentMed1']);
@$CurrentMed2 = addslashes($_POST['CurrentMed2']);
@$CurrentMed11 = addslashes($_POST['CurrentMed11']);
@$CurrentMed4 = addslashes($_POST['CurrentMed4']);
@$CurrentMed5 = addslashes($_POST['CurrentMed5']);
@$CurrentMed6 = addslashes($_POST['CurrentMed6']);
@$CurrentMed7 = addslashes($_POST['CurrentMed7']);
@$CurrentMed8 = addslashes($_POST['CurrentMed8']);
@$CurrentMed9 = addslashes($_POST['CurrentMed9']);
@$CurrentMed10 = addslashes($_POST['CurrentMed10']);
@$MedicationAllergies1 = addslashes($_POST['MedicationAllergies1']);
@$MedicationAllergies2 = addslashes($_POST['MedicationAllergies2']);
@$CurrentMed3 = addslashes($_POST['CurrentMed3']);
@$MedicationAllergies4 = addslashes($_POST['MedicationAllergies4']);
@$Anxiety_nervousness = addslashes($_POST['Anxiety_nervousness']);
@$Paranoid = addslashes($_POST['Paranoid']);
@$Depression1 = addslashes($_POST['Depression1']);
@$ObsessiveThoughts = addslashes($_POST['ObsessiveThoughts']);
@$MoodSwings1 = addslashes($_POST['MoodSwings1']);
@$ObsessiveHabits = addslashes($_POST['ObsessiveHabits']);
@$Insomnia_Oversleeping = addslashes($_POST['Insomnia_Oversleeping']);
@$LowEnergy = addslashes($_POST['LowEnergy']);
@$ProblemsConcentrating = addslashes($_POST['ProblemsConcentrating']);
@$HopelessFeelings = addslashes($_POST['HopelessFeelings']);
@$HearingVoices = addslashes($_POST['HearingVoices']);
@$ThoughtsAboutDeath = addslashes($_POST['ThoughtsAboutDeath']);
@$Visions = addslashes($_POST['Visions']);
@$Suicide = addslashes($_POST['Suicide']);
@$Year1 = addslashes($_POST['Year1']);
@$Reasonforvisit1 = addslashes($_POST['Reasonforvisit1']);
@$Year2 = addslashes($_POST['Year2']);
@$ReasonforVisit2 = addslashes($_POST['ReasonforVisit2']);
@$Year3 = addslashes($_POST['Year3']);
@$Reasonforvisit3 = addslashes($_POST['Reasonforvisit3']);
@$AnxietyNervousness = addslashes($_POST['AnxietyNervousness']);
@$Alcoholism = addslashes($_POST['Alcoholism']);
@$Depression = addslashes($_POST['Depression']);
@$DrugAddiction = addslashes($_POST['DrugAddiction']);
@$MoodSwings = addslashes($_POST['MoodSwings']);
@$AttentionDeficit = addslashes($_POST['AttentionDeficit']);
@$Schizophrenia = addslashes($_POST['Schizophrenia']);
@$ObsessiveCompulsiveDisorder = addslashes($_POST['ObsessiveCompulsiveDisorder']);
@$Cigarettes_Yes = addslashes($_POST['Cigarettes_Yes']);
@$Cigarettes_No = addslashes($_POST['Cigarettes_No']);
@$Cigarettes_Amount_Used = addslashes($_POST['Cigarettes_Amount_Used']);
@$Cigarettes_LastUsed = addslashes($_POST['Cigarettes_LastUsed']);
@$Alcohol_Yes = addslashes($_POST['Alcohol_Yes']);
@$Alcohol_No = addslashes($_POST['Alcohol_No']);
@$Alcohol_Amount_Used = addslashes($_POST['Alcohol_Amount_Used']);
@$Alcohol_LastUsed = addslashes($_POST['Alcohol_LastUsed']);
@$Opiates_Yes = addslashes($_POST['Opiates_Yes']);
@$Opiates_No = addslashes($_POST['Opiates_No']);
@$Opiates_Amount_Used = addslashes($_POST['Opiates_Amount_Used']);
@$Opiates_LastUsed = addslashes($_POST['Opiates_LastUsed']);
@$Cocaine_Yes = addslashes($_POST['Cocaine_Yes']);
@$Cocaine_No = addslashes($_POST['Cocaine_No']);
@$Cocaine_Amount_Used = addslashes($_POST['Cocaine_Amount_Used']);
@$Cocaine_LastUsed = addslashes($_POST['Cocaine_LastUsed']);
@$Marijuana_Yes = addslashes($_POST['Marijuana_Yes']);
@$Marijuana_No = addslashes($_POST['Marijuana_No']);
@$Marijuana_Amount_Used = addslashes($_POST['Marijuana_Amount_Used']);
@$Marijuana_LastUsed = addslashes($_POST['Marijuana_LastUsed']);
@$Speed_Yes = addslashes($_POST['Speed_Yes']);
@$Speed_No = addslashes($_POST['Speed_No']);
@$Speed_Amount_Used = addslashes($_POST['Speed_Amount_Used']);
@$Speed_LastUsed = addslashes($_POST['Speed_LastUsed']);
@$Sedatives_Yes = addslashes($_POST['Sedatives_Yes']);
@$Sedatives_No = addslashes($_POST['Sedatives_No']);
@$Sedatives_Amount_Used = addslashes($_POST['Sedatives_Amount_Used']);
@$Sedatives_LastUsed = addslashes($_POST['Sedatives_LastUsed']);
@$Other_Yes1 = addslashes($_POST['Other_Yes1']);
@$Other_No1 = addslashes($_POST['Other_No1']);
@$Other_Amount_Used1 = addslashes($_POST['Other_Amount_Used1']);
@$Other_LastUsed1 = addslashes($_POST['Other_LastUsed1']);
@$Other_Yes = addslashes($_POST['Other_Yes']);
@$Other_No = addslashes($_POST['Other_No']);
@$Other_Amount_Used = addslashes($_POST['Other_Amount_Used']);
@$Other_LastUsed = addslashes($_POST['Other_LastUsed']);
@$Nose_EyesRunning = addslashes($_POST['Nose_EyesRunning']);
@$Nausea = addslashes($_POST['Nausea']);
@$Sneezing = addslashes($_POST['Sneezing']);
@$Vomiting = addslashes($_POST['Vomiting']);
@$Sweating = addslashes($_POST['Sweating']);
@$Diarrhea = addslashes($_POST['Diarrhea']);
@$Chills_HotFlashes = addslashes($_POST['Chills_HotFlashes']);
@$Problems_Sleeping = addslashes($_POST['Problems_Sleeping']);
@$Anxiety = addslashes($_POST['Anxiety']);
@$Headache = addslashes($_POST['Headache']);
@$Tremors = addslashes($_POST['Tremors']);
@$Hallucinations = addslashes($_POST['Hallucinations']);
@$MuscleJointAches = addslashes($_POST['MuscleJointAches']);
@$Other = addslashes($_POST['Other']);
@$Other_Withdrawal_Symptoms = addslashes($_POST['Other_Withdrawal_Symptoms']);
@$CurrentMedicalProblems1 = addslashes($_POST['CurrentMedicalProblems1']);
@$CurrentMedicalProblems2 = addslashes($_POST['CurrentMedicalProblems2']);
@$CurrentMedicalProblems3 = addslashes($_POST['CurrentMedicalProblems3']);
@$Other_Withdrawal_Symptoms4 = addslashes($_POST['Other_Withdrawal_Symptoms4']);
@$CurrentMedicalProblems5 = addslashes($_POST['CurrentMedicalProblems5']);
@$CurrentMedicalProblems6 = addslashes($_POST['CurrentMedicalProblems6']);
@$CurrentMedicalProblems7 = addslashes($_POST['CurrentMedicalProblems7']);
@$CurrentMedicalProblems8 = addslashes($_POST['CurrentMedicalProblems8']);
@$CurrentMedicalProblems9 = addslashes($_POST['CurrentMedicalProblems9']);
@$CurrentMedicalProblems10 = addslashes($_POST['CurrentMedicalProblems10']);
@$DateOfLastPeriod = addslashes($_POST['DateOfLastPeriod']);
@$BirthControl_Yes = addslashes($_POST['BirthControl_Yes']);
@$BirthControl_No = addslashes($_POST['BirthControl_No']);
@$TypeofBirthControl = addslashes($_POST['TypeofBirthControl']);
*/

//Sending Email to form owner
$pfw_header = "From: $Name\n"
  . "Reply-To: $Name\n";
$pfw_subject = "WCBM - Health Questionnaire";
$pfw_email_to = "pploesser@gmail.com";
/**
$pfw_message = "Name: $Name\n"
. "Date: $Date\n"
. "DOB: $DOB\n"
. "Age: $Age\n"
. "Weight: $Weight\n"
. "\n"
. "Reason for the visit:\n"
. "Problem/Symptom $1: Problem1\n"
. "Problem/Symptom $2: Problem2\n"
. "Problem/Symptom $3: Problem3\n"
. "\n"
. "Current Medication (and Doses)\n"
. "Current Medication $1: CurrentMed1\n"
. "Current Medication $2: CurrentMed2\n"
. "Current Medication $3: CurrentMed11\n"
. "Current Medication $4: CurrentMed4\n"
. "Current Medication $5: CurrentMed5\n"
. "Current Medication $6: CurrentMed6\n"
. "Current Medication $7: CurrentMed7\n"
. "Current Medication $8: CurrentMed8\n"
. "Current Medication $9: CurrentMed9\n"
. "Current Medication $10: CurrentMed10\n"
. "\n"
. "Medication Allergies\n"
. "Medication Allergies  $1: MedicationAllergies1\n"
. "Medication Allergies  $2: MedicationAllergies2\n"
. "Medication Allergies  $3: CurrentMed3\n"
. "Medication Allergies  $4: MedicationAllergies4\n"
. "\n"
. "Past Psychiatric History\n"
. "\n"
. "Anxiety / Nervousness:  $Anxiety_nervousness\n"
. "Paranoid Feeliongs: $Paranoid\n"
. "Depression : $Depression1\n"
. "Obsessive Thoughts: $ObsessiveThoughts\n"
. "Mood Swings: $MoodSwings1\n"
. "Obsessive Habits: $ObsessiveHabits\n"
. "Insomnia / Oversleeping: $Insomnia_Oversleeping\n"
. "Low Energy: $LowEnergy\n"
. "Problems Concentrating: $ProblemsConcentrating\n"
. "Hopeless Feelings: $HopelessFeelings\n"
. "Hearing Voices: $HearingVoices\n"
. "Thoughts About Death: $ThoughtsAboutDeath\n"
. "Visions: $Visions\n"
. "Suicide: $Suicide\n"
. "\n"
. "Past Hospitalizations\n"
. "\n"
. "Year: $Year1\n"
. "Reason for the hospital visit: $Reasonforvisit1\n"
. "Year: $Year2\n"
. "Reason for the hospital visit: $ReasonforVisit2\n"
. "Year: $Year3\n"
. "Reason for the hospital visit: $Reasonforvisit3\n"
. "\n"
. "Family History\n"
. "\n"
. "Anxiety / Nervousness: $AnxietyNervousness\n"
. "Alcoholism: $Alcoholism\n"
. "Depression: $Depression\n"
. "Drug Addiction: $DrugAddiction\n"
. "Mood Swings: $MoodSwings\n"
. "Attention Deficit: $AttentionDeficit\n"
. "Schizophrenia: $Schizophrenia\n"
. "Obsessive Compulsive Disorder: $ObsessiveCompulsiveDisorder\n"
. "Cigarettes: $Cigarettes_Yes\n"
. "Cigarettes No: $Cigarettes_No\n"
. "Cigarettes_Amount_Used: $Cigarettes_Amount_Used\n"
. "Cigarettes_LastUsed: $Cigarettes_LastUsed\n"
. "Alcohol_Yes: $Alcohol_Yes\n"
. "Alcohol_No: $Alcohol_No\n"
. "Alcohol_Amount_Used: $Alcohol_Amount_Used\n"
. "Alcohol_LastUsed: $Alcohol_LastUsed\n"
. "Opiates_Yes: $Opiates_Yes\n"
. "Opiates_No: $Opiates_No\n"
. "Opiates_Amount_Used: $Opiates_Amount_Used\n"
. "Opiates_LastUsed: $Opiates_LastUsed\n"
. "Cocaine_Yes: $Cocaine_Yes\n"
. "Cocaine_No: $Cocaine_No\n"
. "Cocaine_Amount_Used: $Cocaine_Amount_Used\n"
. "Cocaine_LastUsed: $Cocaine_LastUsed\n"
. "Marijuana_Yes: $Marijuana_Yes\n"
. "Marijuana_No: $Marijuana_No\n"
. "Marijuana_Amount_Used: $Marijuana_Amount_Used\n"
. "Marijuana_LastUsed: $Marijuana_LastUsed\n"
. "Speed_Yes: $Speed_Yes\n"
. "Speed_No: $Speed_No\n"
. "Speed_Amount_Used: $Speed_Amount_Used\n"
. "Speed_LastUsed: $Speed_LastUsed\n"
. "Sedatives_Yes: $Sedatives_Yes\n"
. "Sedatives_No: $Sedatives_No\n"
. "Sedatives_Amount_Used: $Sedatives_Amount_Used\n"
. "Sedatives_LastUsed: $Sedatives_LastUsed\n"
. "Other_Yes1: $Other_Yes1\n"
. "Other_No1: $Other_No1\n"
. "Other_Amount_Used1: $Other_Amount_Used1\n"
. "Other_LastUsed1: $Other_LastUsed1\n"
. "Other_Yes: $Other_Yes\n"
. "Other_No: $Other_No\n"
. "Other_Amount_Used: $Other_Amount_Used\n"
. "Other_LastUsed: $Other_LastUsed\n"
. "Nose_EyesRunning: $Nose_EyesRunning\n"
. "Nausea: $Nausea\n"
. "Sneezing: $Sneezing\n"
. "Vomiting: $Vomiting\n"
. "Sweating: $Sweating\n"
. "Diarrhea: $Diarrhea\n"
. "Chills_HotFlashes: $Chills_HotFlashes\n"
. "Problems_Sleeping: $Problems_Sleeping\n"
. "Anxiety: $Anxiety\n"
. "Headache: $Headache\n"
. "Tremors: $Tremors\n"
. "Hallucinations: $Hallucinations\n"
. "MuscleJointAches: $MuscleJointAches\n"
. "Other: $Other\n"
. "Other_Withdrawal_Symptoms: $Other_Withdrawal_Symptoms\n"
. "CurrentMedicalProblems1: $CurrentMedicalProblems1\n"
. "CurrentMedicalProblems2: $CurrentMedicalProblems2\n"
. "CurrentMedicalProblems3: $CurrentMedicalProblems3\n"
. "Other_Withdrawal_Symptoms4: $Other_Withdrawal_Symptoms4\n"
. "CurrentMedicalProblems5: $CurrentMedicalProblems5\n"
. "CurrentMedicalProblems6: $CurrentMedicalProblems6\n"
. "CurrentMedicalProblems7: $CurrentMedicalProblems7\n"
. "CurrentMedicalProblems8: $CurrentMedicalProblems8\n"
. "CurrentMedicalProblems9: $CurrentMedicalProblems9\n"
. "CurrentMedicalProblems10: $CurrentMedicalProblems10\n"
. "\n"
. "For women only:\n"
. "\n"
. "DateOfLastPeriod: $DateOfLastPeriod\n"
. "BirthControl_Yes: $BirthControl_Yes\n"
. "BirthControl_No: $BirthControl_No\n"
. "TypeofBirthControl: $TypeofBirthControl\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: pploesser@gmail.com\n"
  . "Reply-To: pploesser@gmail.com\n";
*/
$pfw_subject = "test";
$pfw_email_to = "$Name";
$pfw_message = "test";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Test</font></p>");
?>

Link to comment
Share on other sites

Haha, I went overboard with the commenting. Sorry about that. Note, $requiredfields isn't complete!

 

<?php

function createMailBody ($postdata = array(), $requiredfields = array()) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$pfw_message = createMailBody($_POST, $requiredfields);

//Sending Email to form owner
$pfw_header = "From: $Name\n"
  . "Reply-To: $Name\n";
$pfw_subject = "WCBM - Health Questionnaire";
$pfw_email_to = "pploesser@gmail.com";

@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: pploesser@gmail.com\n"
  . "Reply-To: pploesser@gmail.com\n";

$pfw_subject = "test";
$pfw_email_to = "$Name";
$pfw_message = "test";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Test</font></p>");
?>

Link to comment
Share on other sites

Thank you, BUT now I'm not getting an email or the confirmation "test" message. Sorry to be a nuisance but nothing catches my eyes as to what the problem is

 

<?php

function createMailBody ($postdata = array(), $requiredfields = array()) {
     $msg = '';
     foreach ($_POST as $key => $value) {
          if (empty($value) && !empty($requiredfields[$key])) die($requiredfields[$key]);
          if (!empty($value)) $msg .= $key . ': ' . $value . '\n';
     }
     return $msg;
}

// add the rest
$requiredfields = array(
     'Name' => "<p align='center'><font face='Arial' size='3' color='#FF0000'>Please enter a valid name</font></p>"
);

// add all the other headers etc.
$pfw_message = createMailBody($_POST, $requiredfields);

/**
// Receiving variables
@$Name = addslashes($_POST['Name']);
@$Date = addslashes($_POST['Date']);
@$DOB = addslashes($_POST['DOB']);
@$Age = addslashes($_POST['Age']);
@$Weight = addslashes($_POST['Weight']);
@$Problem1 = addslashes($_POST['Problem1']);
@$Problem2 = addslashes($_POST['Problem2']);
@$Problem3 = addslashes($_POST['Problem3']);
@$CurrentMed1 = addslashes($_POST['CurrentMed1']);
@$CurrentMed2 = addslashes($_POST['CurrentMed2']);
@$CurrentMed11 = addslashes($_POST['CurrentMed11']);
@$CurrentMed4 = addslashes($_POST['CurrentMed4']);
@$CurrentMed5 = addslashes($_POST['CurrentMed5']);
@$CurrentMed6 = addslashes($_POST['CurrentMed6']);
@$CurrentMed7 = addslashes($_POST['CurrentMed7']);
@$CurrentMed8 = addslashes($_POST['CurrentMed8']);
@$CurrentMed9 = addslashes($_POST['CurrentMed9']);
@$CurrentMed10 = addslashes($_POST['CurrentMed10']);
@$MedicationAllergies1 = addslashes($_POST['MedicationAllergies1']);
@$MedicationAllergies2 = addslashes($_POST['MedicationAllergies2']);
@$CurrentMed3 = addslashes($_POST['CurrentMed3']);
@$MedicationAllergies4 = addslashes($_POST['MedicationAllergies4']);
@$Anxiety_nervousness = addslashes($_POST['Anxiety_nervousness']);
@$Paranoid = addslashes($_POST['Paranoid']);
@$Depression1 = addslashes($_POST['Depression1']);
@$ObsessiveThoughts = addslashes($_POST['ObsessiveThoughts']);
@$MoodSwings1 = addslashes($_POST['MoodSwings1']);
@$ObsessiveHabits = addslashes($_POST['ObsessiveHabits']);
@$Insomnia_Oversleeping = addslashes($_POST['Insomnia_Oversleeping']);
@$LowEnergy = addslashes($_POST['LowEnergy']);
@$ProblemsConcentrating = addslashes($_POST['ProblemsConcentrating']);
@$HopelessFeelings = addslashes($_POST['HopelessFeelings']);
@$HearingVoices = addslashes($_POST['HearingVoices']);
@$ThoughtsAboutDeath = addslashes($_POST['ThoughtsAboutDeath']);
@$Visions = addslashes($_POST['Visions']);
@$Suicide = addslashes($_POST['Suicide']);
@$Year1 = addslashes($_POST['Year1']);
@$Reasonforvisit1 = addslashes($_POST['Reasonforvisit1']);
@$Year2 = addslashes($_POST['Year2']);
@$ReasonforVisit2 = addslashes($_POST['ReasonforVisit2']);
@$Year3 = addslashes($_POST['Year3']);
@$Reasonforvisit3 = addslashes($_POST['Reasonforvisit3']);
@$AnxietyNervousness = addslashes($_POST['AnxietyNervousness']);
@$Alcoholism = addslashes($_POST['Alcoholism']);
@$Depression = addslashes($_POST['Depression']);
@$DrugAddiction = addslashes($_POST['DrugAddiction']);
@$MoodSwings = addslashes($_POST['MoodSwings']);
@$AttentionDeficit = addslashes($_POST['AttentionDeficit']);
@$Schizophrenia = addslashes($_POST['Schizophrenia']);
@$ObsessiveCompulsiveDisorder = addslashes($_POST['ObsessiveCompulsiveDisorder']);
@$Cigarettes_Yes = addslashes($_POST['Cigarettes_Yes']);
@$Cigarettes_No = addslashes($_POST['Cigarettes_No']);
@$Cigarettes_Amount_Used = addslashes($_POST['Cigarettes_Amount_Used']);
@$Cigarettes_LastUsed = addslashes($_POST['Cigarettes_LastUsed']);
@$Alcohol_Yes = addslashes($_POST['Alcohol_Yes']);
@$Alcohol_No = addslashes($_POST['Alcohol_No']);
@$Alcohol_Amount_Used = addslashes($_POST['Alcohol_Amount_Used']);
@$Alcohol_LastUsed = addslashes($_POST['Alcohol_LastUsed']);
@$Opiates_Yes = addslashes($_POST['Opiates_Yes']);
@$Opiates_No = addslashes($_POST['Opiates_No']);
@$Opiates_Amount_Used = addslashes($_POST['Opiates_Amount_Used']);
@$Opiates_LastUsed = addslashes($_POST['Opiates_LastUsed']);
@$Cocaine_Yes = addslashes($_POST['Cocaine_Yes']);
@$Cocaine_No = addslashes($_POST['Cocaine_No']);
@$Cocaine_Amount_Used = addslashes($_POST['Cocaine_Amount_Used']);
@$Cocaine_LastUsed = addslashes($_POST['Cocaine_LastUsed']);
@$Marijuana_Yes = addslashes($_POST['Marijuana_Yes']);
@$Marijuana_No = addslashes($_POST['Marijuana_No']);
@$Marijuana_Amount_Used = addslashes($_POST['Marijuana_Amount_Used']);
@$Marijuana_LastUsed = addslashes($_POST['Marijuana_LastUsed']);
@$Speed_Yes = addslashes($_POST['Speed_Yes']);
@$Speed_No = addslashes($_POST['Speed_No']);
@$Speed_Amount_Used = addslashes($_POST['Speed_Amount_Used']);
@$Speed_LastUsed = addslashes($_POST['Speed_LastUsed']);
@$Sedatives_Yes = addslashes($_POST['Sedatives_Yes']);
@$Sedatives_No = addslashes($_POST['Sedatives_No']);
@$Sedatives_Amount_Used = addslashes($_POST['Sedatives_Amount_Used']);
@$Sedatives_LastUsed = addslashes($_POST['Sedatives_LastUsed']);
@$Other_Yes1 = addslashes($_POST['Other_Yes1']);
@$Other_No1 = addslashes($_POST['Other_No1']);
@$Other_Amount_Used1 = addslashes($_POST['Other_Amount_Used1']);
@$Other_LastUsed1 = addslashes($_POST['Other_LastUsed1']);
@$Other_Yes = addslashes($_POST['Other_Yes']);
@$Other_No = addslashes($_POST['Other_No']);
@$Other_Amount_Used = addslashes($_POST['Other_Amount_Used']);
@$Other_LastUsed = addslashes($_POST['Other_LastUsed']);
@$Nose_EyesRunning = addslashes($_POST['Nose_EyesRunning']);
@$Nausea = addslashes($_POST['Nausea']);
@$Sneezing = addslashes($_POST['Sneezing']);
@$Vomiting = addslashes($_POST['Vomiting']);
@$Sweating = addslashes($_POST['Sweating']);
@$Diarrhea = addslashes($_POST['Diarrhea']);
@$Chills_HotFlashes = addslashes($_POST['Chills_HotFlashes']);
@$Problems_Sleeping = addslashes($_POST['Problems_Sleeping']);
@$Anxiety = addslashes($_POST['Anxiety']);
@$Headache = addslashes($_POST['Headache']);
@$Tremors = addslashes($_POST['Tremors']);
@$Hallucinations = addslashes($_POST['Hallucinations']);
@$MuscleJointAches = addslashes($_POST['MuscleJointAches']);
@$Other = addslashes($_POST['Other']);
@$Other_Withdrawal_Symptoms = addslashes($_POST['Other_Withdrawal_Symptoms']);
@$CurrentMedicalProblems1 = addslashes($_POST['CurrentMedicalProblems1']);
@$CurrentMedicalProblems2 = addslashes($_POST['CurrentMedicalProblems2']);
@$CurrentMedicalProblems3 = addslashes($_POST['CurrentMedicalProblems3']);
@$Other_Withdrawal_Symptoms4 = addslashes($_POST['Other_Withdrawal_Symptoms4']);
@$CurrentMedicalProblems5 = addslashes($_POST['CurrentMedicalProblems5']);
@$CurrentMedicalProblems6 = addslashes($_POST['CurrentMedicalProblems6']);
@$CurrentMedicalProblems7 = addslashes($_POST['CurrentMedicalProblems7']);
@$CurrentMedicalProblems8 = addslashes($_POST['CurrentMedicalProblems8']);
@$CurrentMedicalProblems9 = addslashes($_POST['CurrentMedicalProblems9']);
@$CurrentMedicalProblems10 = addslashes($_POST['CurrentMedicalProblems10']);
@$DateOfLastPeriod = addslashes($_POST['DateOfLastPeriod']);
@$BirthControl_Yes = addslashes($_POST['BirthControl_Yes']);
@$BirthControl_No = addslashes($_POST['BirthControl_No']);
@$TypeofBirthControl = addslashes($_POST['TypeofBirthControl']);
*/

//Sending Email to form owner
$pfw_header = "From: $Name\n"
  . "Reply-To: $Name\n";
$pfw_subject = "WCBM - Health Questionnaire";
$pfw_email_to = "pploesser@gmail.com";

/**
$pfw_message = "Name: $Name\n"
. "Date: $Date\n"
. "DOB: $DOB\n"
. "Age: $Age\n"
. "Weight: $Weight\n"
. "\n"
. "Reason for the visit:\n"
. "Problem/Symptom $1: Problem1\n"
. "Problem/Symptom $2: Problem2\n"
. "Problem/Symptom $3: Problem3\n"
. "\n"
. "Current Medication (and Doses)\n"
. "Current Medication $1: CurrentMed1\n"
. "Current Medication $2: CurrentMed2\n"
. "Current Medication $3: CurrentMed11\n"
. "Current Medication $4: CurrentMed4\n"
. "Current Medication $5: CurrentMed5\n"
. "Current Medication $6: CurrentMed6\n"
. "Current Medication $7: CurrentMed7\n"
. "Current Medication $8: CurrentMed8\n"
. "Current Medication $9: CurrentMed9\n"
. "Current Medication $10: CurrentMed10\n"
. "\n"
. "Medication Allergies\n"
. "Medication Allergies  $1: MedicationAllergies1\n"
. "Medication Allergies  $2: MedicationAllergies2\n"
. "Medication Allergies  $3: CurrentMed3\n"
. "Medication Allergies  $4: MedicationAllergies4\n"
. "\n"
. "Past Psychiatric History\n"
. "\n"
. "Anxiety / Nervousness:  $Anxiety_nervousness\n"
. "Paranoid Feeliongs: $Paranoid\n"
. "Depression : $Depression1\n"
. "Obsessive Thoughts: $ObsessiveThoughts\n"
. "Mood Swings: $MoodSwings1\n"
. "Obsessive Habits: $ObsessiveHabits\n"
. "Insomnia / Oversleeping: $Insomnia_Oversleeping\n"
. "Low Energy: $LowEnergy\n"
. "Problems Concentrating: $ProblemsConcentrating\n"
. "Hopeless Feelings: $HopelessFeelings\n"
. "Hearing Voices: $HearingVoices\n"
. "Thoughts About Death: $ThoughtsAboutDeath\n"
. "Visions: $Visions\n"
. "Suicide: $Suicide\n"
. "\n"
. "Past Hospitalizations\n"
. "\n"
. "Year: $Year1\n"
. "Reason for the hospital visit: $Reasonforvisit1\n"
. "Year: $Year2\n"
. "Reason for the hospital visit: $ReasonforVisit2\n"
. "Year: $Year3\n"
. "Reason for the hospital visit: $Reasonforvisit3\n"
. "\n"
. "Family History\n"
. "\n"
. "Anxiety / Nervousness: $AnxietyNervousness\n"
. "Alcoholism: $Alcoholism\n"
. "Depression: $Depression\n"
. "Drug Addiction: $DrugAddiction\n"
. "Mood Swings: $MoodSwings\n"
. "Attention Deficit: $AttentionDeficit\n"
. "Schizophrenia: $Schizophrenia\n"
. "Obsessive Compulsive Disorder: $ObsessiveCompulsiveDisorder\n"
. "Cigarettes: $Cigarettes_Yes\n"
. "Cigarettes No: $Cigarettes_No\n"
. "Cigarettes_Amount_Used: $Cigarettes_Amount_Used\n"
. "Cigarettes_LastUsed: $Cigarettes_LastUsed\n"
. "Alcohol_Yes: $Alcohol_Yes\n"
. "Alcohol_No: $Alcohol_No\n"
. "Alcohol_Amount_Used: $Alcohol_Amount_Used\n"
. "Alcohol_LastUsed: $Alcohol_LastUsed\n"
. "Opiates_Yes: $Opiates_Yes\n"
. "Opiates_No: $Opiates_No\n"
. "Opiates_Amount_Used: $Opiates_Amount_Used\n"
. "Opiates_LastUsed: $Opiates_LastUsed\n"
. "Cocaine_Yes: $Cocaine_Yes\n"
. "Cocaine_No: $Cocaine_No\n"
. "Cocaine_Amount_Used: $Cocaine_Amount_Used\n"
. "Cocaine_LastUsed: $Cocaine_LastUsed\n"
. "Marijuana_Yes: $Marijuana_Yes\n"
. "Marijuana_No: $Marijuana_No\n"
. "Marijuana_Amount_Used: $Marijuana_Amount_Used\n"
. "Marijuana_LastUsed: $Marijuana_LastUsed\n"
. "Speed_Yes: $Speed_Yes\n"
. "Speed_No: $Speed_No\n"
. "Speed_Amount_Used: $Speed_Amount_Used\n"
. "Speed_LastUsed: $Speed_LastUsed\n"
. "Sedatives_Yes: $Sedatives_Yes\n"
. "Sedatives_No: $Sedatives_No\n"
. "Sedatives_Amount_Used: $Sedatives_Amount_Used\n"
. "Sedatives_LastUsed: $Sedatives_LastUsed\n"
. "Other_Yes1: $Other_Yes1\n"
. "Other_No1: $Other_No1\n"
. "Other_Amount_Used1: $Other_Amount_Used1\n"
. "Other_LastUsed1: $Other_LastUsed1\n"
. "Other_Yes: $Other_Yes\n"
. "Other_No: $Other_No\n"
. "Other_Amount_Used: $Other_Amount_Used\n"
. "Other_LastUsed: $Other_LastUsed\n"
. "Nose_EyesRunning: $Nose_EyesRunning\n"
. "Nausea: $Nausea\n"
. "Sneezing: $Sneezing\n"
. "Vomiting: $Vomiting\n"
. "Sweating: $Sweating\n"
. "Diarrhea: $Diarrhea\n"
. "Chills_HotFlashes: $Chills_HotFlashes\n"
. "Problems_Sleeping: $Problems_Sleeping\n"
. "Anxiety: $Anxiety\n"
. "Headache: $Headache\n"
. "Tremors: $Tremors\n"
. "Hallucinations: $Hallucinations\n"
. "MuscleJointAches: $MuscleJointAches\n"
. "Other: $Other\n"
. "Other_Withdrawal_Symptoms: $Other_Withdrawal_Symptoms\n"
. "CurrentMedicalProblems1: $CurrentMedicalProblems1\n"
. "CurrentMedicalProblems2: $CurrentMedicalProblems2\n"
. "CurrentMedicalProblems3: $CurrentMedicalProblems3\n"
. "Other_Withdrawal_Symptoms4: $Other_Withdrawal_Symptoms4\n"
. "CurrentMedicalProblems5: $CurrentMedicalProblems5\n"
. "CurrentMedicalProblems6: $CurrentMedicalProblems6\n"
. "CurrentMedicalProblems7: $CurrentMedicalProblems7\n"
. "CurrentMedicalProblems8: $CurrentMedicalProblems8\n"
. "CurrentMedicalProblems9: $CurrentMedicalProblems9\n"
. "CurrentMedicalProblems10: $CurrentMedicalProblems10\n"
. "\n"
. "For women only:\n"
. "\n"
. "DateOfLastPeriod: $DateOfLastPeriod\n"
. "BirthControl_Yes: $BirthControl_Yes\n"
. "BirthControl_No: $BirthControl_No\n"
. "TypeofBirthControl: $TypeofBirthControl\n";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

//Sending auto respond Email to visitor
$pfw_header = "From: pploesser@gmail.com\n"
  . "Reply-To: pploesser@gmail.com\n";

$pfw_subject = "test";
$pfw_email_to = "$Name";
$pfw_message = "test";
@mail($pfw_email_to, $pfw_subject ,$pfw_message ,$pfw_header ) ;

echo("<p align='center'><font face='Arial' size='3' color='#FF0000'>Test</font></p>");
?>

Link to comment
Share on other sites

Ah, Darn! I see what I missed. So I got it working thanks to Ken2k7. THANK YOU Very much !!

 

One question I have now though..

 

The results showed up like this "Name: test\nDate: test\nDOB: test\nAge: test\nProblem1: I am not sure whats going on \nProblem2: hello\nProblem3: to the world\nSubmit: Submit\n"

 

In that same format.. How do I get rid of the \n just delete them from the code? How can I make this into a friendly format, any suggestions?

 

Thank you all very much for your help.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.