✔ php contact form
(Completed by Taylor Bernard on August 7, 2015)
Comments
Taylor Bernard on July 29, 2015:
good to go.
Taylor Bernard on July 30, 2015:
i see you tested the form out. only thing i havent figured out. is that the last line in the form.php code had a redirect script. i was trying to get it to popup instead. but im sure we want something nicer, like a css div that shows or something next to completion of the submit button. let me know what you think on that.
Justin Bernard on July 30, 2015:
yeah, thtsa pretty common, they either redirect to a 'success' screen, or they do it inline, we need one that does it inline so they not leave the site page they are on. often you can get one that will just add like text below the submit button that says something like 'message sent', thats what i prefer
play with this and get it working, do it first before cccd, ecsp being that insta/twitter thing being such a pain
notice the required="required" on each field. that triggers jquery to know you need to do it before it is submitted, and that field you are seeing is default jquery stuff, its prob grabbing that little image from some jquery cdn, and the rest is made with css in jquery
Taylor Bernard on July 30, 2015:
what. wheres the jquery header tag though. hows it know what 'required' refers to language wise being that vague in terminology.
Justin Bernard on July 30, 2015:
just is. jquery does all kinda of crazy stuff. required isnt a html normal keyword or anything. i didnt know what was up either, so i looked at the html/php, and noticed there was not validation, so then i looked at the fields to see if anythign looked weird, noticed that required variable, googled it, found outs
Taylor Bernard on July 30, 2015:
weird. esp to be tied to something as oldschool as a bare bones form input field.
Taylor Bernard on July 30, 2015:
ok found some code to show/hide certain divs. everyone said has to be done via AJAX but this guy is just using php somehow.
here's his example. if you leave a field out and hit submit you see its showing a red bg error div with all the missing fields listed.
if all fields are good and mail sent then go ahead and push successMessage div to ouput
-----------
php config-
function successMessage(){ $message = "Your message was sent successfully - expect a reply soon! Thank you!"; return "<div class='message'>$ message</div>"; }
function failureMessage(){ $message = "We're sorry, we were unable to send your message. Please try again."; return "<div class='message error'>$message</div>"; }
there nothign wrong with ajax, all it really is, is js
Taylor Bernard on July 30, 2015:
still trying to figure out how to tie it into my simple php form i was using before. may be easier just to use his complete form rather than modify it into mine? he just has validation fields and stuff where mine doesnt and since i'm adding a few more fields i didnt want to screw something up. just wanted to get that show/hide out of it.
Justin Bernard on July 30, 2015:
use his if you can get same form fields, whatever is easiest to get working and meet our needs
Taylor Bernard on August 4, 2015:
updated glendale with updated form. weird. all the timestamps i had on my local file glendale folder were all 7/30. so shows that i transfered them down at same time from sever. but server was showing old files.
Comments
Taylor Bernard on July 29, 2015:
Taylor Bernard on July 30, 2015:
only thing i havent figured out. is that the last line in the form.php code had a redirect script. i was trying to get it to popup instead. but im sure we want something nicer, like a css div that shows or something next to completion of the submit button. let me know what you think on that.
Justin Bernard on July 30, 2015:
play with this and get it working, do it first before cccd, ecsp being that insta/twitter thing being such a pain
Taylor Bernard on July 30, 2015:
http://client.fleeangrybear.com/realtree/glendale/index.html
dont fill in any of the fields and hit 'submit'.
it hovers a popup box 'please fill in this field' .....
where in the HELL is that box at.
not in the php. only a few lines there.
html is all simple form fields.
css is just simple box styling and bg colors
Justin Bernard on July 30, 2015:
https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=required%3D%20required%20jquery
notice the required="required" on each field. that triggers jquery to know you need to do it before it is submitted, and that field you are seeing is default jquery stuff, its prob grabbing that little image from some jquery cdn, and the rest is made with css in jquery
Taylor Bernard on July 30, 2015:
Justin Bernard on July 30, 2015:
Taylor Bernard on July 30, 2015:
Taylor Bernard on July 30, 2015:
everyone said has to be done via AJAX but this guy is just using php somehow.
here's his example. if you leave a field out and hit submit you see its showing a red bg error div with all the missing fields listed.
http://www.websitecodetutorials.com/code/php/one-webpage-php-contact-form.php
heres the code broken apart.
important parts:
css-
.message {
background: red;
color:#088a08;
}
.message.error {
background:#f5a9a9;
color:#610b0b;
}
the 2 success/fail div params
--------------
html-
<?php print $OUTPUT; ?>
looks like this is a placeholder till after the button is pressed then it populates the output with appropriate div.
----------------
php sender-
if( sendEmail( $mailConfig,$formFields ) ){
$OUTPUT = successMessage();
}else{
$OUTPUT = failureMessage();
}
if all fields are good and mail sent then go ahead and push successMessage div to ouput
-----------
php config-
function successMessage(){
$message = "Your message was sent successfully - expect a reply soon! Thank you!";
return "<div class='message'>$ message</div>";
}
function failureMessage(){
$message = "We're sorry, we were unable to send your message. Please try again.";
return "<div class='message error'>$message</div>";
}
txt to put in called div class
Justin Bernard on July 30, 2015:
there nothign wrong with ajax, all it really is, is js
Taylor Bernard on July 30, 2015:
just wanted to get that show/hide out of it.
Justin Bernard on July 30, 2015:
Taylor Bernard on August 4, 2015:
weird. all the timestamps i had on my local file glendale folder were all 7/30. so shows that i transfered them down at same time from sever. but server was showing old files.