Jump to content

Recommended Posts

Topic: custom jquery/ajax form in a sidebar template page
The website

Hi everyone,
I made a custom form in a sidebar template page – a plugin is not an option. I got the validation working but the processing runs foul. Next I will explain in more detail what I did.

Let me start off by saying: I am noob (and that’s probably stretching it). My problem – in short – is that a contact form validated with the jquery validation plugin, and submitted through ajax does not end up in my mailbox. And yes, I have a form processor php scrip attached but something goes wrong. But I don’t know what.

Now I have been searching the internets for an answer. Of course I don’t thoroughly understand the javascript and php stuff. None the less I did put the necessary scripts together in accordance with the many explanations that I have read.

My own guess
Before I will show you the custom scripts I want to address what I think is going foul. I made a valid html form. I used the jquery validation plugin to use the validate function on the various fields. And I added some custom jquery to tell the validation plugin exactly what fields are required. On top of that I added ajax, via the jquery form plugin, so that the form doesn’t reload upon submittal.

Now the validation works – see for yourself here. And as soon as all fields are filled out correctly, and I press submit ajax kicks in because I see the button value change as intended. After a short load – sending sequence – the button changes to ‘message send’. But I receive no email. And I have checked my spam folder: it’s empty. In previous tests – with a different script – I did receive emails with the contact form values (but there were other issues).

I am using this contact form in a WordPress template. Perhaps it is the php processor? But I can’t see what’s wrong with that file.

Also in Firebug, under ‘console’ I see a GET string with the form values after submittal.

My question is. Can someone take a look at the form (because I think the post action might be wrong, the form processor is located in the template file), the custom jquery script and the php script? Plus after the form is successfully submitted, via ajax, I would like the form to reset, to clear all fields; how would I do that?

Btw I read somewhere I can use a WordPress function to add the admin e-mailaddress in the php form processor – where you would normally put down the receivers emailaddress. Is this true? And how would I do this?

Any help is seriously appreciated. Thank you for your time.

You can check the script and code over at Pastebin:
 

Sidebar template page containing the htlm form

http://pastebin.com/0Ucn306n

 

Custom jquery form validation script

http://pastebin.com/xxPdV7eL

 

Php form processor

http://pastebin.com/1LKVPx2v

 

Link to comment
https://forums.phpfreaks.com/topic/277951-form-processing-issue/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.