Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-16-2010, 05:34 PM   PM User | #1
tangwaichee
New Coder

 
Join Date: Mar 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
tangwaichee is an unknown quantity at this point
Login & Logout

Hi all,

when the user enter its userid and password to login into the web, it successfully works, but if the user wish to logout, what coding i need to insert it.anyone could give me a hand on it?

thanks


[CODE]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en" lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>


<title>Cart-Test</title>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<link rel="shortcut icon" href="http://cart-test.com/product_images/favicon.ico" />

<link href="http://cart-test.com/templates/default/Styles/styles.css?1" media="all" type="text/css" rel="stylesheet" />
<link href="http://cart-test.com/templates/default/Styles/iselector.css?1" media="all" type="text/css" rel="stylesheet" />
<link href="http://cart-test.com/templates/default/Styles/blue.css?1" media="all" type="text/css" rel="stylesheet" />
<!--[if IE]><link href="http://cart-test.com/templates/default/Styles/ie.css?1" media="all" type="text/css" rel="stylesheet" /><![endif]-->


<!-- Tell the browsers about our RSS feeds -->
<link rel="alternate" type="application/rss+xml" title="Latest News (RSS 2.0)" href="http://cart-test.com/rss.php?action=newblogs&amp;type=rss" />
<link rel="alternate" type="application/atom+xml" title="Latest News (Atom 0.3)" href="http://cart-test.com/rss.php?action=newblogs&amp;type=atom" />
<link rel="alternate" type="application/rss+xml" title="New Products (RSS 2.0)" href="http://cart-test.com/rss.php?type=rss" />
<link rel="alternate" type="application/atom+xml" title="New Products (Atom 0.3)" href="http://cart-test.com/rss.php?type=atom" />
<link rel="alternate" type="application/rss+xml" title="Popular Products (RSS 2.0)" href="http://cart-test.com/rss.php?action=popularproducts&amp;type=rss" />
<link rel="alternate" type="application/atom+xml" title="Popular Products (Atom 0.3)" href="http://cart-test.com/rss.php?action=popularproducts&amp;type=atom" />


<!-- Include visitor tracking code (if any) -->
<script type="text/javascript" src="http://cart-test.com/index.php?action=tracking_script"></script>





<script type="text/javascript" src="http://cart-test.com/javascript/jquery.js?1"></script>
<script type="text/javascript" src="http://cart-test.com/javascript/menudrop.js?1"></script>
<script type="text/javascript" src="http://cart-test.com/javascript/common.js?1"></script>
<script type="text/javascript" src="http://cart-test.com/javascript/iselector.js?1"></script>

<script type="text/javascript">
//<![CDATA[
config.ShopPath = 'http://cart-test.com';
config.AppPath = '';
var ThumbImageWidth = 120;
var ThumbImageHeight = 120;
//]]>
</script>

<script type="text/javascript" src="http://cart-test.com/javascript/quicksearch.js"></script>

</head>

<body>
<div id="Container">
<div id="AjaxLoading"><img src="http://cart-test.com/templates/default/images/ajax-loader.gif" alt="" />&nbsp; Loading... Please wait...</div>



<div id="TopMenu">
<ul style="display:">
<li style="" class="HeaderLiveChat">

</li>
<li style="display:" class="First"><a href="http://cart-test.com/account.php">My Account</a></li>
<li style="display:"><a href="http://cart-test.com/orderstatus.php">Order Status</a></li>
<li style="display:"><a href="http://cart-test.com/wishlist.php">Wish Lists</a></li>
<li><a href="http://cart-test.com/giftcertificates.php">Gift Certificates</a></li>
<li style="display:" class="CartLink"><a href="http://cart-test.com/cart.php">View Cart <span></span></a></li>
<li style="display:">
<div>
<a href='http://cart-test.com/login.php' onclick=''>Sign in</a> or <a href='http://cart-test.com/login.php?action=create_account' onclick=''>Create an account</a>
</div>
</li>
</ul>
<br class="Clear" />
</div>
<div id="Outer">
<div id="Header">
<div id="Logo">
<div id="LogoContainer">
<h1><a href="http://cart-test.com/"><span class="Logo1stWord">Cart-Test</span></a></h1>
</div>
</div>
<div id="SearchForm">
<form action="http://cart-test.com/search.php" method="get" onsubmit="return check_small_search_form()">
<label for="search_query">Search</label>
<input type="text" name="search_query" id="search_query" class="Textbox" value="" />
<input type="image" src="http://cart-test.com/templates/default/images/blue/Search.gif" class="Button" />
</form>
<p>
<a href="http://cart-test.com/search.php?mode=advanced"><strong>Advanced Search</strong></a> |
<a href="http://cart-test.com/search.php?action=Tips">Search Tips</a>
</p>
</div>

<script type="text/javascript">
var QuickSearchAlignment = 'left';
var QuickSearchWidth = '232px';
lang.EmptySmallSearch = "You forgot to enter some search keywords.";
</script>

<br class="Clear" />
</div>
<div id="Menu">
<ul>
<li class="First ActivePage"><a href="http://cart-test.com/"><span>Home</span></a></li>
<li class=" ">
<a href="http://cart-test.com/pages/Information.html"><span>Information</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/giftcertificates.php"><span>Gift Certificate</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/Products.html"><span>Products</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/New-Arrivals.html"><span>New Arrivals</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/Promotions-Items.html"><span>Promotions Items</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/Hot-Items.html"><span>Hot Items</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/Clearance-Items.html"><span>Clearance Items</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/Wholesales.html"><span>Wholesales</span></a>

</li> <li class=" ">
<a href="http://cart-test.com/pages/Support.html"><span>Support</span></a>

</li>
</ul>
</div>

<div id="Wrapper">

<div class="Left" id="LayoutColumn1">
<div class="Block CategoryList Moveable Panel" id="SideCategoryList">
<h2>Categories</h2>
<div class="BlockContent">
<ul>
<li class=""><a href="http://cart-test.com/categories/Testonly/">Testonly</a>

</li>
</ul>
</div>
</div>




<div class="Block NewsletterSubscription Moveable Panel" id="SideNewsletterBox">

<h2>
Our Newsletter
</h2>


<div class="BlockContent">
<form action="http://cart-test.com/subscribe.php" method="post" id="subscribe_form" name="subscribe_form">
<input type="hidden" name="action" value="subscribe" />
<label for="nl_first_name">Your First Name:</label>
<input type="text" class="Textbox" id="nl_first_name" name="nl_first_name" />
<label for="nl_email">Your Email Address:</label>
<input type="text" class="Textbox" id="nl_email" name="nl_email" /><br />

<input type="image" src="http://cart-test.com/templates/default/images/blue/NewsletterSubscribe.gif" value="Subscribe" class="Button" />

</form>
</div>
</div>
<script type="text/javascript">
// <!--
$('#subscribe_form').submit(function() {
if($('#nl_first_name').val() == '') {
alert('You forgot to type in your first name.');
$('#nl_first_name').focus();
return false;
}

if($('#nl_email').val() == '') {
alert('You forgot to type in your email address.');
$('#nl_email').focus();
return false;
}

if($('#nl_email').val().indexOf('@') == -1 || $('#nl_email').val().indexOf('.') == -1) {
alert('Please enter a valid email address, such as john@example.com.');
$('#nl_email').focus();
$('#nl_email').select();
return false;
}

// Set the action of the form to stop spammers
$('#subscribe_form').append("<input type=\"hidden\" name=\"check\" value=\"1\" \/>");
return true;

});
// -->
</script>

Last edited by tangwaichee; 03-16-2010 at 05:37 PM..
tangwaichee is offline   Reply With Quote
Old 03-16-2010, 06:09 PM   PM User | #2
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
We need to see the actual PHP script that logs them in.
I assume they are using PHP SESSIONS, but they could be using cookies (not sure).
mlseim is offline   Reply With Quote
Old 03-16-2010, 07:55 PM   PM User | #3
masterofollies
Senior Coder

 
Join Date: May 2005
Posts: 2,137
Thanks: 96
Thanked 72 Times in 72 Posts
masterofollies can only hope to improve
If using sessions, this is all you need. You don't even need the html, but very useful.

PHP Code:
<?php
session_start
();
session_destroy();
?>
You have successfully logged out..<br><br><br>
Return to <a href="index.html">Website</a>
__________________
Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?
masterofollies is offline   Reply With Quote
Old 03-17-2010, 02:26 AM   PM User | #4
tangwaichee
New Coder

 
Join Date: Mar 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
tangwaichee is an unknown quantity at this point
as you can see this http://www.cart-test.com on the left column, the tab of the customer login panel. When the user logins, it will show the user name , i want to hide the rest of the (email address,password, register, forget password), only show the logout link after they have login successfully.

Below are the ID & Password Testing Only.

Email Address: test@yahoo.com
Password: test123

please help.

advance thanks to your guys...

Last edited by tangwaichee; 03-17-2010 at 02:29 AM..
tangwaichee is offline   Reply With Quote
Old 03-17-2010, 04:18 AM   PM User | #5
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,502
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
Whatever if-statement you're using to display the following message:

Hello, test test. (Not test?)

...just use the opposite:
PHP Code:
if ( /* user is logged in */ )
{
    
// Display welcome message
}
else
{
    
// Display login form, register link, forgot pass link, etc...

__________________
ZCE
kbluhm is offline   Reply With Quote
Old 03-17-2010, 05:16 AM   PM User | #6
tangwaichee
New Coder

 
Join Date: Mar 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
tangwaichee is an unknown quantity at this point
Hi kbluhm , where shall i put the code to?

<script type="text/javascript">

//<![CDATA[
/* Make sure the login fields are filled in */
function check_login_form() {
var login_email = g("login_email");
var login_pass = g("login_pass");

if(login_email.value.indexOf("@") == -1 || login_email.value.indexOf(".") == -1) {
alert("Please type in a valid email address, such as joe@aol.com");
login_email.focus();
login_email.select();
return false;
}

if(login_pass.value == "") {
alert("Please type in your password.");
login_pass.focus();
return false;
}

return true;
}


//]]>
</script>

thanks
tangwaichee is offline   Reply With Quote
Old 03-17-2010, 01:26 PM   PM User | #7
tangwaichee
New Coder

 
Join Date: Mar 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
tangwaichee is an unknown quantity at this point
anyone can give me a hand on this issue, quite urgent to me..
please


advance thanks
tangwaichee is offline   Reply With Quote
Old 03-17-2010, 02:03 PM   PM User | #8
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
We need to see the PHP scripting for that right column (or sidebar).
One would think it's in your "index.php" file, but that
might contain "includes" from other files or templates.

Wherever the scripting is for that login area ...
that's what we need to see. Not the HTML output,
but the actual PHP script.



.

Last edited by mlseim; 03-17-2010 at 02:05 PM..
mlseim is offline   Reply With Quote
Old 03-17-2010, 03:01 PM   PM User | #9
tangwaichee
New Coder

 
Join Date: Mar 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
tangwaichee is an unknown quantity at this point
the code for the sidecolumn:
Quote:
<h2>Customer Login</h2>

<div style="margin-bottom: 20px;" class="%%GLOBAL_CurrentCustomerFirstName%% PersonalGreeting">
<p>
<font color="red"><b>Hello, %%GLOBAL_CurrentCustomerFirstName%% %%GLOBAL_CurrentCustomerLastName%%.</b>&nbsp;
<span style="color: gray">(Not <a style="color: gray" href="%%GLOBAL_ShopPath%%/login.php?action=logout">%%GLOBAL_CurrentCustomerFirstName%%</a>?)</span></font>
</p>
</div>
<form action="http://cart-test.com/login.php?action=check_login" method="post" onsubmit="return check_login_form()">
<div class="FormContainer HorizontalFormContainer NarrowFormContainer">
<p style="display: none" class="SuccessMessage">

</p>

<dl>
<dt>Email Address:</dt>
<input type="text" class="Textbox Field150 InitialFocus" name="login_email" id="login_email" />

<dt>Password:</dt>
<input type="password" class="Textbox Field150" name="login_pass" id="login_pass" />
</dl>
<center><a href="http://cart-test.com/login.php?action=create_account"><font color="red">Register<font/></a>
<a href="http://cart-test.com/login.php?action=reset_password"><font color="red">Forgot Password?<font/></a></center>
<p class="Submit">
<input id="LoginButton" type="submit" value="Sign in" />
</dl>

</form>

<script type="text/javascript">

//<![CDATA[
/* Make sure the login fields are filled in */
function check_login_form() {
var login_email = g("login_email");
var login_pass = g("login_pass");

if(login_email.value.indexOf("@") == -1 || login_email.value.indexOf(".") == -1) {
alert("Please type in a valid email address, such as joe@aol.com");
login_email.focus();
login_email.select();
return false;
}

if(login_pass.value == "") {
alert("Please type in your password.");
login_pass.focus();
return false;
}

return true;
}


//]]>
</script>


tangwaichee is offline   Reply With Quote
Old 03-18-2010, 12:15 AM   PM User | #10
kbluhm
Senior Coder

 
kbluhm's Avatar
 
Join Date: Apr 2007
Location: Philadelphia, PA, USA
Posts: 1,502
Thanks: 2
Thanked 258 Times in 254 Posts
kbluhm will become famous soon enough
That appears to be a flat file template, replacing bits of text using the following format:
Code:
%%GLOBAL_VariableName%%
`if-else` syntax may not be supported. You might need to use PHP to parse and assign different templates depending on the users' logged-in status.
__________________
ZCE
kbluhm is offline   Reply With Quote
Old 03-18-2010, 04:30 AM   PM User | #11
tangwaichee
New Coder

 
Join Date: Mar 2010
Posts: 17
Thanks: 1
Thanked 0 Times in 0 Posts
tangwaichee is an unknown quantity at this point
Question

any programmer can slove this problem???
tangwaichee is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:45 AM.


Advertisement
Log in to turn off these ads.