Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialibbhfsmeaf
4,568 PointsPHP for HTML forms.
I have yet to learn PHP and cannot do so at the moment, so can someone help me or link me to a resource that will allow me to retrieve data from the forms on my website (http://desimara.com - click the request button)?
I want to retrieve their first name, last name, email, any of the descriptions they fill out, if at all, and the files they upload.
7 Answers
Test Net
21,518 PointsFor a clear picture check this http://teamtreehouse.com/library/build-a-simple-php-application and look at Adding a Contact Form. Randy Hoyt will take you step by step in php contact form.
If any other questions please let me know.
Good luck pal!
Regards, Mihai
Test Net
21,518 PointsIf you want to collect the data from the fields you need to use $_Get["name"]. Please find below a very simple example:
Your html file:
<form action="contact-form.php" method="get">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
Your contact-form.php:
$name = $_GET["name"];
$email= $_GET["email"];
echo "Hi, your name is $name and your email is $email";
Please let me know if that helps.
Regards, Mihai
ibbhfsmeaf
4,568 PointsHelps heaps, thanks!
One more thing.. the .php is only for me to use, right? What I mean by that is I wouldn't post it to my websites files, correct?
And does the same method work for getting the images and description? For example, to get first name, last name, email, I just use $_GET["name"] and use the name of the inputs that I labelled, such as email, last_name, first_name?
What about the files? Would I just use the same php method rather using fileField (the name for my files)?
And the same for the textarea?
ibbhfsmeaf
4,568 PointsUnfortunately I cannot watch any courses on Treehouse as my account is on pause, hence why I needed to ask this rather than learning it myself =( and I'm on tight schedule so Googling things isn't very efficient if I want to get this done as soon as possible.
Test Net
21,518 PointsRIght, so check this out http://www.html-form-guide.com/contact-form/contact-form-attachment.html
Unfortunately I can't help you write the entire sendmail php, busy at work.
A bit of research should help you sort your problem.
Mihai
ibbhfsmeaf
4,568 PointsI've actually just managed to reactivite my subscription, so I will proceed with the PHP course. Thanks for everything!
Test Net
21,518 PointsThat's great Lansana!