spacepoet Posted January 31, 2011 Share Posted January 31, 2011 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 https://forums.phpfreaks.com/topic/226216-i-cant-get-the-2-functions-to-write-properly-to-the-page/ Share on other sites More sharing options...
suma237 Posted January 31, 2011 Share Posted January 31, 2011 <?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 https://forums.phpfreaks.com/topic/226216-i-cant-get-the-2-functions-to-write-properly-to-the-page/#findComment-1167771 Share on other sites More sharing options...
spacepoet Posted January 31, 2011 Author Share Posted January 31, 2011 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 https://forums.phpfreaks.com/topic/226216-i-cant-get-the-2-functions-to-write-properly-to-the-page/#findComment-1167839 Share on other sites More sharing options...
spacepoet Posted January 31, 2011 Author Share Posted January 31, 2011 OK, it does work like this: ". spAdminLinks() ." I could have swore I tried this last night, but my eyes must have been tired ... lol ... Thanks for the help. Link to comment https://forums.phpfreaks.com/topic/226216-i-cant-get-the-2-functions-to-write-properly-to-the-page/#findComment-1167885 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.