Page 1 of 1

form data not being received via email

Posted: Wed Nov 25, 2015 10:00 am
by cee lippens
hi,
when i submit my form the only data i am receiving in email is the email of the sender, no other data is coming threw!

what's going on?

thank-you
here is the code

Code: Select all

                    <?php
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
$from = 'From:gavini2@adhdclinic.com';
$to = 'ceelippens2@gmail.com';
$subject = 'adult new patient form';
$body = "firstName: $firstname \n\nlastName: $lastname \n\nEmail: $email \n\nAge: $age \n\nStreet: $street \n\nCity: $city \n\nState: $state\n\nZipcode: $zipcode\n\n cellphone: $cellphone\n\n homephone: $homephone  \n\n Employername: $employername \n\n Workstreet: $workstreet\n\n\ Workcity: $workcity\n\n Workstate: $workstate \n\n Workzipcode: $workzipcode \n\n Workphone: $workusrtel \n\n MartialStatus: $martialStatus \n\n contactname: $contactname \n\n";

if ($_POST['submit']) {
    if (mail ($to, $subject, $body, $from)) { 
        echo '<p>Your message has been sent!</p>';
    } else { 
        echo '<p>Something went wrong, go back and try again!</p>'; 
    }
}

?> 

  <form method="post" name="commentform" action="adlutf.php" autocomplete="on">
<h2 class="text-center"><strong>New Adult ADHD Patient /<br>Family And Insurance Information Form</strong></h2><hr>
		<p class="name">
          <div class="fieldBlock">
<label for="name">First Name</label>
			<input type="fi" name="firstname" id="firstname" placeholder="John " />
            </div>
  <div class="fieldBlock">

		<label for="name">Last Name</label>
			<input type="text" name="Lastname" id="lastname" placeholder=" Doe" />	
 </div>
		</p>
      
    
    
       
<p class="date">
 <div class="fieldBlock">
			<label for="Date">Date of Birth</label>

			<input type="text" name="dob" id="dob" placeholder="12/09/1977" />
           
            </div>
             <div class="fieldBlock">


		<label for="name">Age</label>
			<input type="text" name="age" id="age" placeholder="35" />
            </div>

		</p>

 <div style="clear:both;">&nbsp;</div>
	
            <p class="sex">
            
                  <label><input type="checkbox" id="CheckboxMale" name="driving">Male</label>
                   <label><input type="checkbox" id="CheckboxFemale" name="driving">Female</label>

</p>
<p><strong>*<span style="font-size:14px;color:#C33;">Attenion</span>:</strong> If you do not include a proper home address in the fields below, you're form will be discarded/deleted immediately. Answers such as n/a are not acceptable answers. We need a complete and accurate address to be able to bill you for our services, as well as creating a medical record for you.</p>
<p class="address">
 <div class="fieldBlock">
	<label for="name">Street</label>
			<input type="text" name="street" id="street" placeholder="14 Elm St." />
            </div>
             <div class="fieldBlock">
            	<label for="name">City</label>
			<input type="text" name="city" id="city" placeholder="Novi" />
            </div>
             <div class="fieldBlock">
            <label for="name">State</label>
			<input type="text" name="state" id="state" placeholder="Michigan" />
            </div>
             <div class="fieldBlock">
            <label for="name">Zip Code</label>
            
			<input type="text" name="zipcode" id="zipcode" placeholder="48220" />
            </div>
            </p>
            <div style="clear:both;">&nbsp;</div>
<p class="email">
	<label for="name">Email</label>
			<input type="email" name="email" id="email" placeholder="jondoe@gmail.com" />
            </p>
            <p class="phone">
 <div class="fieldBlock">
	<label for="name">Cell Phone</label>
			<input type="tel" name="usrtel" id="usrtel" placeholder="734-790-7790" />
            </div>
             <div class="fieldBlock">
            	<label for="name">Home Phone</label>
			<input type="tel" name="usrtel" id="usrtel" placeholder="734-790-7790" />
            </div>
            </p>
             <div style="clear:both;">&nbsp;</div>
             
             <p class="employername">
         
<label for="name">Employer Name</label>
			<input type="text" name="employername" id="employername" placeholder="Mega Company " />
            </p>
                         <label for="name">Employer Address</label>  
            <p class="address">
 <div class="fieldBlock">
	<label for="name">Street</label>
			<input type="text" name="workstreet" id="workstreet" placeholder="10005 Main St." />
            </div>
 
             <div class="fieldBlock">
         
            	<label for="name">City</label>
			<input type="text" name="workcity" id="workcity" placeholder="Novi" />
            </div>
             <div class="fieldBlock">
            <label for="name">State</label>
			<input type="text" name="workstate" id="workstate" placeholder="Michigan" />
            </div>
             <div class="fieldBlock">
            <label for="name">Zip Code</label>
            
			<input type="text" name="workzipcode" id="workzipcode" placeholder="48220" />
            </div>
            </p>
            <div style="clear:both;">&nbsp;</div>
            </div>
            <p class="phone">

	<label for="name">Work Phone</label>
			<input type="tel" name="usrtel" id="usrtel" placeholder="734-790-7790" />
          </p>
            <p class="martialstatus">
          	<label for="name">Martial Status</label>
          <select name="Martial Status">
                <option value="double chocolate">Single</option>
                <option value="vanilla">Married</option>
                <option value="strawberry">Divorced</option>
              
        </select>
        </p>
       <p class="name">
       <label for="name">Emergency Contact</label>
          <div class="fieldBlock">
<label for="name">First Name</label>
			<input type="text" name="name" id="name" placeholder="John " />
            </div>
  


  <label><span style="font-size:14px;color:#C33;">Thank-you for filling out and submitting the form.</span></label>

     
    
      
		<p class="submit">

                     <input id="submit" name="submit" type="submit" value="Submit"/>
			

		</p>

	</form>

php code for a drop down menu for data to be sent to email

Posted: Wed Nov 25, 2015 10:02 am
by cee lippens
how do i write the php code to receive drop down menu data in php via email?

Code: Select all

            <p class="martialstatus">
          	<label for="name">Martial Status</label>
          <select name="Martial Status">
                <option value="double chocolate">Single</option>
                <option value="vanilla">Married</option>
                <option value="strawberry">Divorced</option>
              
        </select>

Re: form data not being received via email

Posted: Wed Nov 25, 2015 2:49 pm
by requinix
All those variables you put into the email? You never defined them. You have to define them just like you did for $name and $email.

Re: php code for a drop down menu for data to be sent to ema

Posted: Wed Nov 25, 2015 5:24 pm
by Christopher
There are several step to get from a form submission to receiving an email.

- Create HTML form
- Receive form data
- Validate and filter the data
- Build email body
- Send email

The first step is to put the code below into a <form>. I have cleaned up your HTML a little.

Code: Select all

      <p class="martialstatus">
          <label for="martial_status">Martial Status</label>
          <select name="martial_status" id="martial_status">
                <option value="double chocolate">Single</option>
                <option value="vanilla">Married</option>
                <option value="strawberry">Divorced</option>
           </select>
       </p>

Re: php code for a drop down menu for data to be sent to ema

Posted: Sun Nov 29, 2015 2:44 pm
by cee lippens
thanks,
i am asking how to write the php code to send the answer from the drop sown menu..


here's the whole form and php


Code: Select all

                    <?php
$firstname=$_POST['firstname'];
$lastName=$_POST['lastname'];
$age=$_POST['age'];
$street=$_POST['street'];
$city=$_POST['city'];
$state=$_POST['state'];
$zipcode=$_POST['zipcode'];
$email=$_POST['email'];
$cellPhone=$_POST['cellphone'];
$homePhone=$_POST['homephone'];
$employername=$_POST['employername'];
$workstreet=$_POST['workstreet'];
$workcity=$_POST['workcity'];
$workstate=$_POST['workstate'];
$workzipcode=$_POST['workzipcode'];
$workphone=$_POST['workusrtel'];

$martialStatus=$_POST['martialStatus'];
$contactname=$_POST['contactname'];
$workzipcode=$_POST['workzipcode'];

$message=$_POST['message'];
$from = 'From:gavini2@adhdclinic.com';
$to = 'ceelippens2@gmail.com';
$subject = 'adult new patient form';
$body = "firstName: $firstname \n\n lastname: $lastname \n\nEmail: $email \n\nAge: $age \n\nStreet: $street \n\nCity: $city \n\nState: $state\n\nZipcode: $zipcode\n\ncellphone: $cellPhone\n\nhomephone: $homePhone  \n\n Employername: $employername \n\n Workstreet: $workstreet\n\n Workcity: $workcity\n\n Workstate: $workstate \n\n Workzipcode: $workzipcode \n\n workphone: $workusrtel \n\n MartialStatus: $martialStatus \n\n contactname: $contactname \n\n";

if ($_POST['submit']) {
    if (mail ($to, $subject, $phone, $body, $from)) { 
        echo '<p>Your message has been sent!</p>';
    } else { 
        echo '<p>Something went wrong, go back and try again!</p>'; 
    }
}

?> 

  <form method="post" name="commentform" action="adlutf.php" autocomplete="on">
<h2 class="text-center"><strong>New Adult ADHD Patient /<br>Family And Insurance Information Form</strong></h2><hr>
		<p class="name">
          <div class="fieldBlock">
<label for="name">First Name</label>
			<input type="fi" name="firstname" id="firstname" placeholder="John " />
            </div>
  <div class="fieldBlock">

		<label for="name">Last Name</label>
			<input type="text" name="Lastname" id="lastname" placeholder=" Doe" />	
 </div>
		</p>
      
    
    
       
<p class="date">
 <div class="fieldBlock">
			<label for="Date">Date of Birth</label>

			<input type="text" name="dob" id="dob" placeholder="12/09/1977" />
           
            </div>
             <div class="fieldBlock">


		<label for="name">Age</label>
			<input type="text" name="age" id="age" placeholder="35" />
            </div>

		</p>

 <div style="clear:both;">&nbsp;</div>
	
            <p class="sex">
            
                  <label><input type="checkbox" id="CheckboxMale" name="driving">Male</label>
                   <label><input type="checkbox" id="CheckboxFemale" name="driving">Female</label>

</p>
<p><strong>*<span style="font-size:14px;color:#C33;">Attenion</span>:</strong> If you do not include a proper home address in the fields below, you're form will be discarded/deleted immediately. Answers such as n/a are not acceptable answers. We need a complete and accurate address to be able to bill you for our services, as well as creating a medical record for you.</p>
<p class="address">
 <div class="fieldBlock">
	<label for="name">Street</label>
			<input type="text" name="street" id="street" placeholder="14 Elm St." />
            </div>
             <div class="fieldBlock">
            	<label for="name">City</label>
			<input type="text" name="city" id="city" placeholder="Novi" />
            </div>
             <div class="fieldBlock">
            <label for="name">State</label>
			<input type="text" name="state" id="state" placeholder="Michigan" />
            </div>
             <div class="fieldBlock">
            <label for="name">Zip Code</label>
            
			<input type="text" name="zipcode" id="zipcode" placeholder="48220" />
            </div>
            </p>
            <div style="clear:both;">&nbsp;</div>
<p class="email">
	<label for="name">Email</label>
			<input type="email" name="email" id="email" placeholder="jondoe@gmail.com" />
            </p>
            <p class="phone">
 <div class="fieldBlock">
	<label for="name">Cell Phone</label>
			<input type="tel" name="usrtel" id="usrtel" placeholder="734-790-7790" />
            </div>
             <div class="fieldBlock">
            	<label for="name">Home Phone</label>
			<input type="tel" name="usrtel" id="usrtel" placeholder="734-790-7790" />
            </div>
            </p>
             <div style="clear:both;">&nbsp;</div>
             
             <p class="employername">
         
<label for="name">Employer Name</label>
			<input type="text" name="employername" id="employername" placeholder="Mega Company " />
            </p>
                         <label for="name">Employer Address</label>  
            <p class="address">
 <div class="fieldBlock">
	<label for="name">Street</label>
			<input type="text" name="workstreet" id="workstreet" placeholder="10005 Main St." />
            </div>
 
             <div class="fieldBlock">
         
            	<label for="name">City</label>
			<input type="text" name="workcity" id="workcity" placeholder="Novi" />
            </div>
             <div class="fieldBlock">
            <label for="name">State</label>
			<input type="text" name="workstate" id="workstate" placeholder="Michigan" />
            </div>
             <div class="fieldBlock">
            <label for="name">Zip Code</label>
            
			<input type="text" name="workzipcode" id="workzipcode" placeholder="48220" />
            </div>
            </p>
            <div style="clear:both;">&nbsp;</div>
            </div>
            <p class="phone">

	<label for="name">Work Phone</label>
			<input type="tel" name="usrtel" id="usrtel" placeholder="734-790-7790" />
          </p>
            <p class="martialstatus">
          	<label for="name">Martial Status</label>
          <select name="Martial Status">
                <option value="double chocolate">Single</option>
                <option value="vanilla">Married</option>
                <option value="strawberry">Divorced</option>
              
        </select>
        </p>
       <p class="name">
       <label for="name">Emergency Contact</label>
          <div class="fieldBlock">
<label for="name">First Name</label>
			<input type="text" name="name" id="name" placeholder="John " />
            </div>
  


  <label><span style="font-size:14px;color:#C33;">Thank-you for filling out and submitting the form.</span></label>

     
    
      
		<p class="submit">

                     <input id="submit" name="submit" type="submit" value="Submit"/>
			

		</p>

	</form>

Re: php code for a drop down menu for data to be sent to ema

Posted: Sun Nov 29, 2015 4:26 pm
by Celauran
What sort of errors are you encountering?

Re: php code for a drop down menu for data to be sent to ema

Posted: Sun Nov 29, 2015 4:44 pm
by Christopher

Code: Select all

    if (mail ($to, $subject, $phone, $body, $from)) { 
Take a look at the PHP documentation for the mail() function (http://php.net/manual/en/function.mail.php). The parameters are To, Subject, Body and Headers. The documentation explains how to build headers for From, ReplyTo, CC, etc.

Re: php code for a drop down menu for data to be sent to ema

Posted: Mon Nov 30, 2015 8:10 am
by cee lippens
i am not sure how to write the php for the drop down menu, when an item is selected how is that send via the php with the rest of the body of info to e-mail? also not all the info is being received via email, like lastname does not come through.
thanks

Re: php code for a drop down menu for data to be sent to ema

Posted: Mon Nov 30, 2015 8:42 am
by cee lippens
hi Celauran,

i was receiving most of the data, but am not not receiving any mail when i hit submit? now?????? help :-)

Re: form data not being received via email

Posted: Mon Nov 30, 2015 8:45 am
by cee lippens
below is what i added,now i am not receiving any email at all when i hit submit

Code: Select all

 <?php
$firstname=$_POST['firstname'];
$lastName=$_POST['lastname'];
$checkboxm=$_POST['checkboxm'];
$checkboxf=$_POST['checkboxf'];
$dob=$_POST['dob'];
$age=$_POST['age'];
$street=$_POST['street'];
$city=$_POST['city'];
$state=$_POST['state'];
$zipcode=$_POST['zipcode'];
$email=$_POST['email'];
$cellPhone=$_POST['cellphone'];
$homePhone=$_POST['homephone'];
$employername=$_POST['employername'];
$workstreet=$_POST['workstreet'];
$workcity=$_POST['workcity'];
$workstate=$_POST['workstate'];
$workzipcode=$_POST['workzipcode'];
$workusrtel=$_POST['workusrtel'];
$martialStatus=$_POST['martialStatus'];
$contactname=$_POST['contactname'];
$econtactphone=$_POST['econtactphone'];
$EmergencyRelationship=$_POST['EmergencyRelationship'];
$referredname =$_POST['referredname '];
$date_today =$_POST['date_today'];
$pharmacyname =$_POST['pharmacyname'];
$pharmacyaddress =$_POST['pharmacyaddress'];
$phonepharmacy =$_POST['phonepharmacy'];

$message=$_POST['message'];
$from = 'From:gavini2@adhdclinic.com';
$to = 'ceelippens2@gmail.com';
$subject = 'adult new patient form';
$body = "firstName: $firstname \n\n lastname: $lastname \n\ncheckboxm: $checkboxm \n\ncheckboxf: $checkboxf\n\nEmail: $email \n\ndob: $dob \n\nAge: $age \n\nStreet: $street \n\nCity: $city \n\nState: $state\n\nZipcode: $zipcode\n\ncellphone: $cellPhone\n\nhomephone: $homePhone  \n\n Employername: $employername \n\n Workstreet: $workstreet\n\n Workcity: $workcity\n\n Workstate: $workstate \n\n Workzipcode: $workzipcode \n\n workphone: $workusrtel \n\n MartialStatus: $martialStatus \n\n contactname: $contactname \n\n econtactphone: $econtactphone \n\n EmergencyRelationship: $EmergencyRelationship \n\n referredname: $referredname \n\n date_today: $date_today\n\n pharmacyname: $pharmacynamen\n  pharmacyaddress: $pharmacyaddress n\n phonepharmacy: $phonepharmacy n\n";

if ($_POST['submit']) {
    if (mail ($to, $subject, $body, $from)) { 
        echo '<p>Your message has been sent!</p>';
    } else { 
        echo '<p>Something went wrong, go back and try again!</p>'; 
    }
}

?> 

    
           <form method="post" name="commentform" action="adlutf.php" autocomplete="on">
<h2 class="text-center"><strong>New Adult ADHD Patient /<br>Family And Insurance Information Form</strong></h2><hr>
		<p class="name">
          <div class="fieldBlock">
<label for="name">First Name</label>
			<input type="text" name="firstname" id="firstname" placeholder="John " />
            </div>
  <div class="fieldBlock">

		<label for="name">Last Name</label>
			<input type="text" name="lastname" id="lastname" placeholder=" Doe" />	
 </div>
		</p>
      
    
    
       
<p class="date">
 <div class="fieldBlock">
			<label for="Date">Date of Birth</label>

			<input type="text" name="dob" id="dob" placeholder="12/09/1977" />
           
            </div>
             <div class="fieldBlock">


		<label for="name">Age</label>
			<input type="text" name="age" id="age" placeholder="35" />
            </div>

		</p>

 <div style="clear:both;">&nbsp;</div>
	
            <p class="sex">
            
                  <label><input type="checkbox" id="Checkboxm" name="driving">Male</label>
                   <label><input type="checkbox" id="Checkboxf" name="driving">Female</label>

</p>
<p><strong>*<span style="font-size:14px;color:#C33;">Attenion</span>:</strong> If you do not include a proper home address in the fields below, you're form will be discarded/deleted immediately. Answers such as n/a are not acceptable answers. We need a complete and accurate address to be able to bill you for our services, as well as creating a medical record for you.</p>
<p class="address">
 <div class="fieldBlock">
	<label for="name">Street</label>
			<input type="text" name="street" id="street" placeholder="14 Elm St." />
            </div>
             <div class="fieldBlock">
            	<label for="name">City</label>
			<input type="text" name="city" id="city" placeholder="Novi" />
            </div>
             <div class="fieldBlock">
            <label for="name">State</label>
			<input type="text" name="state" id="state" placeholder="Michigan" />
            </div>
             <div class="fieldBlock">
            <label for="name">Zip Code</label>
            
			<input type="text" name="zipcode" id="zipcode" placeholder="48220" />
            </div>
            </p>
            <div style="clear:both;">&nbsp;</div>
<p class="email">
	<label for="name">Email</label>
			<input type="email" name="email" id="email" placeholder="jondoe@gmail.com" />
            </p>
            <p class="phone">
 <div class="fieldBlock">
	<label for="name">Cell Phone</label>
			<input type="text" name="cellphone" id="cellphone" placeholder="734-790-7790" />
            </div>
             <div class="fieldBlock">
            	<label for="name">Home Phone</label>
			<input type="text" name="homephone" id="homephone" placeholder="734-790-7790" />
            </div>
            </p>
             <div style="clear:both;">&nbsp;</div>
             
             <p class="employername">
         
<label for="name">Employer Name</label>
			<input type="text" name="employername" id="employername" placeholder="Mega Company " />
            </p>
                         <label for="name">Employer Address</label>  
            <p class="address">
 <div class="fieldBlock">
	<label for="name">Street</label>
			<input type="text" name="workstreet" id="workstreet" placeholder="10005 Main St." />
            </div>
 
             <div class="fieldBlock">
         
            	<label for="name">City</label>
			<input type="text" name="workcity" id="workcity" placeholder="Novi" />
            </div>
             <div class="fieldBlock">
            <label for="name">State</label>
			<input type="text" name="workstate" id="workstate" placeholder="Michigan" />
            </div>
             <div class="fieldBlock">
            <label for="name">Zip Code</label>
            
			<input type="text" name="workzipcode" id="workzipcode" placeholder="48220" />
            </div>
            </p>
            <div style="clear:both;">&nbsp;</div>
            </div>
            <p class="phone">

	<label for="name">Work Phone</label>
			<input type="tel" name="workusrtel" id="workusrtel" placeholder="734-790-7790" />
          </p>
            <p class="martialstatus">
          	<label for="name">Martial Status</label>
          <select name="Martial Status">
                <option value="double chocolate">Single</option>
                <option value="vanilla">Married</option>
                <option value="strawberry">Divorced</option>
              
        </select>
        </p>
       <p class="name">
       <label for="name">Emergency Contact</label>
          <div class="fieldBlock">
<label for="name">Full Name</label>
			<input type="text" name="contactname" id="contactname" placeholder="John " />
            </div>
  

  <div class="fieldBlock">

		<label for="name">Last Name</label>
			<input type="text" name="name" id="name" placeholder=" Doe" />	
 </div>
		</p>
        <div style="clear:both;">&nbsp;</div>
        <p class="phone">

	<label for="name">Emergency Contact Phone</label>
			<input type="tel" name="econtactphone" id="econtactphone" placeholder="734-790-7790" />
          </p>
            <p class="EmergencyRelationship">
        
          	<label for="name">Emergency Contact Relationship</label>
          <select name="Martial Status">
                <option value="double chocolate">Spouse</option>
                 <option value="strawberry">Partner</option>
                <option value="vanilla">Mother</option>
                <option value="strawberry">Father</option>
                 <option value="strawberry">Sister</option>
                  <option value="strawberry">Brother</option>
                     <option value="strawberry">GrandParent</option>
                       <option value="strawberry">Friend</option>
                        <option value="strawberry">Other</option>
                        
              
        </select>
        </p>
   <p class="referred ">
            <label for="name">Who referred you to our office?</label>
            
			<input type="text" name="referredname" id="referredname" placeholder="Jane Doe" />
        
            </p>
      	<p class="submit">

                     <input id="submit" name="submit" type="submit" value="Submit"/>
			

		</p>

	</form>

Re: php code for a drop down menu for data to be sent to ema

Posted: Mon Nov 30, 2015 3:50 pm
by Christopher
cee lippens wrote:i am not sure how to write the php for the drop down menu, when an item is selected how is that send via the php with the rest of the body of info to e-mail?
When you set the name of a HTML form element, that name is used to put the value in the $_POST array.

Code: Select all

<input type="checkbox" name="foo" value="bar">
// or
<select name="foo">
<option value="bar">
<option value="baz">
</select>
// both are put into
$foo = $_POST['foo'];
cee lippens wrote:also not all the info is being received via email, like lastname does not come through.
If the are not in the message body, then you are not putting them into $body, are using the wrong variable, or have the wrong name for the $_POST element.