Jump to content

I can't get the 2 Functions to write properly to the page ??


spacepoet

Recommended Posts

Hi:

 

I can't seem to get the 2 Functions to write properly to the page:

 

myLogin.php

<?php

include('../include/myConn.php'); //contains your mysql connection and table selection
include('../include/myCodeLib.php');
include('include/myAdminNav.php');

ob_start();

// Connect to server and select database.
//mysql_connect("$host", "$username", "$password")or die("cannot connect");
//mysql_select_db("$db_name")or die("cannot select DB");

// Define $myUserName and $myPassword
$myUserName=$_POST['myUserName'];
$myPassword=$_POST['myPassword'];

// To protect MySQL injection (more detail about MySQL injection)
$myUserName = stripslashes($myUserName);
$myPassword = stripslashes($myPassword);
$myUserName = mysql_real_escape_string($myUserName);
$myPassword = mysql_real_escape_string($myPassword);

$sql="SELECT * FROM myAdmins WHERE myUserName='$myUserName' and myPassword='$myPassword'";
$result=mysql_query($sql);

// Mysql_num_row is counting table row
$count=mysql_num_rows($result);
// If result matched $myUserName and $myPassword, table row must be 1 row

if($count==1){
// Register $myUserName, $myPassword and redirect to file "a_Home.php"
session_register("myUserName");
session_register("myPassword");
header("location:a_Home.php");
}
else {

echo "

<!DOCTYPE HTML>

<html>

<head>

<meta name=\"author\" content=\"MontyTheWebmaster.com\" />
<meta charset=\"ISO-8859-1\" />
<meta http-equiv=\"refresh\" content=\"5;url='Login.php'\">

<title>Admin Area</title>

<?php echo spAdminLinks(); ?>

</head>

<body>

<div id=\"siteContainer\">

<div id=\"topContainer\">
	 
</div>

	<div id=\"topMenuContainer\">
		<div id=\"topMenu\">
			 
		</div>
	</div>

<div id=\"contentContainer\">

	<div id=\"mainContent\">

			<h1>Incorrect User Name or Password.</h1>

		<p>You will now be re-directed back to the login area to try again, or <a href=\"Login.php\">click here</a>.</p>

	</div>

	<div style=\"clear: both;\"></div>

</div>

<div id=\"footerContainer\">

	<?php echo spAdminFooter(); ?>

</div>

</div>

</body>

</html>
";
}

ob_end_flush();
?>

 

Meaning, these 2:

<?php echo spAdminLinks(); ?>

<?php echo spAdminFooter(); ?>

 

I know I asked about this before, but can't remember what the solution was .. sighhh ..

 

I know it has something to do with the already being in an "echo" tag ..

 

Anyone help me out?

<?php
echo "

<!DOCTYPE HTML>

<html>

<head>

<meta name=\"author\" content=\"MontyTheWebmaster.com\" />
<meta charset=\"ISO-8859-1\" />
<meta http-equiv=\"refresh\" content=\"5;url='Login.php'\">

<title>Admin Area</title>". spAdminLinks()."

</head>

<body>

<div id=\"siteContainer\">

   <div id=\"topContainer\">
       
   </div>

      <div id=\"topMenuContainer\">
         <div id=\"topMenu\">
             
         </div>
      </div>

   <div id=\"contentContainer\">
      
      <div id=\"mainContent\">

          <h1>Incorrect User Name or Password.</h1>

         <p>You will now be re-directed back to the login area to try again, or <a href=\"Login.php\">click here</a>.</p>

      </div>

      <div style=\"clear: both;\"></div>
      
   </div>

   <div id=\"footerContainer\">

     

   </div>

</div>

</body>

</html>
";


function spAdminLinks()
{
return "test";
}
?>

I will try that, but I already defined the function like this:

include('include/myAdminNav.php');

 

myAdminNav.php:

<?php

function spAdminLinks() {
$spAdminLinks =
"

<link rel=\"stylesheet\" type=\"text/css\" href=\"include/Admin-StyleSheet.css\" />

<script type=\"text/javascript\" src=\"ckeditor/ckeditor.js\"></script>

<script type=\"text/javascript\" src=\"ckfinder/ckfinder.js\"></script>

";

return $spAdminLinks;

}

 

So I'm not sure if your idea will work, it will be writing it twice ??

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.