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?

Link to comment
Share on other sites

<?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";
}
?>

Link to comment
Share on other sites

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 ??

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.