Hi all… first timer, so go EASY!
I’m developing a template website for a friend (its a Template Monster site) and he wants me to add a dropdown menu (select) for day of week and time of booking most suitable.
Website: www.ututor.com.au
Page in Question: http://ututor.com.au/booking.html
Help required: I’ve added the field to select the day of week in HTML (visible in view source), but Can’t get it to work (everything works but the day selected) - PLEASE NOTE HE ALSO WANTS TO ADD A TIME FOR STUDENTS TO BOOK.
MailHandler.php reads: (PLEASE NOTE > I have called the day select “days” > also need to add PreferredTime
<?php $owner_email = $_POST["owner_email"]; $headers = 'From:' . $_POST["email"]; $subject = 'A message from your site visitor ' . $_POST["name"]; $days = $POST['days']; $messageBody = ""; if($_POST['name']!='nope'){ $messageBody .= 'Visitor: ' . $_POST["name"] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['email']!='nope'){ $messageBody .= '
Email Address: ' . $_POST['email'] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['state']!='nope'){ $messageBody .= '
State: ' . $_POST['state'] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['phone']!='nope'){ $messageBody .= '
Phone Number: ' . $_POST['phone'] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['subject']!='nope'){ $messageBody .= '
Subject of study: ' . $_POST["subject"] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['days']!='nope'){ $messageBody .= '
Preferred day: ' . $_POST["days"] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['fax']!='nope'){ $messageBody .= '
Fax Number: ' . $_POST['fax'] . '
' . "\n"; $messageBody .= '' . "\n"; } if($_POST['message']!='nope'){ $messageBody .= '
Message: ' . $_POST['message'] . '
' . "\n"; } if($_POST["stripHTML"] == 'true'){ $messageBody = strip_tags($messageBody); } try{ if(!mail($owner_email, $subject, $messageBody, $headers)){ throw new Exception('mail failed'); }else{ echo 'mail sent'; } }catch(Exception $e){ echo $e->getMessage() ."\n"; } ?>So thats the issue > can someone please assist. I’m sure I’m close?
JS for those required reads:
(function($){
$.fn.extend({
forms:function(opt){
if(opt===undefined)
opt={}
this.each(function(){
var th=$(this),
data=th.data(‘forms’),
={
errorCl:‘error’,
emptyCl:‘empty’,
invalidCl:‘invalid’,
successCl:‘success’,
successShow:‘4000’,
mailHandlerURL:‘bin/MailHandler.php’,
ownerEmail:‘[email protected]’,
stripHTML:true,
smtpMailServer:‘localhost’,
targets:‘input,textarea’,
controls:‘a[data-type=reset],a[data-type=submit]’,
validate:true,
rx:{
“.name”:{rx:/^[a-zA-Z’][a-zA-Z-’ ]+[a-zA-Z’]?$/,target:‘input’},
“.state”:{rx:/^[a-zA-Z’][a-zA-Z-’ ]+[a-zA-Z’]?$/,target:‘input’},
“.email”:{rx:/^(("[\w-\s]+")|([\w-]+(?:.[\w-]+))|("[\w-\s]+")([\w-]+(?:.[\w-]+)))(@((?:[\w-]+.)*\w[\w-]{0,66}).([a-z]{2,6}(?:.[a-z]{2})?)$)|(@[?((25[0-5].|2[0-4][0-9].|1[0-9]{2}.|[0-9]{1,2}.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2}).){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})]?$)/i,target:‘input’},
“.phone”:{rx:/^+?(\d[\d-+() ]{5,}\d$)/,target:‘input’},
“.subject”:{rx:/^[a-zA-Z’][a-zA-Z-’ ]+[a-zA-Z’]?$/,target:‘input’},
“.days”:{rx:/^[a-zA-Z’][a-zA-Z-’ ]+[a-zA-Z’]?$/,target:‘input’},
“.fax”:{rx:/^+?(\d[\d-+() ]{5,}\d$)/,target:‘input’},
“.message”:{rx:/.{20}/,target:‘textarea’}
},
preFu:function(){
.labels.each(function(){
var label=$(this),
inp=$(.targets,this),
defVal=inp.val(),
trueVal=(function(){
var tmp=inp.is(‘input’)?(tmp=label.html().match(/value=’"[’"].+/),!!tmp&&!!tmp[1]&&tmp[1]):inp.html()
return defVal==’’?defVal:tmp
})()
trueVal!=defVal
&&inp.val(defVal=trueVal||defVal)
label.data({defVal:defVal})
inp
.bind(‘focus’,function(){
inp.val()==defVal
&&(inp.val(’’),.hideEmptyFu(label),label.removeClass(.invalidCl))
})
.bind(‘blur’,function(){
!inp.val()
?inp.val(defVal)
.isValid(label)
?.showErrorFu(label)
:.hideErrorFu(label)),
(.isEmpty(label)
?.showEmptyFu(label)
:.hideEmptyFu(label))
})
.bind(‘keyup’,function(){
label.hasClass(.invalidCl)
&&.isValid(label)
?.showErrorFu(label)
:.hideErrorFu(label)
})
label.find(’.’+.errorCl+’,.’+.emptyCl).css({display:‘block’}).hide()
})
.success=$(’.’+.successCl,.form).hide()
},
isValid:function(el){
var ret=true,
empt=.isEmpty(el)
if(empt)
ret=false,
el.addClass(.invalidCl)
else
$.each(.rx,function(k,d){
if(el.is(k))
d.rx.test(el.find(d.target).val())
?(el.removeClass(.invalidCl),ret=false)
:el.addClass(.invalidCl)
})
return ret
},
isEmpty:function(el){
var tmp
return (tmp=el.find(.targets).val())==’’||tmp==el.data(‘defVal’)
},
validateFu:function(){
.labels.each(function(){
var th=$(this)
.isEmpty(th)
?.showEmptyFu(th)
:.hideEmptyFu(th)
.isValid(th)
?.showErrorFu(th)
:.hideErrorFu(th)
})
},
submitFu:function(){
.validateFu()
if(!.form.has(’.’+.invalidCl).length)
$.ajax({
type: “POST”,
url:.mailHandlerURL,
data:{
name:$(’.name input’,.form).val()||‘nope’,
email:$(’.email input’,.form).val()||‘nope’,
phone:$(’.phone input’,.form).val()||‘nope’,
subject:$(’.subject input’,.form).val()||‘nope’,
days:$(’.days input’,.form).val()||‘nope’,
fax:$(’.fax input’,.form).val()||‘nope’,
state:$(’.state input’,.form).val()||‘nope’,
message:$(’.message textarea’,.form).val()||‘nope’,
owner_email:.ownerEmail,
stripHTML:.stripHTML
},
success: function(){
.showFu()
}
})
},
showFu:function(){
.success.slideDown(function(){
setTimeout(function(){
.success.slideUp()
.form.trigger(‘reset’)
},.successShow)
})
},
controlsFu:function(){
$(.controls,.form).each(function(){
var th=$(this)
th
.bind(‘click’,function(){
.form.trigger(th.data(‘type’))
return false
})
})
},
showErrorFu:function(label){
label.find(’.’+.errorCl).slideDown()
},
hideErrorFu:function(label){
label.find(’.’+.errorCl).slideUp()
},
showEmptyFu:function(label){
label.find(’.’+.emptyCl).slideDown()
.hideErrorFu(label)
},
hideEmptyFu:function(label){
label.find(’.’+.emptyCl).slideUp()
},
init:function(){
_.form=this
.labels=$(‘label’,.form)
_.preFu()
_.controlsFu()
_.form
.bind('submit',function(){
if(_.validate)
_.submitFu()
else
_.form[0].submit()
return false
})
.bind('reset',function(){
_.labels.removeClass(_.invalidCl)
_.labels.each(function(){
var th=$(this)
_.hideErrorFu(th)
_.hideEmptyFu(th)
})
})
_.form.trigger('reset')
}
}
if(!data)
(typeof opt=='object'?$.extend(_,opt):_).init.call(th),
th.data({cScroll:_}),
data=_
else
_=typeof opt=='object'?$.extend(data,opt):data
})
return this
}
})
})(jQuery)
$(function(){
$(’#contact-form’).forms({
ownerEmail:‘[email protected]’
})
})
(again > I’ve thrown in “Days” but sure this is wrong.
Thanks
Bernie in Sydney (guest)