473,382 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Error-Undefined index

250 100+
I'm developing a web site using php and mysql. This is my index.php page.
Expand|Select|Wrap|Line Numbers
  1. <?php 
  2. session_start();
  3. require_once ('dbconnect.php'); ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5. <META http-equiv=Pragma content=no-cache>
  6. <head>
  7. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  8. <title>Vehicle Master</title>
  9. <link rel="stylesheet" type="text/css" href="vehicleMaster.css">
  10. </head>
  11. <!--<body style="background:url(images/bg.jpg)" >-->
  12. <body>
  13. <?php
  14. $username = "";
  15. $password = "";
  16. $errorMessage = "";
  17. $_SESSION['UserName_Ses'] = "";
  18. $_SESSION['UserType_Ses'] = "";
  19. $_SESSION['login'] = "";
  20. if(isset($_POST['login'])){
  21.     $username=$_POST['userusername']; 
  22.     $password=$_POST['userpassword'];
  23.     if((!$username)||(!$password)){
  24.         $login_error = '<p class= "errormsg">Please enter all fields</p>';
  25.     }
  26.         $password_encrpt = md5(substr($password, 1, -1));
  27.  
  28.         $sql = "SELECT * FROM user WHERE  userName='$username' AND userPassword ='$password_encrpt'"; 
  29.         $result=mysql_query($sql)or die(mysql_error());
  30. //----------this is use to retriew values---------------------------------------------------------------        
  31.         $row = mysql_fetch_array($result) or die(mysql_error());
  32. //-----------if login success then get user typr to session and go to the login page--------------------        
  33.         if(mysql_num_rows($result) == 1){
  34.             $_SESSION['UserType_Ses'] =$row['userType'];
  35.             $_SESSION['UserNamee_Ses'] =$row['userName'];
  36.             $_SESSION['login'] = "";
  37.             $_SESSION['login'] = "True";
  38.             header('Location: main.php');    
  39.         }
  40.         else {
  41.             $errorMessage = '<p class="errMsg" align="Center">Invalid Username or Password</p>';
  42.             echo "error";
  43.         }
  44.  
  45. }
  46.  
  47. ?>
  48. <table width="566" height="100%" border="0" align="center" cellpadding="0" cellspacing="0"  class="mainTblBorder">
  49.   <!-------------------hedder table-------------------------------------------------->
  50.   <tr>
  51.     <td><?php require_once 'hedder.php'; ?>
  52.     </td>
  53.   </tr>
  54.   <!--------------menu-------------------------------------------------------------->
  55.   <tr>
  56.     <td><?php require_once 'menue.php'; ?>
  57.     </td>
  58.   </tr>
  59.   <!--------------body-------------------------------------------------------------->
  60.   <td>
  61.       <table width="520" id="maintable">
  62.         <tr>
  63.             <td width="234">
  64.             <?php if ($_SESSION['login'] != 'True')  {
  65.             echo "login not true";
  66.             login();
  67.             }?>
  68.  
  69.                 <?php if ($_SESSION['login'] == 'True')  {
  70.             echo "true";
  71.             login();
  72.             }?>
  73.             </td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td>
  74.           <td><table width="339" border="0" cellpadding="0" cellspacing="0" class="subTableBorder" id="stocksearch">
  75.             <tr>
  76.               <td colspan="2" align="center"><img src="images/subBannerStockSearch.jpg"  /></td>
  77.             </tr>
  78.             <tr><?php if(isset($errorMessage)){ echo "$errorMessage"; }?></tr>
  79.             <tr>
  80.               <td width="41%" >Make&nbsp;&nbsp;:</td>
  81.               <td width="59%"><select name="select" style="width:100px">
  82.                   <option></option>
  83.                   <option></option>
  84.                   <option></option>
  85.                 </select>              </td>
  86.             </tr>
  87.             <tr>
  88.               <td>Model&nbsp;:</td>
  89.               <td><select name="select" style="width:100px">
  90.                   <option></option>
  91.                   <option></option>
  92.                   <option></option>
  93.               </select></td>
  94.             </tr>
  95.             <tr>
  96.               <td>Year&nbsp;&nbsp;&nbsp;:</td>
  97.               <td><select name="select" style="width:100px">
  98.                   <option>1</option>
  99.                   <option>2</option>
  100.                   <option>3</option>
  101.               </select></td>
  102.             </tr>
  103.             <tr>
  104.               <td>Fuel&nbsp;&nbsp;&nbsp;&nbsp;:</td>
  105.               <td><select name="select" style="width:100px">
  106.                   <option></option>
  107.                   <option></option>
  108.                   <option></option>
  109.               </select></td>
  110.             </tr>
  111.             <tr><td colspan="2" align="right"><img src="images/deleteBtn.jpg" /></td></tr>
  112.           </table></td>
  113.         </tr>
  114.       </table>
  115.     </td>
  116.       </tr>
  117.           <tr>
  118.             <td><?php require_once 'footer.php'; ?>
  119.         </td>
  120.   </tr>
  121. </table>
  122.  
  123. <?php
  124. function login(){
  125. ?>                <form action="index.php" method="post">
  126.                 <table width="98%" height="134" border="0" cellpadding="0"  cellspacing="0" class="subTableBorder" id="customerLogin">
  127.                     <tr valign="top">
  128.                       <td colspan="2" width="100%"><img src="images/subBannerCustomerLogin.jpg" /></td>
  129.                     </tr>
  130.                     <tr valign="top">
  131.                       <td>Login ID&nbsp;&nbsp;:</td>
  132.                       <td><input name="userusername" type="text" id="userid" /></td>
  133.                     </tr>
  134.                     <tr>
  135.                       <td>Password:</td>
  136.                       <td><input name="userpassword" type="text" id="userpassword" /></td>
  137.                     </tr>
  138.                     <tr>
  139.                       <td height="53" colspan="2" align="right" ><br />
  140.                       <input type="submit" name="login"  value="Submit" class="btn" height="30"  width="50"/><img src="images/tesBtn.jpg" />&nbsp;</td>
  141.                   </tr>
  142.               </table>    
  143.             </form> 
  144. <?php }
  145. ?>
  146. <!-------------------------end stock search---------------------------------------- -->
  147.  
  148. </body>
  149. </html>
  150.  
I have define 3variables in this page
Expand|Select|Wrap|Line Numbers
  1. $_SESSION['UserName_Ses'] = "";
  2. $_SESSION['UserType_Ses'] = "";
  3. $_SESSION['login'] = "";
  4.  
when I did not set default value like this It will get and error saying 'Undefined index: UserType_Ses in...'
But when I use this , after the login if user wants to go to index page egain it display as not login. because top of the page I set the default value. But user should have the permission to go to the index page without auto sign out. Please help me..
Jul 8 '11 #1

✓ answered by code green

error saying 'Undefined index: UserType_Ses in...'
You have chopped the error message that indicates the problem.
It looks like you are overwriting the element so try
Expand|Select|Wrap|Line Numbers
  1. if(!isset($_SESSION['UserName_Ses']) ['UserName_Ses'] = ""; 
  2.  

1 1635
code green
1,726 Expert 1GB
error saying 'Undefined index: UserType_Ses in...'
You have chopped the error message that indicates the problem.
It looks like you are overwriting the element so try
Expand|Select|Wrap|Line Numbers
  1. if(!isset($_SESSION['UserName_Ses']) ['UserName_Ses'] = ""; 
  2.  
Jul 8 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
2
by: Gregory | last post by:
Hi, One of the disadvantages of using error handling with error codes instead of exception handling is that error codes retuned from a function can be forgotten to check thus leading to...
13
by: deko | last post by:
I use this convention frequently: Exit_Here: Exit Sub HandleErr: Select Case Err.Number Case 3163 Resume Next Case 3376 Resume Next
7
by: p | last post by:
WE had a Crystal 8 WebApp using vs 2002 which we upgraded to VS2003. I also have Crystal 9 pro on my development machine. The web app runs fine on my dev machine but am having problems deploying....
3
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
0
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
1
by: developer | last post by:
Hi All I have made a .NET project. the files included are borland c++ files that i am migrate to VC++ .NET I am using Microsoft Visual C++ .NET 2003. the compilation goes through properly,...
0
by: mchuc7719 | last post by:
Hello, I have a Vb.Net 2005 ClassLibrary, when I try to compile using MSBee, only get errors. Before I to run the command line, I open in notepad the .vbproj and I was add the next line: ...
4
by: jk2l | last post by:
Error 10 error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj Error 11 error...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.