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 Building Websites with PHP Contact Form & Sending Email Testing For POST Data

Qasim Hafeez
Qasim Hafeez
12,731 Points

Redirect not working properly (blank screen)

When I submit the form, I just see a blank page. The url in the address bar is the correct one for the contact page but, the screen is blank. Does anyone know why this is?

Here is my code:

$app->post('/contact', function() use($app){
    $name = $app->request->post('name');
    $email = $app->request->post('email');
    $msg = $app->request->post('msg');

    if(!empty($name) && !empty($email) && !empty($msg)){

    } else {
        //message the user that there was a problem
        $app->redirect('/contact');
    }

});

2 Answers

jason chan
jason chan
31,009 Points

just unzip and drop the completed version into the public_html

(complete version)[http://treehouse-code-samples.s3.amazonaws.com/PHP/Building-Websites-With-PHP/stage_3/s3v4-begin.zip]

jason chan
jason chan
31,009 Points

Are you doing this on treehouse workspaces? or running xamp doing this on localhost?

Qasim Hafeez
Qasim Hafeez
12,731 Points

I'm running MAMP on localhost