javascript - If option selected true, then post it, else show error PHP -


Sorry to ask this, but I can not find anywhere I am watching ... okay, okay I do not know I see ... well, I have this contact form. I made it, so whatever it will send to my email on the form but I only know how to work with simple forms, which only works with stars, now I need to add a list of options , And when a person chooses that option he will email me that value. Here's the code:

PHP code

  & lt; Php $ main_email = "samplemail@mail.com"; $ C_acc = htmlspecialchars ($ _POST ["account"]); ---- & gt; String from $ C_location = htmlspecialchars ($ _ POST ["location"]); ---- & gt; String from $ C_server = htmlspecialchars ($ _ POST ["server"]); ---- & gt; This option is assumed to be $$ error = 0; If (strlen ($ c_acc) & lt; 1) {----> If the length of the string is less than 1, then error = error returns +++; } If (strollon ($ c_location) <1) {---- & gt; If the length of the string is less than 1, then error = error returns +++; } If (strenel ($ c_server) <1) {---- & gt; I tried to do with the string, but it is assumed that the option has been selected or not, and do not give me any error if an option selecet $ error ++; }  

And here the form I is used on the html page:

  & lt; Form class = "contactform" action = "sendmail.php" method = "post" & gt; & Lt; P class = "form_info" & gt; Account & lt; Period class = "required" & gt; * & Lt; / Span & gt; & Lt; / P & gt; & Lt; Input id = "c_acc" type = "text" name = "account" /> & Lt; P class = "form_info" & gt; Location & lt; Span class = "required" & gt; * & Lt; / Span & gt; & Lt; / P & gt; & Lt; Input id = "c_location" type = "text" name = "password" /> & Lt; P class = "form_info" & gt; Server & lt; Span class = "required" & gt; * & Lt; / Span & gt; & Lt; / P & gt; & Lt; Select id = "c_server" name = "server" & gt; & Lt; Option value = "NNY" & gt; Nn & lt; / Options & gt; & Lt; Option value = "SNY" & gt; SNY & lt; / Options & gt; & Lt; Option value = "nj" & gt; NJ & lt; / Options & gt; & Lt; Option value = "CA" & gt; Ca & lt; / Options & gt; & Lt; Option value = "TX" & gt; TX & lt; / Options & gt; & Lt; / Select & gt;  

And finally it is a JS file

  function validate_contactform () {$ ('. Contactform'). Append ('& lt; div id = "c_loader"> ';); Hide $ ('# C_submit'). Var c_acc = $ ('# c_acc'), c_location = $ ('# c_location'), c_server = $ ('# c_server'), var filter = / ^ (\ w + (?: \. \ W +) * ) @ ((: \ W + \) * \ w [\ w -] {0,66}?). \ ([Az] {2,6} (:?? \ [Az] {2})). $ / I; Var error_exist = 0; If (c_acc.val (). Length & lt; 1) {c_acc.addClass ('error'); Error_exist ++; } And {c_acc.removeClass ('error'); } If (c_location.val (). Length & lt; 1) {c_location.addClass ('error'); Error_exist ++; } And {c_location.removeClass ('error'); } If (c_server.val (). Length & lt; 1) {c_server.addClass ('error'); Error_exist ++; } And {c_server.removeClass ('error'); } If (error_exist> 0) {$ ('# c_loader'). Remove (); $ ('# C_submit') Show ().; } Else {var dataString = 'acc =' + c_acc.val () + 'location =' + c_location.val () + 'server =' + c_server.val (); $ .Azax ({type: "post", url: "sending mail.fp"), data: data string, success: function (feedback) {if (response == "sent") {$ ('# c_loader'). ); $ ('. Contactform'). The message has been sent successfully! We will soon be in touch with you & lt; / div & gt; ';) else {$ (' $ (' # C_submit '). $ (' Contactform '). (' & Lt; div class = "noti_error" & gt; An error occurred while sending your message & lt; / div & gt; ');}  

OK, sorry for the long post again ... I do not know what to change or will send the price of this option .. As you can see, the form only The wire was able to send ... like, only f The type was typed on ... not selected ... please help, I do not know what to do now ...


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

lua - HowTo create a fuel bar -