Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Building Websites with PHP Contact Form & Sending Email POST Route & Data

var_dump() is posting the form data in the URL

When I fill the form and click submit, the data is posted in the URL.... (I'm using Xaamp)

screenshot: http://imgur.com/a/pQfwz

Please Help!

My code:

contact.twig:

'''

<strong>Contact</strong>
<h2>Ralph Waldo Emerson</h2>

<p>Unfortately, Ralph Waldo Emerson has been deceased for over 100 years so he's not particularly expediant at replying to email but you can make an attempt below. However, if you require face to gravestone contact you can visit his remains at:</p>
<address>
  <h4>Sleepy Hollow Cemetery</h4>
  <p>34 Bedford Street<br>
  Concord, MA 01742, United States<br>
<a href="https://www.google.com/maps/place/Sleepy+Hollow+Cemetery/@42.464126,-71.343098,15z/data=!4m2!3m1!1s0x0:0x9c41d0f83df689a6?sa=X&ei=ZCgLVZb5Io_hoASc7oHwCQ&ved=0CH0Q_BIwCw">Google Map</a></p>
</address>

<form action="" method="post">
  <fieldset>
    <input name="name" type="text" placeholder="Full Name">
    <input name="email" type="email" placeholder="Email Address">
    <textarea name="msg" placeholder="Your message..."></textarea>
  </fieldset>
  <input type="submit" class="button">
</form>

{% endblock content %}

'''

index.php: '''

date_default_timezone_set('America/Lima');

require 'vendor/autoload.php';

$app = new \Slim\Slim(array(
    'view' => new \Slim\Views\Twig()
));

$view = $app->view();
$view->parserOptions = array(
    'debug' => true,
);

$view->parserExtensions = array(
    new \Slim\Views\TwigExtension(),
);

/***** ROUTING *****/
$app->get('/', function() use($app) {
    $app -> render('about.twig');
})->name('home');

$app->get('/contact', function() use($app){
    $app -> render('contact.twig'); 
})->name('contact');

$app->post('/contact', function() use($app){
    var_dump($app->request->post());

});

$app->run();

'''

That is the default behavior of the browser. You haven't connected the form action to your routes. That's why the info is appearing in the URL.

<form action="/contact" method="post">

Will send the post data to the contact route.