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 trial

PHP

John Levy
John Levy
1,451 Points

Problems with my php code

I made a sign up form. The HTML and CSS works but I am new to PHP and having trouble getting it to work. The PHP code is on lines 32-57 in the HTML code shown in the code pen attached below. http://codepen.io/Johned22/pen/qqVGgB

I also inclided the other php code in the HTML side in the code shown below- http://codepen.io/Johned22/pen/WoXBmM

When the user submits the form I want the user to get a automatic e-mail with a link attahced which they can click on and move onto the next step. What do I need to change to make this work? Thanks in advance

1 Answer

Joel Bardsley
Joel Bardsley
31,249 Points

Hi John,

To help get you started, you should know that your current php code is not capturing the input values from your form. PHP doesn't use class selectors like JavaScript, so in order to pass the values from the form to your php file, your input tags need the name attribute as follows:

<input type="text" name="email">

Then you can retrieve the value in your php file using the $_POST (or $_GET) variable:

<?php
  $email = $_POST["email"]; // needs to be the value of the "name" attribute for your input tag
?>

Alena covers post variables in this video if you need further information or a reminder.