input $_SESSION['username'] = $username; on login page help

This is a discussion on "input $_SESSION['username'] = $username; on login page help" within the PHP Forum section. This forum, and the thread "input $_SESSION['username'] = $username; on login page help are both part of the Program Your Website category.


 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices




Reply
 
LinkBack Thread Tools
  #1  
Old Jan 28th, 2008, 10:47
Reputable Member
Join Date: Jul 2006
Location: Baldock
Age: 20
Posts: 465
Thanks: 1
Thanked 0 Times in 0 Posts
input $_SESSION['username'] = $username; on login page help

Hi i was just wondering how i input this
Code: Select all
$_SESSION['username'] = $username;
on my login.php page. the page is below

Code: Select all
<?php
session_start();
require("./CustomSql.inc.php");
$db = new CustomSQL($DBName);
$showtable = true;
$errortag = false;
if (!empty($userlogin)) {
if (empty($username)){
 $errortag = true;
 $errormsg = $error_usernameempty;
}
if (empty($password)){
 $errortag = true;
 $errormsg = $error_passwordempty;
}
$customerid = $db->logincheck($username,$password);
if ($customerid==0) {
 $errortag = true;
 $errormsg = $error_wrongpassword;
}
if (!$errortag){
 session_register("CID");
 $_SESSION["CID"] = $customerid;
 $CID = $customerid;
                $_SESSION['username'] = $username;
 $showtable = false;
}
}
if (session_is_registered("CID")){
$showtable = false;
}
?>
<html>
<head>
<title><?php print "$front_login"; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=<?php print "$front_charset"; ?>">
<link rel="stylesheet" href="./style/style.css" type="text/css">
<script language="JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0">
<?php
include("top.php3");
?>
<table width="770" border="0" cellspacing="1" cellpadding="0" align="center" class="table_01">
  <tr> 
    <td class="table_02" width="160" valign="top"> 
    <table width="160" border="0" cellspacing="0" cellpadding="4">
        <tr> 
          <td>&nbsp;</td>
        </tr>
        <tr> 
          <td valign="top"><?php include("left.php"); ?></td>
        </tr>
      </table>
      </td>
      <td class="menu" bgcolor="#FFFFFF" valign="top" width="610"> 
     <table border="0" cellspacing="0" cellpadding="4" width="610">
        <tr> 
          <td bgcolor="#F2F2F2" class="menu_in">::<?php print "$front_login"; ?>&nbsp;&nbsp;&nbsp;<font color="#FF0000">*</font>&nbsp;<?php print "$front_requiredinfo"; ?></td>
        </tr>
        <?php
        if ($errortag){
        ?>
        <tr> 
          <td><font color="#FF0000"><?php print "$errormsg"; ?></font></td>
        </tr>
        <?php
        }
        ?>
        <tr> 
          <td>
            <?php
            if ($showtable){
            ?>          
<form action="<?php print "$PHP_SELF"; ?>" method="POST">
<table border=0 cellpadding=2 cellspacing=2>
<tr><td width="120"><?php print "$front_username"; ?> : </td><td><input type="text" name="username" value="<?php print "$username"; ?>">&nbsp;<font color="#FF0000">*</font></td></tr>
<tr><td><?php print "$front_password"; ?> : </td><td><input type="password" name="password" value="">&nbsp;<font color="#FF0000">*</font></td></tr>
<tr><td><a href="register.php"><?php print "$front_registration"; ?></a>&nbsp;&nbsp;&nbsp;<a href="forgetpass.php"><?php print "$front_forgetpass"; ?></a></td><td><input type="submit" name="userlogin" value="<?php print "$front_login"; ?>"></td></tr>
</table>
</form>
 <?php
 }
 else{
 ?>
 <a href="modiinfo.php"><?php print "$front_modiinfo"; ?></a>&nbsp;&nbsp;&nbsp;<a href="modipass.php"><?php print "$front_modipass"; ?></a>
 <?php
 }
 ?>
          </td>
        </tr>
        <tr> 
          <td align="right">&nbsp;</td>
        </tr>
      </table>
      </td>
  </tr>
</table>
<?php
include("bottom.php3");
?>
</body>
</html>
Thanks
Aaron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Jan 28th, 2008, 13:08
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: input $_SESSION['username'] = $username; on login page help

I don't understand the question. It looks to me like you have set $_SESSION['username']=$username and have a form to receive the input. Just set $username=$_POST['username'] in the form handler somewhere before you set the session username.

There are two things. Since you have a POST form at the bottom of the page, why don't you just use a long "if (isset($_POST['submit'])) {" for the form handler? That javascript looks very shaky. This is the standard way to handle a single page form & form handler.

Second is, I can't understand any possible reason to use "session_register()". Take out all uses of it and similar deprecated functions, i.e. "session_is_registered()". And make sure you have register_globals set to "off" in your php.ini for your entire site.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
  #3  
Old Jan 28th, 2008, 14:14
Reputable Member
Join Date: Jul 2006
Location: Baldock
Age: 20
Posts: 465
Thanks: 1
Thanked 0 Times in 0 Posts
Re: input $_SESSION['username'] = $username; on login page help

Hi right i found out what code i want lol, in the login.php code it has this

Code: Select all
$_SESSION["CID"] = $customerid;
which will show the users.

but what i want is to redirect the login.php page to my index.php page and then it will show this "Welcome Guest or Welcome Aaron1988" something like that mate.

and the code which should do that is
Code: Select all
$_SESSION["CID"] = $customerid;
but i dont know how to redirect the login.php page to the index.php and input the code into index.php

Hope that is clear if not let us know.

Thanks
Aaron
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
validating username sudhakararaog PHP Forum 0 May 27th, 2008 17:50
validating username sudhakararaog PHP Forum 1 May 26th, 2008 21:29
username validation Monie Classic ASP 0 Sep 9th, 2004 01:53


All times are GMT. The time now is 02:25.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42