I am working on a site for class, and i have a form system. My friend is working on the design, and therefore the index site is actually just this:
<!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=iso-8859-1" />
<title>Nail n' Bolts man</title>
<link href="../../styles/main.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="../../js/main.js"></script>
</head>
<body>
<div id="main">
<center>
<div id="header">
Nails & Bolts APS - Admin side
<img src="../images/header.jpg" alt="header" width="" height="" />
</div>
<?php require('php/newEmployee.php'); ?>
</center>
</div>
</body>
</html>
Then in newEmployee.php i also require another file called varibleEcho.php Basically this file just has a function with a switch case statement, echoing different code depending on what you call from newEmployee.php
however for some reason, when i check the source of the site with google chrome, it seems that the echoing cleans everything of except the stuff i echo. This means my metadata css jquery and such dissapers.
Any ideas on why it has this behaviour?
Edit:
Here is the entire site (indes.php up there):
newEmployee.php
<?php
require('php/variableEcho.php');
if(!isset($_POST['rank']) || !isset($_POST['fname']) || !isset($_POST['lname']) || !isset($_POST['initials']))
{
variableEcho(0);
variableEcho(1);
}
else if($_POST['rank'] == '' || $_POST['fname'] == '' || $_POST['lname'] == '' || $_POST['initials'] == '')
{
variableEcho(0);
variableEcho(3);
variableEcho(1);
}
else if($_POST['password'] != '')
{
echo $_POST['password'];
$hasLetter = false;
$hasNumber = false;
$hasLength = false;
$pwd = $_POST['password'];
$strlen = strlen($pwd);
$pwdarr = str_split($pwd);
$ints = 0;
$chars = 0;
foreach($pwdarr as $x)
{
if(is_int($x))
{
$ints++;
}
if(ctype_alpha($x))
{
$chars++;
}
}
if($ints >= $strlen || $chars >= $strlen)
{
variableEcho(0);
variableEcho(4);
variableEcho(1);
}
if($strlen >= 8)
{
variableEcho(0);
variableEcho(4);
variableEcho(1);
}
}
?>
variableEcho
<?php
function variableEcho($echoSelect)
{
switch($echoSelect)
{
case 0:
echo('
<form action="" method="post">
<table>
');
break;
case 1:
echo('
<tr>
<td><label for="fname">First name*</label></td>
<td><input type="text" name="fname" id="fname"/></td>
</tr>
<tr>
<td><label for="lname">Last name*</label></td>
<td><input type="text" name="lname" id="lname"/></td>
</tr>
<tr>
<td><label for="rank">Rank*</label></td>
<td><input type="text" name="rank" id="rank"/></td>
</tr>
<tr>
<td><label for="initials">Initials (3 length)*</label></td>
<td><input type="text" name="initials" id="initials"/></td>
</tr>
<tr>
<td><label for="password">Password</label></td>
<td><input type="text" name="password" id="password"/></td>
</tr>
<tr>
<td><input type="submit"/></td>
</form>
');
break;
case 2:
echo('
<tr>
<td><div class="errText">A password is required for admins.</div></td>
<td></td>
</tr>
');
break;
case 3:
echo('
<tr>
<td><div class="errText">Please fill out all the obligatory fields.</div></td>
<td></td>
</tr>
');
case 4:
echo('
<tr>
<td><div class="errText">The password need to be of atleas one letter, one number, and 8 long.</div></td>
<td></td>
</tr>
');
break;
default:
echo('
biscuit
');
break;
}
}
?>
I figured out my issue, and it was sadly a simple one 😛
require ‘newEmployee.php’;
would include that php file. In that file i required another one, where the filepath were relative to newEmployee.php locaiton. I now instead include both variableEcho, and newEmployee from the main file.