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 trialKonrad Pilch
2,435 PointsPHP Forms
HI,
Im doing same as treehouse with Randy on form but, im doing portfolio . I saved it in xampp as html and the php file as php. The php file works, but , images dont work . If i open it not in xampp, the image works but the php is broke. What im missing? even if i save both as php its wonrg.
Konrad Pilch
2,435 PointsHI its :
<form method="post" action="contact-process.php">
<div class="form-group">
<input type="email" class="form-control" name="email" id="email" placeholder="Enter email">
</div>
<div class="form-group">
<input type="text" class="form-control" name="name" id="name" placeholder="Your Name">
</div>
<div class="form-group" id="messageContact">
<textarea class="form-control" name="message" id="message" placeholder="Message"></textarea>
</div>
<div class="btnContact">
<button type="submit" class="btn btn-warning buttonContact">Submit!</button>
</div>
</form>
When i click on
<?php
echo "It doesnt work";
?>
The it exactly show me this line of code <?php etc.. but if i save my file as php, my images do not work but the code does
Kristian Terziev
28,449 PointsCould you post and the code with the images you are talking about?
Konrad Pilch
2,435 PointsImages all over the place in the code added with CSS . They work fine but now when i save it with PHP on local server. I mean that they work , but if i save them on xampp they dont work.
3 Answers
Dan Martin
33,150 Pointsshow the source of one of the broken images... the server sees the as relative to its server root path. not local machine path.
Konrad Pilch
2,435 Points.header{
background:url('../../img/img2.jpg') center;
height: 100%;
width:100%;
background-attachment: fixed;
background-size: cover;
-moz-box-shadow: inset 40px 0 0 0 #000000;
-webkit-box-shadow: inset 0 0 40px #000000;
box-shadow: inset 0 0 40px #000000;
}
.profilePic{
background: url('../../images/me.jpg');
background-size: cover;
width:100%;
height:447.5px;
min-height: 100%;
border-radius: 10%;
border:3px solid #FFF;
}
They both dont work
Dan Martin
33,150 PointsAs a habit I always like to store images in a assets folder on the server public root directory, so I can easily access images with '/assets/images/me.jpg' so no matter where you are in the directory structure you can access you images, JS, CSS files.
So in your site folder you have an assets directory, and in that assets folder you have an images folder a css folder and a js folder:
--SiteName
--assets
--images
--css
--js
That way your images are all in one spot, and have the same path syntax to your files. I hope this makes sense.
Konrad Pilch
2,435 PointsI think i get you what you mean but i have folders like images,css,js etc.. and there is also index.php or html. So its all clean and in one foleer. So if you go and open my Portfolio code , these folders will apear clean . But i have to use ../../ i dont know why .
If you ment that?
Dan Martin
33,150 PointsEssentially "/" represents your root directory, so no matter what directory you are in starting with "/" takes you the root or base folder. "../" is navigating up one directory from your current position, and ../../ goes up two directories.
Let's say you have two folders in your site "images" and "css"... Inside that css folder you have your style.css file that references your me.jpg image in your images folder. There are two ways to reference that image "/images/me.jpg" or "../images/me.jpg" Starting with "/" says I want to start from the root and access the images directory and select me.jpg, starting with ".." says I want to go up one directory then go into the "/images/" directory and select me.jpg.
Think of it navigating your folders and "../" is like a navigation back button, and starting with "/" starts you at the beginning.
Does that help any?
Konrad Pilch
2,435 Pointsohh i get it now i think. Basicaly with / you go straight away to your root instead of using ../ ? or did i missed something? bdw i will try it tomorrow night like 18h from now , around.
Kristian Terziev
28,449 PointsKristian Terziev
28,449 PointsHello Konrad,
Could you post your code? Just wrap it with (```) without the brackets.