docmombo Posted December 31, 2008 Share Posted December 31, 2008 Okay, I am new at PHP and I think someone may be able to direct me to the right thing to do here. I am trying to run the following code. It does not work since the first PHP line runs into the closing code. Is there a way to embedd PHP code within itself to avoid this. <?php if ($slname == "") { echo "1-800-295-9100"; } else { echo "<a href='<?php siteloklogout()?>' class=topmenu><b>Logout</b></a>"; } ?> The siteloklogout() is a call in the SiteLok software we just purchased. That is the code to run that function. I want that code to only appear when the user is logged in. Any advice? Quote Link to comment Share on other sites More sharing options...
chronister Posted December 31, 2008 Share Posted December 31, 2008 <?php if ($slname == "") { echo "1-800-295-9100"; } else { echo '<a href= "'.siteloklogout().'" class="topmenu"><b>Logout</b></a>'; } ?> You don't "embed" php within itself. You simply have to concatenate properly. Nate Quote Link to comment Share on other sites More sharing options...
docmombo Posted December 31, 2008 Author Share Posted December 31, 2008 I put your code it. It seemed to improve things, but I got this on the form. /demo/htm/login.php?sitelokaction=logout Logout (Logout) is the link name. Any thoughts. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 1, 2009 Share Posted January 1, 2009 This function siteloklogout() is probably returning some character(s) that are fouling up the HTML code. Post the actual HTML code that is generated for that link. Quote Link to comment Share on other sites More sharing options...
docmombo Posted January 1, 2009 Author Share Posted January 1, 2009 Here it the HTM around it. <table width=100% align=center cellpadding=0 cellspacing=0 valign=top> <tr> <td align=center valign=center class=topmenu> <?php if ($slname == "") { echo "<a href='request.htm' class=topmenu>Request Demo</a>"; } else { echo $slname; } ?> </td> <td align=center valign=bottom class=topmenu> <?php if ($slname == "") { echo "1-800-295-9100"; } else { echo '<a href= "'.siteloklogout().'" class="topmenu"><b>Logout</b></a>'; } ?> </td> </tr> </table> Dave Quote Link to comment Share on other sites More sharing options...
revraz Posted January 1, 2009 Share Posted January 1, 2009 Why not just echo "<a href= 'siteloklogout()' class='topmenu'><b>Logout</b></a>"; Quote Link to comment Share on other sites More sharing options...
chronister Posted January 1, 2009 Share Posted January 1, 2009 I would bet that if you look into the function siteloklogout() you will find that it echo's something rather than returns it. Here is an example of what I mean. <?php function echoSomething() { echo 'This is echo\'d in the function'; } function returnSomething() { return ' This is returned in the function'; } ?> These 2 functions will do something dramatically different. The first one will echo as soon as it is called. If it is in a file that is included in the header, then it will echo at the very top of the page. The second one will return something so that you can control where it is echo'd or have it set to a variable and echo that later. I would bet that yours is echo'ing and I would also bet it is at the top of the page.... am I right? Nate Quote Link to comment Share on other sites More sharing options...
docmombo Posted January 1, 2009 Author Share Posted January 1, 2009 Unfortunately, I don't have access to see the code related to siteloklogout(). I wouldn't be surprised if you are right. My code does not have a return in it. Here is my complete page of code. Do you see anything funny? <?php ob_start(); session_start(); ?> <?php $groupswithaccess="PUBLIC"; $loginpage="login.php"; $logoutpage="login.php"; $loginredirect=1; $startpage="../secure/startpage.php"; require_once("../../slpw/sitelokpw.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>Client Login - CompuSource Systems, Inc - Credit Union Data Processor</title> <link rel=stylesheet type="text/css" href="http://www.css4cu.com/demo/testinclude/cucss1.css"> <LINK REL="SHORTCUT ICON" HREF="http://www.css4cu.com/demo/images/logo.ico"> <script type="text/javascript"> function random_imglink(){ var myimages=new Array() myimages[1]="../images/login/loginpic1.jpg" myimages[2]="../images/login/loginpic2.jpg" myimages[3]="../images/login/loginpic3.jpg" myimages[4]="../images/login/loginpic4.jpg" var ry=Math.floor(Math.random()*myimages.length) if (ry==0) ry=1 document.banners.src=myimages[ry] } </script> <meta http-equiv="description" content="CompuSource System Inc - State of the art core processing for Credit Unions. Complete turnkey systems. 25 years experience. Over 480 clients. Ongoing Support."> <meta http-equiv="keywords" content="credit union software, credit union data processing, credit union system, credit union system, credit union core processing, credit union core system, software solutions, compusource, compushare, credit union industry, credit union accounting, small credit unions, financial reporting, system tailoring"> </head> <body bgcolor="#978F8F" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" onLoad="random_imglink()"> <!-- table one --> <TABLE width=100% valign=top cellpadding=0 cellspacing=0 border=0> <tr> <td width=10%></td> <td width=80% valign=top bgcolor="#FFFFFF"> <!-- table 2 - top directory--> <table align=center valign=top cellpadding=0 cellspacing=0 border=0> <tr> <td bgcolor="#715555"> <!-- replace this code with the call to the routine when you figure this out --> <table align=center width=744 cellpadding=0 cellspacing=0 border=0> <tr> <td rowspan=2> <a href="index.htm"><img src="../images/topgraphic/toppt1.gif" width=82 height=74 alt="Credit Union Core Technology" border=0></a> </td> <td rowspan=2> <a href="index.htm"><img src="../images/topgraphic/toppt2.gif" width=301 height=74 alt="Credit Union Core Technology" border=0></a> </td> <td rowspan=2> <img src="../images/topgraphic/toppt3.gif" width=124 height=74 alt="Credit Union Core Technology" border=0> </td> <td bgcolor="#7BAD9C" valign=top> <table width=100% align=center cellpadding=0 cellspacing=0 valign=top> <tr> <td align=center valign=center class=topmenu> <?php if ($slname == "") { echo "<a href='request.htm' class=topmenu>Request Demo</a>"; } else { echo $slname; } ?> </td> <td align=center valign=bottom class=topmenu> <?php if ($slname == "") { echo "1-800-295-9100"; } else { echo '<a href= "'.siteloklogout().'" class="topmenu"><b>Logout</b></a>'; } ?> </td> </tr> </table> </td> </tr> <tr> <td valign=top> <img src="../images/topgraphic/toppt4.gif" width=237 height=60 alt="Credit Union Core Technology"> </td> </tr> </table> </td> </tr> <tr> <td bgcolor="#FFFFFF"> <script src="../testinclude/xaramenu.js"></script><script menumaker src="../menus/mainscope.js"></script> <noscript> <?php include("../testinclude/mainmenu.txt") ?> </noscript> </td> </tr> </table> <!-- table 3 --> <table align=center bgcolor="#FFFFFF" width=740 valign=top cellpadding=0 cellspacing=0 border=0> <tr> <!-- place to insert menu when items are added to our hardware solutions section --> <td width=740 valign=top rowspan=2> <table align=center width=100% valign=top cellpadding=0 cellspacing=0 border=0> <tr> <td> <br> <p align=center class=subscript> <img src="http://www.css4cu.com/demo/images/login1.gif" width=411 height=49 alt="Client Login"> </p> <table width=740 cellpadding=0 cellspacing=0 border=1 bordercolor="#DEDEDE"> <tr> <td width=185> <img name="banners" src="../images/login/loginpic1.jpg" width=184 height=254 alt="Client Login"> </td> <td width=355> <table width=95% align=center cellpadding=5 cellspacing=5 border=0> <tr> <td valign=top> <p align=center class=promo> Member Area </p> <p align=left class=normal> <?php if ($slname == "") { } else { echo "You are already logged in."; echo '<a href= "'.siteloklogout().'" class="email"><b>Logout</b></a>'; } ?> <?php if ($msg!="") print $msg; ?> <form name="siteloklogin" action="<?php print $startpage; ?>" method="GET" onSubmit="return validlogin()"> <?php siteloklogin(); ?> Username: <input type="text" name="username" value""><br><br> Password: <input type="password" name="password" value=""><br><br> <BR><BR> <a href="javascript: void forgotpw()" title="Forgot your password? Enter username or email & click link" class=subscript>Forgot your password?</a> <BR><BR> <center> <input type="Submit" name="login" value="Login"> </center> </form> </td> </tr> </table> </td> <td width=300 bgcolor="#E6E4E4"> <table width=95% align=center cellpadding=5 cellspacing=5 border=0> <tr> <td> <p align=center class=normal> <b>New Member Area</b> </p> <p align=left class=normal> Welcome to our new Member Area. We have upgraded our Client Login section to be secured behind one simple login. <BR><BR> If you have not registered for your Credit Union login, please register below. <BR><BR> <a href="registerfirst.php" class=email>Register Here!</a> </p> </td> </tr> </table> </td> </tr> </table> <BR><BR><BR><BR> </td> </tr> </table> </td> </tr> </table> <br><br> <?php include("../testinclude/footerhc.txt") ?> </td> <td width=10%> </td> </tr> </table> </body> </html> <?php ob_end_flush(); ?> Quote Link to comment Share on other sites More sharing options...
chronister Posted January 1, 2009 Share Posted January 1, 2009 /demo/htm/login.php?sitelokaction=logout Logout does this appear at the very top of the page? You can test it out by calling that function somewhere else, by itself. <?php siteloklogout() ?> If this prints something on screen, then it echos... if it does not print on screen, then it probably returns data. BTW, use code tags when you post code. It is the # button above. Nate Quote Link to comment Share on other sites More sharing options...
docmombo Posted January 1, 2009 Author Share Posted January 1, 2009 Thanks for the advice on code. I was looking through help to figure that out. I will fix that. Yes, that appears on the top of the page. I will check out the test you suggested. I think you are right. I am done for the day - Happy New Year and thanks for all your help. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 1, 2009 Share Posted January 1, 2009 Here it the HTM around it. <table width=100% align=center cellpadding=0 cellspacing=0 valign=top> <tr> <td align=center valign=center class=topmenu> <?php if ($slname == "") { echo "<a href='request.htm' class=topmenu>Request Demo</a>"; } else { echo $slname; } ?> </td> <td align=center valign=bottom class=topmenu> <?php if ($slname == "") { echo "1-800-295-9100"; } else { echo '<a href= "'.siteloklogout().'" class="topmenu"><b>Logout</b></a>'; } ?> </td> </tr> </table> I asked you to post the "the actual HTML code that is generated", i.e. when you bring the page up in your browser, right-click and view source. Then cut and paste the HTML code for that link. Quote Link to comment Share on other sites More sharing options...
docmombo Posted January 2, 2009 Author Share Posted January 2, 2009 I'm sorry. I thought you meant something else. Here is the code you asked for. <td align=center valign=bottom class=topmenu> /demo/htm/login.php?sitelokaction=logout<a href= "" class="topmenu"><b>Logout</b></a></td> Dave Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.