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

Php file does not at all work

I am working in Notepad++ trying to send the text content of an element from one web page to another with php, but php does not at all seem to work. When I set the form's action attribute to the php page, it just displays all the code I have written on the page rather than working. Even when I use

<?php include 'Phpfile.php' ?>

in the page I want to send the information to, it still does not do anything. I'm pretty new to php so if anyone could tell me what I'm doing wrong, I would be very appreciative.

2 Answers

Sure Mikkel, here is the element on the first page I'm trying to send:

<textarea type = text id = rant-input name = rant></textarea>

Here is the element on another page that I want to recieve the information:

<?php include 'Processor1.php'?>
<div id = info-div></div>

Here is the php file, called Processor1.php, again very new to php so I could have made a thousand mistakes:

<?php

$doc = new DomDocument;

// We need to validate our document before referring to the id
$doc->validateOnParse = true;
$doc->Load('Rant.html');

$doc->getElementById('rant-input');

$doc2 = new DomDocument;

// We need to validate our document before referring to the ids
$doc2->validateOnParse = true;
$doc2->Load('Community.html');

$doc2->getElementById('info-div');


$doc2->nodeValue = $doc->nodeValue;

header('Location: Community.html');

exit();

?>

Thanks for any help

Why does the php just show up as the code I wrote rather than html?

Nvm, didn't realize I had to install a web server cause php is a server side language