PHP Help Needed

Want to chit chat about anything, do it here...
Politics, religion, literature, movies, technology, and simple chitchat,
both serious and fun. Have a green drink, sit down and enjoy!

PHP Help Needed

Postby Honor » 25 Nov 2011, 10:24

Okay, so I totally couldn't think of a place to put this :P

I'm a website developer (mostly HTML and CSS, and a tad bit of PHP - can read but not write). I have a development subdomain for my main site. It can be found at dev.mochajavascript.com. If you take a look at that page, you'll see I'm trying out setting up single passwords for each project I'm working on. The idea is to hand my clients their own password, and it only works for that particular project.

I'm not looking for anything super secure. I'm looking more for a simple log-in. One of my ex-coworkers had this on his splash pages for any site he was working on, and I liked the concept.

I've got majority of the code worked out, but for the life of me I can't get it to recognize the correct passwords. No matter what I do, it keeps bouncing the error back at me. Can someone take a look at these codes and tell me what I'm doing wrong? It's got to be something simple...

/scripts/view.php
Code: Select all
<?php
$WPStyles = "http://dev.mochajavascript.com/WP-Styles/";
$BP = "http://dev.mochajavascript.com/BP-2.0.9/phpBB3/";
$Harwell = "http://dev.mochajavascript.com/Harwell/";

$oops = "http://dev.mochajavascript.com/wrongpassword.html";

$passWP = $_POST['WP'];
$passBP = $_POST['BP'];
$passHarwell = $_POST['Harwell'];

if($passWP == "opensaysme"){
echo"<html><head><meta http-equiv=\"refresh\"content=\"1;url=$WPStyles\"></head></html>";
}

if($passBP == "seedling"){
echo"<html><head><meta http-equiv=\"refresh\"content=\"1;url=$BP\"></head></html>";
}

if($passHarwell == "congressionalvalue"){
echo"<html><head><meta http-equiv=\"refresh\"content=\"1;url=$Harwell\"></head></html>";
}

else{echo"<html><head><meta http-equiv=\"refresh\"content=\"1;url=$oops\"></head></html>";}

?>


index.html
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">




<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>MochaJava Site Development</title>

<link rel="stylesheet" type="text/css" href="/scripts/nice.css"/>

</head>





<body>

<h1>What's Chrissie Doing Now?</h1>

<div class="this">

<p>NO PEEKING! (unless I says you can...)</p>

<center>
<form name="form" method="post" action="/scripts/view.php">

<table border="0" cell-padding:"5px">

<!-- MAKE SURE TO UPDATE view.php! -->

<tr>
<td style="text-align: right; padding-right: 10px; color:#F60;">Word Press Styles</td>
<td>Password: <input type="password" name="WP" />
<input type="submit" value="Submit" /></td>
</tr>

<tr>
<td style="text-align: right; padding-right: 10px; color:#F60;">BP Development</td>
<td>Password: <input type="password" name="BP" />
<input type="submit" value="Submit" /></td>
</tr>

<tr>
<td style="text-align: right; padding-right: 10px; color:#F60;">Harwell Site</td>
<td>Password: <input type="password" name="Harwell" />
<input type="submit" value="Submit" /></td>
</tr>

</table>

</form>
</center>

</div>

<div class="feet" style="text-align:center"><a href="http://www.MochaJavaScript.com">www.MochaJavaScript.com</a></div>


</body>


</html>
BluePlanet RP
my own creation.

Host: Host Monster
Version: 3.0.9
Honor    
STG Moderator
STG Moderator
 
Posts: 328
Joined: 23 Dec 2010, 10:53
Gender: Female
phpBB Knowledge: 2




phpBB Academy at StarTrekGuide
Support STG
Using PayPal Donate

Re: PHP Help Needed

Postby Honor » 25 Nov 2011, 10:58

Hah! Fixed it myself :) Google searches are amazing - IF you use the right terms :P Here's the code now, for legacy's sake.

index.html
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">




<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>MochaJava Site Development</title>

<link rel="stylesheet" type="text/css" href="/scripts/nice.css"/>

</head>





<body>

<h1>What's Chrissie Doing Now?</h1>

<div class="this">

<p>NO PEEKING! (unless I says you can...)</p>

<center>
<form name="form" method="post" action="/view.php">

<table border="0" cell-padding:"5px">

<!-- MAKE SURE TO UPDATE view.php! -->

<tr>
<td style="text-align: right; padding-right: 10px; color:#F60;">Word Press Styles</td>
<td>Password: <input type="password" name="WP" />
<input type="submit" value="Submit" /></td>
</tr>

<tr>
<td style="text-align: right; padding-right: 10px; color:#F60;">BP Development</td>
<td>Password: <input type="password" name="BP" />
<input type="submit" value="Submit" /></td>
</tr>

<tr>
<td style="text-align: right; padding-right: 10px; color:#F60;">Harwell Site</td>
<td>Password: <input type="password" name="Harwell" />
<input type="submit" value="Submit" /></td>
</tr>

</table>

</form>
</center>

</div>

<div class="feet" style="text-align:center"><a href="http://www.MochaJavaScript.com">www.MochaJavaScript.com</a></div>


</body>


</html>


view.php
Code: Select all
<?php

$passWP = $_POST['WP'];
$passBP = $_POST['BP'];
$passHarwell = $_POST['Harwell'];

if (($passWP == "opensaysme" ))
{
Header("Location:/WP-Styles/");
exit();
}

if (($passBP == "seedling" ))
{
Header("Location:/BP-2.0.9/phpBB3/");
exit();
}

if (($passHarwell == "congressionalvalue" ))
{
Header("Location:/Harwell/");
exit();
}

else{Header("Location:wrongpassword.html");
exit();}

?>
BluePlanet RP
my own creation.

Host: Host Monster
Version: 3.0.9
Honor    
STG Moderator
STG Moderator
 
Posts: 328
Joined: 23 Dec 2010, 10:53
Gender: Female
phpBB Knowledge: 2

Re: PHP Help Needed

Postby TimN » 24 Dec 2011, 10:24

Wouldn't the use of .htaccess password control be easier and more secure?
"Just smile and wave boys, smile and wave. Remember, cute and cuddly." - The Penguins
User avatar
TimN    
Supporter
Supporter
 
Posts: 372
Joined: 17 Nov 2008, 16:24
Location: Ceti Alpha V
Favorite Team: London Silly Nannies
Gender: Male
phpBB Knowledge: 5

Re: PHP Help Needed

Postby Honor » 28 Dec 2011, 20:11

Security's not the issue - I kid not, most of my users don't know how to copy and paste (had to travel 45 mins to one customer's house to set up his bookmarks for him and sign in to Google Analytics because he couldn't copy/paste the password I gave him....)

There's no security threats here. This is just to create a form of curtain from the generic outside world from the company's personal website while it's still being developed.
BluePlanet RP
my own creation.

Host: Host Monster
Version: 3.0.9
Honor    
STG Moderator
STG Moderator
 
Posts: 328
Joined: 23 Dec 2010, 10:53
Gender: Female
phpBB Knowledge: 2

Re: PHP Help Needed

Postby Obsidian » 29 Dec 2011, 00:11

Honor wrote:Security's not the issue


Skiddies troll the internet looking for anything they can reach with tons of automated probe scripts. Security is always an issue; don't be naive.
うるさいうるさいうるさい!

StopForumSpam Spam Reporting Database
Giving xrumer and friends a great big "screw you" since 2007.
User avatar
Obsidian    
Supporter
Supporter
 
Posts: 2250
Joined: 04 Mar 2008, 23:35
Gender: Male
phpBB Knowledge: 10

Re: PHP Help Needed

Postby Honor » 31 Dec 2011, 09:32

Okay, let me rephrase that - Security may be an issue, but it's not a worry. In example, I have one client who has a deli. The website is nothing more than an online menu. However, their domain is now considered live, but we don't want an unfinished website on their domain. (the domain is on their paper menus which will be handed out soon - on a time crunch myself...). So it's not a matter of confidential data being hidden, but rather a spot where the client can look at the progress of their site without it being "live" to the outside world. Who care's if trolls get into an deli's online menu? :D

For a much more sensitive issue, I'd definitely be looking at a more secure form of protection. But right now, I'm not really trying to protect anything.

EDIT: I did work for one company that actually put a php splash page curtain on their customer's live domain for the very same reason, and did all the development behind that splash page on the domain. That's probably a better idea, though it's no less "secure" - but easier for the customers to get to, I suppose. Something to look to in the new year :)
BluePlanet RP
my own creation.

Host: Host Monster
Version: 3.0.9
Honor    
STG Moderator
STG Moderator
 
Posts: 328
Joined: 23 Dec 2010, 10:53
Gender: Female
phpBB Knowledge: 2

Re: PHP Help Needed

Postby Obsidian » 31 Dec 2011, 09:43

Honor wrote:Okay, let me rephrase that - Security may be an issue, but it's not a worry. In example, I have one client who has a deli. The website is nothing more than an online menu. However, their domain is now considered live, but we don't want an unfinished website on their domain. (the domain is on their paper menus which will be handed out soon - on a time crunch myself...). So it's not a matter of confidential data being hidden, but rather a spot where the client can look at the progress of their site without it being "live" to the outside world. Who care's if trolls get into an deli's online menu? :D

For a much more sensitive issue, I'd definitely be looking at a more secure form of protection. But right now, I'm not really trying to protect anything.

EDIT: I did work for one company that actually put a php splash page curtain on their customer's live domain for the very same reason, and did all the development behind that splash page on the domain. That's probably a better idea, though it's no less "secure" - but easier for the customers to get to, I suppose. Something to look to in the new year :)


then don't hook up a domain to the site - just edit the hosts file on the computer you're on. point the domain to the IP in the hosts file, and it'll "work", but not for anyone without that hosts file change. allows you to develop easily, present the possible results, and keep normal people from seeing the work in progress.
うるさいうるさいうるさい!

StopForumSpam Spam Reporting Database
Giving xrumer and friends a great big "screw you" since 2007.
User avatar
Obsidian    
Supporter
Supporter
 
Posts: 2250
Joined: 04 Mar 2008, 23:35
Gender: Male
phpBB Knowledge: 10

Re: PHP Help Needed

Postby Honor » 31 Dec 2011, 09:51

Now this is very new to me, and I'm not sure how to pull it off. =/ The pains of a self-taught non-programmer :P I know with my host, to assign a domain to a folder, there's a place to do so, but nowhere does it allow me to do anything with IPs themselves. I wouldn't know where to start with changing that.

Welcome to learn tho! Care to teach? :D
BluePlanet RP
my own creation.

Host: Host Monster
Version: 3.0.9
Honor    
STG Moderator
STG Moderator
 
Posts: 328
Joined: 23 Dec 2010, 10:53
Gender: Female
phpBB Knowledge: 2

Re: PHP Help Needed

Postby Obsidian » 31 Dec 2011, 11:42

Don't assign the record on the domain registrar's end so soon - don't point it to that server's IP, but set up the domain on the host's end to point to that folder.

Then modify your hosts file (windows, it's at...uhhh C:\windows\system32\drivers\etc\hosts or something like that) to add in the entry as needed
The file itself contains instructions on how to format entries - run the program you use to edit it, also, as administrator.

ed: it's C:\Windows\System32\drivers\etc\hosts exactly on windows. Linux, /etc/hosts
うるさいうるさいうるさい!

StopForumSpam Spam Reporting Database
Giving xrumer and friends a great big "screw you" since 2007.
User avatar
Obsidian    
Supporter
Supporter
 
Posts: 2250
Joined: 04 Mar 2008, 23:35
Gender: Male
phpBB Knowledge: 10

Re: PHP Help Needed

Postby Honor » 04 Jan 2012, 17:55

Sorry I'm very lost :( I'm not self hosted, and I'm running a Mac to boot. I'm hosted through hostmonster.com and have all my client's websites under my "main" website though it doesn't read that way from the browser. I might be missing something in your instructions, but I've never had a "host" send me any files for my computer - unless you're talking about through Xamp?
BluePlanet RP
my own creation.

Host: Host Monster
Version: 3.0.9
Honor    
STG Moderator
STG Moderator
 
Posts: 328
Joined: 23 Dec 2010, 10:53
Gender: Female
phpBB Knowledge: 2

Next

Return to Ten Forward Lounge

Who is online

Users browsing this forum: No registered users and 13 guests