473,614 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Undefined index: phplogin, Undefined variable: username ,Warning: session_start()

6 New Member
Hi,
I am new to php, i was doing some small chnages in a project developed by my collegue who left the job and i got the responsibility for that,

After doing some changes when i run it on my local server it was working fine but giving some errors those are

Notice: Undefined index: phplogin in C:\Inetpub\wwwr oot\sampleft\in dex.php on line 116

Notice: Undefined variable: username in C:\Inetpub\wwwr oot\sampleft\in dex.php on line 116

and the code is
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  session_start(); 
  3.  
  4.  require_once( 'includes/settings.php' );
  5.  if(isset($_POST['submit']))
  6.  {
  7.     $username=$_POST['email'];
  8.     $password = $_POST['password'];
  9.  
  10.     $login_query = "select user_email, user_group,user_password from person where user_email = '$username' and user_password = '$password' ";
  11.  
  12.     $res = dbconnect($login_query);
  13.  
  14.  
  15.  
  16.      //)
  17.  
  18.      $num_rows = mysql_num_rows($res);
  19.      if ($num_rows)
  20.      {
  21.         while ($myrow = mysql_fetch_row($res))
  22.         {
  23.            $user_group = $myrow[1];
  24.  
  25.         }
  26.  
  27.  
  28.        $_SESSION['user'] = $username;
  29.        $_SESSION['password']=$password;
  30.        $_SESSION['phplogin'] = true;
  31.        $_SESSION['user_group'] = $user_group;
  32.  
  33.        header('Location: main.php'); 
  34.        exit;
  35.     }
  36.  
  37. }
  38.  
  39. ?>
  40. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  41. <html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/maintemp.dwt" codeOutsideHTMLIsLocked="false" -->
  42. <head>
  43. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  44. <!-- InstanceBeginEditable name="doctitle" -->
  45. <title>Login Page</title>
  46. <!-- InstanceEndEditable -->
  47. <!-- InstanceBeginEditable name="head" -->
  48. <style type="text/css">
  49. <!--
  50. .style9 {color: #CC0000}
  51. .style2 {color: #FF0000}
  52. -->
  53. </style>
  54. <!-- InstanceEndEditable -->
  55. <style type="text/css">
  56. <!--
  57. .style7 {
  58.     font-size: 24px;
  59.     color: #FFFFFF;
  60.     font-weight: bold;
  61. }
  62. .style9 {font-size: 19px; color: #FFFFFF; font-weight: bold; }
  63. -->
  64. </style>
  65. </head>
  66.  
  67. <body>
  68. <table width="746" height="377" border="0" cellspacing="0" bordercolor="#B5C3DE">
  69.   <tr>
  70.     <td height="64" colspan="4" bordercolor="#FFFFFF" bgcolor="#000066">
  71.     <p class="style9">Sample Feasibility Tool </p></td>
  72.   </tr>
  73.   <tr>
  74.     <td width="400" height="21" bgcolor="#CCCCCC">
  75.     <?php
  76.      if (isset($_SESSION['phplogin']))
  77.      {
  78.         $user = $_SESSION['user'];
  79.         echo "<span class=\"style10\">Welcome $user </span>";
  80.      }
  81.      ?></td>
  82.  
  83.  
  84.     <td width="88" height="21" bgcolor="#CCCCCC">
  85.     <?php
  86.      if (isset($_SESSION['phplogin']))
  87.      {
  88.  
  89.         echo "<p><a href=\"logout.php\" class=\"style9\">log out</a></p>";
  90.      }
  91.      ?></td>
  92.   </tr>
  93.   <tr>
  94.     <td height="224" colspan="4"><!-- InstanceBeginEditable name="EditRegion3" -->
  95.  
  96.  
  97.       <p align="center"><strong>Please login to use the tool</strong></p>
  98.       <form action="<?php echo $_SERVER['PHP_SELF']?>" method="post">
  99.       <table align="center" border="1" cellspacing="0" cellpadding="3">
  100.       <tr><td>Enter Full PSL Email:</td><td>
  101.       <input type="text" name="email" maxlength="50">
  102.       </td></tr>
  103.       <tr><td>Password:</td><td>
  104.       <input type="password" name="password" maxlength="50">
  105.       </td></tr>
  106.       <tr><td colspan="2" align="right">
  107.       <input type="submit" name="submit" value="Login">
  108.       </td></tr>
  109.       </table>
  110.       </form>
  111.  
  112.       <?php
  113.  
  114.       if($_SESSION['phplogin'] != true && $username!="")
  115.       {
  116.          echo "<span class=\"style9\">You have entered a non-registered email</span>";
  117.  
  118.          echo "<br><strong><span class=\"style2\"><em>(NOTE: In case you are a new user, please email Michael O'Donnell for a login)</em></span></strong>";
  119.      }
  120.  
  121.       ?>
  122.  
  123.       <p>&nbsp;</p>
  124.     <!-- InstanceEndEditable -->
  125.     <p>&nbsp;</p></td>
  126.   </tr>
  127.   <tr>
  128.       <td width="188" height="21" bgcolor="#CCCCCC">
  129.  
  130.     <?php
  131.      if (isset($_SESSION['phplogin']))
  132.      {
  133.         echo "<span class=\"style10\"><a href=\"main.php\">Main Page</a> </span>";
  134.      }
  135.  
  136.     ?></td>
  137.   </tr>
  138.   <tr>
  139.       <td width="188" height="21" bgcolor="#CCCCCC">
  140.     <?php
  141.      if (isset($_SESSION['phplogin']) && $_SESSION['user_group'] == 'A')
  142.      {
  143.  
  144.         echo "<span class=\"style10\"><a href=\"administration.php\">administration</a></span>";
  145.      }
  146.  
  147.     ?>
  148.     </td>
  149.   </tr>    
  150. </table>
  151. </body>
  152. <!-- InstanceEnd --></html>
  153.  
i thought these eroors will go when i put this to main server but i got some more errors and those are
Expand|Select|Wrap|Line Numbers
  1. Warning: session_start() [function.session-start]: open(C:\sessiondata\sess_7622cc37a4f8bcb6af1cc69813daa148, O_RDWR) failed: Permission denied (13) in C:\Inetpub\wwwroot\ft\index.php on line 2
  2.  
  3. Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\Inetpub\wwwroot\ft\index.php:2) in C:\Inetpub\wwwroot\ft\index.php on line 2
  4.  
  5. Warning: Unknown: open(C:\sessiondata\sess_7622cc37a4f8bcb6af1cc69813daa148, O_RDWR) failed: Permission denied (13) in Unknown on line 0
  6.  
  7. Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct (C:\sessiondata) in Unknown on line 0
  8.  
Please help me to destry them,
Looking forward for any reply .......Thanks
Sep 12 '07 #1
5 7177
Atli
5,058 Recognized Expert Expert
Hi and Welcome to The Scripts!

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

Moderator
Sep 12 '07 #2
siyaverma
6 New Member
Hi and Welcome to The Scripts!

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

Moderator
Thanks Sir,i will take care of this in future..loking forward to answers....
Sep 12 '07 #3
Atli
5,058 Recognized Expert Expert
Looks like the session.save_pa th is invalid.

The sessions are saved into this path on the server. If PHP does not have access to write to the directory you get this error.

By the look of the error, you have already made a directory for the session data ('C:\sessiondat a\'), but PHP does not seem to have access to it.

Try changing the folder permission so that PHP has access to it.
If you are having problems with this, try giving Everybody full access, if only to see that this is really the problem.
Sep 12 '07 #4
siyaverma
6 New Member
Looks like the session.save_pa th is invalid.

The sessions are saved into this path on the server. If PHP does not have access to write to the directory you get this error.

By the look of the error, you have already made a directory for the session data ('C:\sessiondat a\'), but PHP does not seem to have access to it.

Try changing the folder permission so that PHP has access to it.
If you are having problems with this, try giving Everybody full access, if only to see that this is really the problem.

[quote=siya]
This is the value which is already there
sesison.save_pa th="/temp"
and with this all his projects are working fine but these errors are coming into the project in which i have done changes,i have tried to give
session.save_pa th="C:\sessiond ata" but same errors are coming back.

one more thing i noticed is that php.ini is in windows in my computer but it is in C dir on main server
Sep 12 '07 #5
siyaverma
6 New Member
[quote=siyaverma]
This is the value which is already there
sesison.save_pa th="/temp"
and with this all his projects are working fine but these errors are coming into the project in which i have done changes,i have tried to give
session.save_pa th="C:\sessiond ata" but same errors are coming back.

one more thing i noticed is that php.ini is in windows in my computer but it is in C dir on main server
[quote]

Hi

to check if my file is correct or not i replaced the index files and then the same error started coming into old project which was working fine.

do you have some suggestion about it ....Please help i am looking forward to answers.
Thanks
Sep 12 '07 #6

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

Similar topics

3
3007
by: sam | last post by:
HI, I installed php4 for apached and restart apache afterward. but my little php script generated error followint error: PHP Notice: Undefined index: myname in /usr/local/www/data-dist/www.authtec.com/php-test.php on line 2 I was trying to run the following php script in apache: <?php
9
9599
by: petermichaux | last post by:
Hi, I am curious about how php deals with the following situation where I use an undefined index into an array. PHP seems to be behaving exactly how I want it to but I want to make sure that it is not a fluke. It seems like most programming languages would crash if you used an undefined index. Why does PHP work the way it does? My example is below
3
2232
by: hemashiki | last post by:
hi i cant pass a same variable to multiplepages... while passing variables in sessions it shows warning and it doesn't pass to multiple pages here the coding which i hve used Registration.php <? session_start(); session_register("username"); $username=$_POST;
3
1657
by: anuragpj | last post by:
i have designed a login page like this: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Electrical Engineering Dept IITK</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!--
4
4072
by: cyberlei | last post by:
hi all, I`m getting this error Notice: Undefined index: user in c:\inetpub\wwwroot\login.php on line 96 Notice: Undefined variable: message in c:\inetpub\wwwroot\login.php on line 101 Could someone please tell me where I did wrong? Here is the Code, Thanks a lot <?php
1
3047
by: selvialagar | last post by:
<?php require_once('database_conn.php'); session_start(); if(isset($_SESSION)) { if(isset($_GET) && $_GET=="submit") { $cust_id=$_POST; echo $cust_id; }
14
3893
by: selvialagar | last post by:
<?php require_once('database_conn.php'); session_start(); if(isset($_SESSION)) { if(isset($_GET) && $_GET=="submit") { $cust_id=$_POST; echo $cust_id; }
5
2199
by: Twayne | last post by:
Hi, If ever a newbie wants to know how much he has to learn yet, he only has to look here<g>!! ANYway: PHP 5.2.5; XP Pro SP2+, local Apache Server My actual question is: How do I get a POST variable into a session variable so I can use it in any other page I want to use it in? Apparently posted variables are only available in the Form page in
4
6304
by: mattehz | last post by:
Hey there, I am trying to upload old source files and came across these errors: Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_html.php on line 59 Notice: Undefined index: args in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92 Warning: Invalid argument supplied for foreach() in /home/mattehz/public_html/acssr/trunk/inc_error.php on line 92
0
8640
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8589
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8287
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7114
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5548
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4136
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2573
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.