Need help with coding a PHP form for a website!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
briankulp
Forum Newbie
Posts: 2
Joined: Thu Apr 15, 2010 3:59 am

Need help with coding a PHP form for a website!

Post 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
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

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

Post 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.
briankulp
Forum Newbie
Posts: 2
Joined: Thu Apr 15, 2010 3:59 am

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

Post 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
User avatar
Technocrat
Forum Contributor
Posts: 127
Joined: Thu Oct 20, 2005 7:01 pm

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

Post 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.
Post Reply