Page 1 of 1

Need help with coding a PHP form for a website!

Posted: Thu Apr 15, 2010 4:03 am
by briankulp
Hey guys, first post, I am not sure if I will get an answer to this, as I am very new to PHP... I mostly have an understanding on how to implement pre-written code, but I have no knowledge of writing my own from scratch as of yet.

I am working on my portfolio site, and I need a way for potential clients to email me from my page with php. I can't really explain the way I currently have the contact form set up, so I recommend you take a look at it at http://www.madebyboom.com/final and you will find it at the bottom of the first page.

What is going to be needed PHP wise to get that form submitted to my email address? All of my searches on Google leave me with solutions for a standard "Name, Email" form, and I am not sure if I can even achieve a form such as this one.

Any help? Thoughts? Code?

Thank you so much.

Brian

Re: Need help with coding a PHP form for a website!

Posted: Thu Apr 15, 2010 8:20 am
by Technocrat
All those fields are pulldowns, so they will show up in your $_POST. So you just need to fetch and validate that data. Like:

Code: Select all

if (isset($_POST['services'])) {
  $services = $_POST['services'];
} else {
  //error
}
Then put all those fields into a message body. Then using php mail() (yuck) or swiftmailer put the message in an email and send it off.

Re: Need help with coding a PHP form for a website!

Posted: Thu Apr 15, 2010 12:48 pm
by briankulp
Thank you so much for your quick reply. Not all of them are pull downs, there are a couple blank input lines that someone can fill in the blanks the information.

So with your code that you provided me, would I just have 1 of those blocks of code for every form field?

Would I need to include anything else in the code?

Thanks a lot.
Brian

Re: Need help with coding a PHP form for a website!

Posted: Fri Apr 16, 2010 8:02 am
by Technocrat
What I gave you is the gist of what to do. It will get you close to what you need. But you still need to verify it and error check it. Then put it in a message and send it. My advice would be to get a PHP book or search for tutorials. There are plenty of resources out there.