By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

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

P: 6
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\wwwroot\sampleft\index.php on line 116

Notice: Undefined variable: username in C:\Inetpub\wwwroot\sampleft\index.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
Share this Question
Share on Google+
5 Replies


Atli
Expert 5K+
P: 5,058
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

P: 6
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
Expert 5K+
P: 5,058
Looks like the session.save_path 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:\sessiondata\'), 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

P: 6
Looks like the session.save_path 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:\sessiondata\'), 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_path="/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_path="C:\sessiondata" 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

P: 6
[quote=siyaverma]
This is the value which is already there
sesison.save_path="/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_path="C:\sessiondata" 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

Post your reply

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