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

Phil White
PLUS
Phil White
Courses Plus Student 9,519 Points

PHP code at top of page?

Hi,

I'm currently doing the PHP track and everything is going well but when the page loads it has the normal page but then at the top it is showing the code like "array(3) => string (4) => string (17) and so on.

How do i make it so this doesn't show?

Thanks in advance

3 Answers

You have to remove this:

Phil White
Phil White
Courses Plus Student 9,519 Points

Ok thanks done that but now it is showing the input like Name: Email: Message: ?

Kevin Korte
Kevin Korte
28,149 Points

That's coming from the echo $email_body line. Remove that too.

I'd have to see your code to be sure, but you might want to search for 'print_r' in your code.

Phil White
PLUS
Phil White
Courses Plus Student 9,519 Points

Heres my code:

<?php 

var_dump($_POST);
$name = $_POST["name"];
$email = $_POST["email"];
$message = $_POST["message"];
$email_body = "";
$email_body = $email_body . "Name: " .$name . "\n";
$email_body = $email_body . "Email: " .$email . "\n";
$email_body = $email_body . "Message: " .$message; 
echo $email_body;

$pageTitle = "Contact Mike";
$section = "contact";

include("inc/header.php");

?>


    <div class="section page">

        <div class="wrapper">

            <h1>Contact</h1>

            <p> Thanks for the email! i&rsquo;ll be in touch shortly.</p>

        </div>

    </div>

<?php include("inc/footer.php"); ?>