PHP / MySQL Login Area...

SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
Watch

will7

VIP Member
Impact
29
Well, I have a client login area at my business site, www.rednerve.com. Now, as you will see, to the right, there is an area with two text boxes and "client login" above it.

You can login with:

username: test2
password: testing

Now, what I want to happen is, when a client logs in (lets just say, for example, test2 logs in) then that client login section at the right should change to say: "You are currently logged in as test2" And also a logout link should be there.

My site runs on a template, i.e, all my pages are based on one Dreamweaver template (not template as in, TemplateMonster, template as in page designed in Dreamweaver and used throughout the site). Is there a way I can use an IF ... ELSE statement to change to a different template with the login information?

Or, is there another way to do this? Now, I have not had much luck in this forum lately, so, I hope I have more luck this time! I hope you understand my question, thanks in advance.

Will.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
spekta to the rescue!

yes ofcourse it's possible, here's how you would do it:
Code:
<?php session_start();
$template = ( isset($_SESSION['template']) ) ? $_SESSION['template'] : "main.dwt"; ?>
<!-- InstanceBegin template="/Templates/<?php echo $template ?>" codeOutsideHTMLIsLocked="false" -->

i'm not entirely sure how dreamweaver templates work but thats seems like it should work...

nice website btw
 
0
•••
Thanks for the nice website comment. I'll give this a whirl later. I feel really ill at the moment :( :(

I'm sorta confused on the code, so, lets give template names. Say the main template is main.dwt (which it is) and the code with the login is logintemp.dwt - how would that change the code? Also, could you explain the code. Like, in sections what it does.

Also, on the login template, would I just edit the client login bit with some PHP code saying "You are logged in as $username" and a variable definition at the top of the page?
 
Last edited:
0
•••
the script says if the session variable contains info about which template to show, show that template, otherwise show main.dwt by default, if you want to show a different template for specific users, set $_SESSION['template'] to the name of the template file when they're logging in, i.e. $_SESSION['template'] = 'bettertemplate.dwt';
 
0
•••
I could use some help!

D-: I am wanting something similar but I need the hole package Login, Register whose on line, Logout ect. I'm too not having any luck here in these forums.

:$: NOTE: I am willing to pay for help (through pay pal only) Below is the link to my original post.


http://www.webdesigntalk.net/showthread.php?p=539544#post539544

I am using Yahoo GeoCities (Page Builder) below are some of what GeoCities has to offer in my package (Standerd)


Add-Ons
AlbumWizards
Choose a Site Building Tool
Compare Site Building Tools
Custom Error Pages
Easy Upload
File Manager
FrontPage
FTP Account Info
Getting Started Guides
Web Hosting Glossary
HTML Editor
MySQL Database
PageBuilder
PageWizards
Perl Editor
PHP Editor
PHP Functions
PHP Mail
SiteBuilder
SiteWizards
Starter Web Page Wizard
Text Editor
Yahoo! Presence
Yahoo! Wizards

Please keep in mind that Im working on this site not just for me but for an Americas Army clan I need to get this project started. From my understanding for what I need I will have to redo what I already started so I put it on hold for this reason. (Need this ASAP)


BratCat
 
0
•••
OK, I don't know if this will help, but, here is my code for main.dwt.

main.dwt
Code:
<!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 name="description" content="Professional, Effective and Innovative UK Website Design Services" />
<meta name="keywords" content="web design, web development, uk, united kingdom, north yorkshire, web, design, development, professional, services" />

<!-- TemplateBeginEditable name="doctitle" -->
<title>RedNerve Media - Redefining the Web | Professional, Innovative & Effective UK Website Design</title>

<!-- TemplateEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<script language="JavaScript" type="text/JavaScript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<link rel="stylesheet" type="text/css" href="main.css"/>

<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<style type="text/css">
<!--
.style2 {color: #003366}
body,td,th {
	font-family: Tahoma;
	font-size: 11px;
	color: #333333;
}
body {
	margin-left: 0px;
	margin-top: 0px;
	margin-right: 0px;
	margin-bottom: 0px;
}
a {
	font-size: 11px;
	color: #000000;
}
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
	color: #000000;
}
a:hover {
	text-decoration: underline;
	color: #990000;
}
a:active {
	text-decoration: none;
	color: #990000;
}
-->
</style>
</head>

<body onload="MM_preloadImages('../nav_roll_02.jpg','../nav_roll_04.jpg','../nav_roll_06.jpg','../nav_roll_08.jpg','../nav_roll_10.jpg','../nav_roll_12.jpg','../nav_roll_14.jpg','../nav_roll_16.jpg','../nav_roll_18.jpg','../nav_roll_20.jpg')">
<table style="width:100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td style="height:20px" class="top"> </td>
  </tr>
</table>
<table style="width:100%;height:60px" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="90%" class="banner_bg"><img src="../banner3.jpg" style="width:700px;height:60px" alt="RedNerve Media" /></td>
    <td width="10%" class="quote_bg"><div align="right"><a href="../quote.htm"><img src="../clickquote.jpg" alt="Click for a FREE Quote" style="width:100px;height:60px" border="0" /></a></div></td>
  </tr>
</table>
<table style="width:100%;height:32px" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td style="height:32px" valign="top" class="nav_bg"><div align="left"><img src="../nav_01.jpg" alt="..." style="width:100%;height:2px" /><br />
        <a href="../index.html" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image6','','../nav_roll_02.jpg',1)"><img src="../nav_02.jpg" alt="RedNerve Homepage" name="Image6" style="width:43px;height:18px" border="0" id="Image6" /></a><img src="../nav_03.jpg" alt="..." style="width:3px;height:18px" /><a href="../about.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image8','','../nav_roll_04.jpg',1)"><img src="../nav_04.jpg" alt="About Us" name="Image8" style="width:57px;height:18px" border="0" id="Image8" /></a><img src="../nav_05.jpg" alt="..." style="width:3px;height:18px" /><a href="../services.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image10','','../nav_roll_06.jpg',1)"><img src="../nav_06.jpg" alt="Services" name="Image10" style="width:56px;height:18px" border="0" id="Image10" /></a><img src="../nav_07.jpg" alt="..." style="width:3px;height:18px" /><a href="../portfolio.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image12','','../nav_roll_08.jpg',1)"><img src="../nav_08.jpg" alt="Portfolio" name="Image12" style="width:62px;height:18px" border="0" id="Image12" /></a><img src="../nav_09.jpg" alt="..." style="width:3px;height:18px" /><a href="../process.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image14','','../nav_roll_10.jpg',1)"><img src="../nav_10.jpg" alt="Design Process" name="Image14" style="width:53px;height:18px" border="0" id="Image14" /></a><img src="../nav_11.jpg" alt="..." style="width:3px;height:18px" /><a href="../contact.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image16','','../nav_roll_12.jpg',1)"><img src="../nav_12.jpg" alt="Contact Us" name="Image16" style="width:56px;height:18px" border="0" id="Image16" /></a><img src="../nav_13.jpg" alt="..." style="width:3px;height:18px" /><a href="../faq.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image18','','../nav_roll_14.jpg',1)"><img src="../nav_14.jpg" alt="Frequently Asked Questions" name="Image18" 
style="width:33px;height:18px" border="0" id="Image18" /></a><img src="../nav_15.jpg" alt="..." style="width:3px;height:18px" /><a href="../terms_and_conditions.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image20','','../nav_roll_16.jpg',1)"><img src="../nav_16.jpg" alt="Terms and Conditions" name="Image20" style="width:105px;height:18px" border="0" id="Image20" /></a><img src="../nav_17.jpg" alt="..." style="height:3px;height:18px" /><a href="../quote.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image22','','../nav_roll_18.jpg',1)"><img src="../nav_18.jpg" alt="Request a FREE Quote" name="Image22" style="width:70px;height:18px" border="0" id="Image22" /></a><img src="../nav_19.jpg" alt="..." style="width:3px;height:18px" /><a href="../links.htm" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image26','','../nav_roll_20.jpg',1)"><img src="../nav_20.jpg" alt="Links" name="Image26" style="width:40px;height:18px" border="0" id="Image26" /></a><img src="../nav_21.jpg" alt="..." style="width:3px;height:18px" /><br />
    <img src="../nav_01.jpg" alt="..." style="width:100%;height:2px" /></div></td>
  </tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" style="border-top:1px solid #e6e6e6;width:100%;height:90%">
  <tr>
    <td rowspan="2" valign="top" class="tahoma" style="border-right:1px none #e6e6e6;padding:5px;width:561px;"><!-- TemplateBeginEditable name="text" -->
      <p class="tahoma"> </p>
    <!-- TemplateEndEditable -->      <div align="right"></div></td>
    <td valign="top" style="border-right:1px solid #e6e6e6;padding:5px;padding-right:60px;width:121px"> </td>
    <td valign="top" class="news_bg" style="border-right:1px solid #e6e6e6;padding:0px;padding-left:0px;background-repeat:repeat-y;width:217px;height:354px"><table style="width:210px;height:54px" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td style="padding-left:10px;height:54px" class="tahoma"><div align="right" class="verdana">
            <div align="left">
              <p><strong><span class="text"><strong><img src="../news.jpg" alt="Latest News" style="margin-left:0px;height:30px;width:145px" /><br />
                </strong></span></strong><strong><strong> <span class="style2"><img src="../arrow.jpg" style="width:11px;height:11px" align="middle" alt="..."/> March 19 2005</span> <br />
                </strong></strong>The official company website is launched.<strong><br />
              </strong></p>
            </div>
        </div></td>
      </tr>
    </table>    <form name="login" id="login" method="post" action="../login.php"><div align="right" class="verdana"><div align="left">
        <table border="0" cellpadding="0" cellspacing="0" style="padding-left:0px;width:217px;height:112px" class="tahoma">
              <tr>
                <td style="width:217px;height:30px"><img src="../login.jpg" alt="Clients Login Here" style="margin-left:10px;width:145px;height:30px" /></td>
              </tr>
              <tr>
                <td style="height:120px;background-image:url(../login_bg.jpg)" class="login"><div align="right" class="verdana">
                  <div align="left"><strong><span class="style7" style="margin-left:10px; color: #003366;">username</span><br />
                        <input name="username" type="text" class="form" id="username" style="width:120px;margin-left:10px" />
                        <br />
                        <span class="style7" style="margin-left:10px; color: #003366;">password</span><br />
                        <input name="password" type="password" class="form" id="password" style="width:120px;margin-left:10px" />
                        <input type="submit" name="Submit" value="Login" class="form" style="height:22px;width:50px;padding:0px" />                        
                      <br />
                    </strong></div>
                </div>
                </td>
              </tr>
            </table>
      </div>
        </div>
      </form>      
      <p>        <br />
      </p></td>
    <td rowspan="2" valign="top" class="news2" style="background-repeat:repeat-y;width:93px"><div align="center">
      <p> </p>
      <p align="left"> </p>
    </div>
      <div align="right"></div></td>
  </tr>
  <tr>
    <td align="right" valign="bottom" style="border-right:1px solid #e6e6e6;padding:5px;padding-right:5px;width:159px;height:36px"><div align="right"><a href="http://validator.w3.org/check?uri=referer" target="_blank"><img src="../w3c.jpg" alt="Valid XHTML 1.0!" border="0" style="height:36px;width:93px" /></a><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://www.rednerve.com/main.css" target="_blank"><img src="../w3c_css.jpg" style="width:93px;height:36px" border="0" alt="Valid CSS!" /> </a></div></td>
    <td valign="bottom" class="news3" style="border-right:1px solid #e6e6e6;padding:5px;padding-left:10px;background-repeat:repeat-y;height:40px"><div align="right"><img src="../paypal.jpg" alt="We accept payment via..." style="width:133px;height:67px" /> </div></td>
  </tr>
</table>
<table style="width:100%;height:30px;" border="0" cellpadding="0" cellspacing="0" class="bottom_bg">
  <tr>
    <td style="padding-right:10px;height:33px"><div align="right" class="style5">© COPYRIGHT 2004 - 2005<strong> REDNERVE MEDIA | </strong>VALID XHTML 1.0 & CSS </div></td>
  </tr>
</table>
</body>
</html>

So, where do I put the PHP template checking code? I do put it on main.dwt right? Or, do I put it on the pages that use the template?
 
0
•••
Spekta, can you help me further?
 
0
•••
No-one has any more ideas? Come on, I know its possible!! How?!?!?!?!?!?
 
0
•••
Possible Solution

yeah, sure... here's how i think it can be solved:

PHP:
<?php
// check session variables
if (($_SESSION[authority]) = "administrator") {
echo "admin.dwt"; // of course here you are going to reference your template
} elseif (($_SESSION[authority]) = "user1") {
echo "user1template.dwt"; // template for user status 1
} elseif (($_SESSION[authority]) = "user2") {
echo "user2template.dwt"; // template for user status 2
exit;
?>

This can go on forever, as long as you have set up user status when it tries to check the username and password. Also make sure that everything is aligned - all this is case-sensitive.

Hope that helps

-Steve
 
0
•••
Appraise.net

We're social

Escrow.com
Spaceship
Rexus Domain
CryptoExchange.com
Domain Recover
CatchDoms
DomDB
NameFit
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back