473,323 Members | 1,622 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,323 software developers and data experts.

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

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
5 7151
Atli
5,058 Expert 4TB
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
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 Expert 4TB
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
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
[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

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

Similar topics

3
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...
9
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...
3
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...
3
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...
4
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...
1
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
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
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...
4
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.