-
PHP Code:
<?php
$to = "josh@gscapedesign.com";
$subject = "Greenscape Customer Inquiry";
$message = "Customer name: " . $_POST['name'] . "\r\n" .
"Phone number: " . $_POST['phone'] . "\r\n" .
"Email: " . $_POST['email'] . "\r\n" ."\r\n" .
"Contact: " . $_POST['contact'] . "\r\n" ."\r\n";
if(isset($_POST[serviceItem])) {
if(isset($_POST[serviceItem])) {
$message .= "Services: ".implode(", ", $_POST[serviceItem])."\r\n";
}
}
$message .= "Budget: " . $_POST['budget'] . "\r\n" .
$message .= "Anything Else: " . $_POST['other'] . "\r\n" .
$from = $_POST['email'];
$headers = "From: $from" . "\r\n";
$headers = "Bcc: kroge16@tigers.lsu.edu" . "\r\n" ;
mail($to,$subject,$message,$headers) ;
?>
this is the current php
-
HTML Code:
<form action="email_form.php" method="post" name="contact_gscape" id="contact_gscape">
<span id="sprytextfield1">
<label for="name"><span class="form_text">Name</span></label>
<input type="text" name="name" id="name" />
<span class="textfieldRequiredMsg">A contact name is required.</span></span>
<br />
<span id="sprytextfield2">
<label for="phone" class="form_text">Phone Number</label>
<input type="text" name="phone" id="phone" />
<span class="textfieldRequiredMsg">A phone number is required.</span><span class="textfieldInvalidFormatMsg">Please enter a valid phone number.</span></span>
<br />
<span id="sprytextfield3">
<label for="email" class="form_text">Email</label>
<input type="text" name="email" id="email" />
<span class="textfieldRequiredMsg">An email address is required.</span><span class="textfieldInvalidFormatMsg">Please enter a valid email address.</span></span>
</p>
<span id="contact">
<label for="label">What is the best way to contact you?</label>
<select name="contact" size="1" id="contact">
<option value="Phone">Phone</option>
<option value="Email">Email</option>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span>
</p>
<span class="form_text">What Greenscape services would you like to know more about?</span>
<br />
<label>
<input name="serviceItem[]" type="checkbox" id="landscape design and construction" value="landscape design and construction" />
<span class="form_text">Landscape Design & Construction</span></label>
<br />
<label>
<input name="serviceItem[]" type="checkbox" id="hardscape design and construction" value="hardscape design and construction" />
<span class="form_text">Hardscape Design & Construction</span></label>
<br />
<label>
<input name="serviceItem[]" type="checkbox" id="grounds maintenance" value="grounds maintenance" />
<span class="form_text">Grounds Maintenance</span></label>
<br />
<label>
<input name="serviceItem[]" type="checkbox" id="irrigation and drainage systems" value="irrigation and drainage systems" />
<span class="form_text">Irrigation & Drainage Systems</span></label>
<br />
<label>
<input name="serviceItem[]" type="checkbox" id="lighting" value="lighting" />
<span class="form_text">Lighting</span></label>
</p>
<span class="form_text">What is your budget?</span><span id="level1">
<label for="budget"></label>
<select name="budget" id="budget">
<option value="$0 - $500">$0 - $500</option>
<option value="$501-$1000">$501-$1000</option>
<option value="$1001-$5000">$1001-$5000</option>
<option value="$5000+">$5000+</option>
</select>
<span class="selectRequiredMsg">Please select an item.</span></span>
</p>
<span id="sprytextarea1">
<label for="other" class="form_text">Anything else?</label>
<br />
<textarea name="other" id="other" cols="45" rows="2"></textarea></span><br />
<input name="Submit" type="submit" value="Email Us" />
</form>
that would be the "relevant" html - let me know if you need more, though.
-
I don't see why it's not working. Try clearing your cache, and make sure you select at least one checkbox.
I just tested it myself with a print call to $message instead of mail() and it works just fine.
-
Ok, seems to be a little better, any reason its posting twice?
Customer name: Katie
Phone number: 1-XXX-XXX-XXXX
Email: katiebugla@yahoo.com
Contact: Phone
Services: landscape design and construction, hardscape design and construction, lighting
Anything Else: Please let this work.
katiebugla@yahoo.comBudget: $0 - $500
Customer name: Katie
Phone number: 1-XXX-XXX-XXXX
Email: katiebugla@yahoo.com
Contact: Phone
Services: landscape design and construction, hardscape design and construction, lighting
Anything Else: Please let this work.
katiebugla@yahoo.com
-
It's functional at the moment, so THANK YOU!
-
Hmm. It's conceivable that if the data is sent twice (e.g., the form is submitted twice) then the data could be repeated, since it is appending data.
A simple solution would be to disable the submit button once the form is submitted.
-
Thank you JShor, how would I "disable" the submit button? As of now, once the submit button is pushed, the php page loads saying "thank for your your inquiry... blah blah blah" - I don't know if one has to do with the other, but that's what happens for the user at the moment.
-
It's pretty simple to do.
In your form tag, place the onsubmit event to select the button and disable it. All you have to do is modify your <form> tag.
Code:
<form action="email_form.php" method="post" name="contact_gscape" id="contact_gscape" onsubmit="document.getElementById('submit_btn').disabled = 'disabled'">
And then set the ID of the submit button to "submit_btn".
Code:
<input name="Submit" type="submit" value="Email Us" id="submit_btn" />
-
Ok, one last question:
The client is now getting emails like this:
Customer name: gfdgd
Phone number: gfdg
Email: ggdf@yt.fr <mailto:ggdf@yt.fr>
Best way to contact: Phone
Services: landscape design and construction, hardscape design and construction, grounds maintenance, irrigation and drainage systems, lighting
Anything Else:
ggdf@yt.frBudget: $0 - $500
anyway to prevent what seems like spam emails???
-
Also, still doubling the data in the form...