Better PHP Form validation and attachment option in a Quote Form
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Hello, bountify members.

I have a PHP based quote page, where customers can request a quote. However I'm looking to improve few things on it.

Things to Improve

1 - Better input validation

2 - Better captcha

Things to add

1 - Ability for customer to attach up to 5 images (2MB size) which would be send along with the form content via Mailgun.

Here is the current code for current form: https://pastebin.com/RG8yR3Zd

Do you need only server side input validation?
Codeword 3 months ago
Hey, I have completed your code.Let me know how you like to receive it, mail or GitHub ?. Thank you
Codeword 3 months ago
awarded to Codeword

Crowdsource coding tasks.

1 Solution

Winning solution

Hey, I have completed your code.Let me know how you like to receive it, mail or GitHub ?.
Thank you.

Hey there, my email is taras@citrx.me, validation wise would be nice if it was on server side, that way it less likely to be tempered with.
tdp 3 months ago
I have mailed you the code please have a look a it. Thank You
Codeword 3 months ago
Hmm. It seems to fire off but there is no Confirmation that message was send/failed and nothing comes into my inbox...
tdp 3 months ago
Try to just send raw email, without attachment, if email goes, than check with a single attachment.Because I am sure, that all the file processing is 100% correct, It' may the the problem with settings in sendmessage function, Please check and let me know.Thank you
Codeword 3 months ago
Still same result.
tdp 3 months ago
okay, do one thing there is a variable named $mail->SMTPDebug=0; under the sendmessage function set it to 2 to debug
Codeword 3 months ago
This way you will be able to know what the probelm is, If ther is any problem with phpmail it will show
Codeword 3 months ago
Let me know, what error pop up.
Codeword 3 months ago
okay let me check, don't worry, it wii be fixed count on me.Thank you
Codeword 3 months ago
are you using laravel ?
Codeword 3 months ago
God no. Custom made PHP mini framework in a way, pain in the ass to maintain but what's done is done :)
tdp 3 months ago
hahahhah, okay, Run the script barebone, with all the include files. and tell me what it say,
Codeword 3 months ago
meanwhile I am creating a Digital ocean server to test the code
Codeword 3 months ago
Hey tdp, give me the contents on the php file inside which you have include my code, so that I may format the code properly, as per the error it seems that, you have included the code incorrectly Thats what it s saying variable undefined, and the if condition at the top of code is failing and control of code is not being able to enter inside the starting if condition, and so the send message function is not executing.Thank you
Codeword 3 months ago
More over if you want to confirm that the script runs correctly, run it as I have sent you, don,t make any modification for the time being, apart from the setting required to send mail, and let me know.Thank you
Codeword 3 months ago
essentially quote.php calls a template.php which calls page.php which then calls quote.tpl.php (it's a nightmare to be honest, but it something i coded and it works) Anyways check your email. I will send you the code that's being included.
tdp 3 months ago
okay I am checking,
Codeword 3 months ago
hey, Tdp, I have uploaded your website in my server and everything is working perfectly.Look for yourself you will be very happy. Thank you. here is the link http://lanedane.com/Quote/quote.php
Codeword 3 months ago
After you have looked at the site, let me know, I will mail the files to you.Thank you
Codeword 3 months ago
Hey just checked, I got a test email from you but when i tried to send one i never got anything. Any idea?
tdp 3 months ago
That's because the data you entered failed the validation test or the files you attached exceeds 2 mb
Codeword 3 months ago
Did you check, http://lanedane.com/Quote/quote.php I have hosted you site here. enter some valid data and it will work. enter data in format shown below eg name = Pankaj Borah email = someone@something.com phone = 757-657-7574 make sure the total file size altogether is <=2mb
Codeword 3 months ago
Interesting, I have all required fields filled out, the captcha is correct as far as I can see and the file I was trying to send is 84kb only
tdp 3 months ago
you have probably entered some data incorrectly, wait let me send anothre mail with attachment to prrof its working.
Codeword 3 months ago
Hmm. Interesting http://i.imgur.com/2H4Wqgh.jpg, I send it in that format, never arrived. I got your email truth... this is odd
tdp 3 months ago
the name you enter is wrong , it should be John Smith
Codeword 3 months ago
this is the way I have set the regex exp
Codeword 3 months ago
Ah, well okay it works then. I'm gonna clean up the validation truth :) because not everyone is going to be grammatical and use upper cases nor is anyone gonna format there phone number :) send me the files and i will award this bounty
tdp 3 months ago
Check your mail, tdp Thank YOU
Codeword 3 months ago
make sure folders( fonts, PHPMailer, Quote) , generate.php resides under the same parent folder.By the way send_email.php is not important, you can delete it.
Codeword 3 months ago
Also a tip would be appreciated, If you WOULD like to.Thank you
Codeword 3 months ago
Even if no tip no problem, Any help in future you can contact me.I would be glad.Thank you and have a nice day.And One more thing, I am removing the server. after you download the files.
Codeword 3 months ago
I am terminating the server, oaky.
Codeword 3 months ago