PHP Mail & Ajax: Message does not contain any form data -


I am using jQuery's AJAX function to send messages with a contact form -

 Click $ ('form button') (function () {$ ("input"). RemoveClass ("error"); $ ("texture"). RemoveClass ("error"); var name = $ ( $ ("Name"); $ ("name") (name == "name =" name == "name" || name == "name") {$ ("# name"). # Name "). Focus (); Return Back;} var Email = $ (" # Email "). Val (); if (email ==" "= email ==" email "|| email ==" ePost "$ "(" #Email "). AddClass ('Error'); $ (" # Email "). Focus (); Usage Val (); Val (); Val (); if (message == "") {$ ("# message"). AddClass ('error'); $ ("# message") Focus (); Return Back;} // Non-Verification Field var Phone = $ ("Input # Phone"). Val (); // Collect Data var post = 'name =' + name + 'and email = '+ Email +' and phone = '+ phone +' and message = '+ message; // disable limit of form = document.form [0] for .elements.length; for (i = 0; i & lt; Boundary; i ++) {document.forms [0]. [Original] [i] .disabled = true; } // data $. Send AZ ({Type: "Post", URL: "Form_Handler.PHP", Data: Post, Success: Function () {$ ('div.contact form'). Animate ({Opacity: 0.25}, function () { $ ('Div.contact div.confirm'). FadeIn (200);})}}, error: function () {$ ('div.contact form'). Animate ({opacity: 0.25}, function () { $ ('Div.contact div.deny'). FadeIn (200);})}}}); return false; });  

I know that this is the safest way because I reveal the mail file in my JS code but still I should do this before I try to do something else. I have the settings in the above fields (name, email, phone, and message) and "form_handler.php" in my contact form -

  & lt ;? Php header ('content-type: text / html; charset = UTF-8'); $ Name = $ _POST ['name']; $ Email = $ _POST ['email']; $ Phone = $ _POST ['phone']; $ Message = $ _POST ['message']; $ To = "staffan.estberg@gmail.com"; $ Theme = "Meddelande fran x.se"; $ Body = "---------------------------------------------- -------------------------------------------------- ------------------------ \ n \ n "; $ Body = "Meddelande fran $ name: \ n \ n"; $ Body = "$ Message \ n \ n"; $ Body = "Avsarion app: $ email \ n"; $ Body = "Acknowledgment Telephone Telephone: $ phone \ n \ n"; $ Body = "--------------------------------------------- --- ----------------------------------------------- --- ---------------------- "; $ Header = "to: $ email"; Mail ($ to $, $ theme, $ body, $ header); ? & Gt;  

When I add the script, then I manage to generate a message, although there is no form data in it, do not I miss something?

I think that you really want to pass a JSON array instead of the GET-style string Data parameters.

Something like this:

  post = {'name': name, ...}  

Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -