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 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,008 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,008 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