NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page PHP / MySQL Login Area...

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 04-20-2005, 04:04 AM THREAD STARTER               #1 (permalink)
Senior Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2,694
will7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud of
 



PHP / MySQL Login Area...


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?
????: NamePros.com http://www.namepros.com/programming/83873-php-mysql-login-area.html

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.
__________________
Will Narburgh | Graphic design | Twitter | Email me
will7 is online now  
Old 04-20-2005, 07:26 AM   #2 (permalink)
NamePros Member
Join Date: Jan 2005
Posts: 92
Spekta is an unknown quantity at this point
 



spekta to the rescue!

yes ofcourse it's possible, here's how you would do it:
????: NamePros.com http://www.namepros.com/showthread.php?t=83873
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
Spekta is offline  
Old 04-20-2005, 12:02 PM THREAD STARTER               #3 (permalink)
Senior Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2,694
will7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud of
 



Thanks for the nice website comment. I'll give this a whirl later. I feel really ill at the moment
????: NamePros.com http://www.namepros.com/showthread.php?t=83873

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?
__________________
Will Narburgh | Graphic design | Twitter | Email me
Last edited by will7; 04-20-2005 at 12:08 PM.
will7 is online now  
Old 04-20-2005, 06:17 PM   #4 (permalink)
NamePros Member
Join Date: Jan 2005
Posts: 92
Spekta is an unknown quantity at this point
 



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';
Spekta is offline  
Old 04-20-2005, 06:22 PM   #5 (permalink)
New Member
Join Date: Apr 2005
Posts: 15
BratCat is an unknown quantity at this point
 



Cool I could use some help!


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/showthr...544#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)
????: NamePros.com http://www.namepros.com/showthread.php?t=83873


BratCat
BratCat is offline  
Old 04-21-2005, 03:17 AM THREAD STARTER               #6 (permalink)
Senior Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2,694
will7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud of
 



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 &amp; 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">&nbsp;</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">&nbsp;</p>
    <!-- TemplateEndEditable -->      <div align="right"></div></td>
    <td valign="top" style="border-right:1px solid #e6e6e6;padding:5px;padding-right:60px;width:121px">&nbsp;</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>&nbsp;</p>
      <p align="left">&nbsp;</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">&copy; COPYRIGHT 2004 - 2005<strong> REDNERVE MEDIA | </strong>VALID XHTML 1.0 &amp; 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?
__________________
Will Narburgh | Graphic design | Twitter | Email me
will7 is online now  
Old 04-21-2005, 10:37 AM THREAD STARTER               #7 (permalink)
Senior Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2,694
will7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud of
 



Spekta, can you help me further?
__________________
Will Narburgh | Graphic design | Twitter | Email me
will7 is online now  
Old 05-01-2005, 07:37 AM THREAD STARTER               #8 (permalink)
Senior Member
Join Date: Jun 2004
Location: United Kingdom
Posts: 2,694
will7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud ofwill7 has much to be proud of
 



No-one has any more ideas? Come on, I know its possible!! How?!?!?!?!?!?
__________________
Will Narburgh | Graphic design | Twitter | Email me
will7 is online now  
Old 05-02-2005, 08:03 AM   #9 (permalink)
A Wealth of Knowledge
 
stscac's Avatar
Join Date: Aug 2004
Posts: 3,809
stscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud ofstscac has much to be proud of
 



Possible Solution


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

PHP Code:
<?php
????: NamePros.com http://www.namepros.com/showthread.php?t=83873
// 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
stscac is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: Install the Apache Web Server, Perl, PHP, and MySQL on Windows deadserious Webmaster Tutorials 96 05-27-2007 02:24 PM
Googlism - What does google think of you? deadserious The Break Room 55 12-15-2005 10:09 AM
Tutorial: How to Install Apache2 MySQL and PHP on Windows deadserious Webmaster Tutorials 35 09-21-2005 10:46 PM
Tutorial: Getting Started With MySQL (The Basics) deadserious Webmaster Tutorials 3 04-18-2004 02:17 PM

Liquid Web Smart Servers  
All times are GMT -7. The time now is 04:16 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger