Reply to php.ini and sessions

Your name:

Reply:


Posted by Ike on 06/09/05 03:41

Can someone please help. I've installed php the latest php <5.0 I have not
altered php.ini. I keep getting the following error within my broweser when
I attempt to authenticate from index.php (enclosed). Ive also enclosed
login.php. I'm running this under an apache web server on windows. Does
anyone have any idea why this wont run (I assume it is with a setting in my
php.ini, or, my directory structure under my web root - any ideas?). Ive
enclosed the relevant files below the error message, thanks, Ike

---------error msg:-----------------------
Notice: Undefined index: newUser in C:\Program Files\Apache
Group\Apache2\htdocs\login.php on line 20

Warning: Cannot modify header information - headers already sent by (output
started at C:\Program Files\Apache Group\Apache2\htdocs\login.php:20) in
C:\Program Files\Apache Group\Apache2\htdocs\login.php on line 133

------index.php----------------------------
<?php
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Imperial Heating &amp; Cooling Inc.</title>
<script language="JavaScript" type="text/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>
<script language="JavaScript">
function trim(strText) {
// this will get rid of leading spaces
while (strText.substring(0,1) == ' ')
strText = strText.substring(1, strText.length);

// this will get rid of trailing spaces
while (strText.substring(strText.length-1,strText.length) == ' ')
strText = strText.substring(0, strText.length-1);

return strText;
}

function chkLogin()
{
if (trim(document.frmLogin.txtUName.value)=="")
{
alert("Please Enter Username ... ");
document.frmLogin.txtUName.select();
document.frmLogin.txtUName.focus();
return false;
}
if (trim(document.frmLogin.txtPassword.value)=="" &&
(document.frmLogin.newUser==false))
{
alert("Please Enter Password ... ");
document.frmLogin.txtPassword.select();
document.frmLogin.txtPassword.focus();
return false;
}
}

function checkNewUser()
{
document.frmLogin.txtPassword.value="";
document.frmLogin.txtPassword.disabled = document.frmLogin.newUser.checked;
}

</script>
<link href="ihc.css" rel="stylesheet" type="text/css">
</head>

<body bgcolor="#FFF9FA" leftmargin="0" topmargin="0" marginwidth="0"
marginheight="0" onLoad="document.frmLogin.txtUName.focus()">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="418"><img src="images/imperial_logo.jpg" width="418"
height="111"></td>
<td align="right" valign="bottom" style="padding:10px"><img
src="images/van.jpg" width="115" height="62"></td>
</tr>
<tr bgcolor="#003366">
<td colspan="2"><img src="images/spacer.gif" width="5"
height="2"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td style="padding-left:5px">
<table width="220" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="2"><img src="images/spacer.gif" width="2"
height="50"></td>
<td><?php
if(isset($HTTP_SESSION_VARS["errLogin"]))
{
echo("<table width='100%' border='0' cellspacing='3' cellpadding='2'
style='border:1px solid #666666'>");
echo("<tr>");
echo("<td class='tNormal' align='center'><font color='#FF0000'>");
echo($HTTP_SESSION_VARS["errLogin"]);
echo("</font></td>");
echo("</tr>");
echo("</table>");
session_unregister("errLogin");
session_destroy();
unset($errLogin);
}
else if(isset($HTTP_SESSION_VARS["newLogin"]))
{
echo("<table width='100%' border='0' cellspacing='3' cellpadding='2'
style='border:1px solid #666666'>");
echo("<tr>");
echo("<td class='tNormal' align='center'><font color='#FF0000'>");
echo($HTTP_SESSION_VARS["newLogin"]);
echo("</font></td>");
echo("</tr>");
echo("</table>");
session_unregister("newLogin");
session_destroy();
unset($errLogin);
}
?></td>
</tr>
</table></td>
<td rowspan="2" align="center" valign="top"><img
src="images/collage.jpg" width="298" height="282"></td>
</tr>
<tr>
<td align="left" valign="top" style="padding-left:5px ">
<form action="login.php" method="post" name="frmLogin" id="frmLogin"
onSubmit="return chkLogin()" style="margin:0px">
<table width="220" border="0" cellspacing="3" cellpadding="2"
style="border:1px solid #666666">
<tr>
<td align="center" class="loginHead" style="border-bottom:1px
solid #666666">Member
Login</td>
</tr>
<tr>
<td><table width="100%" border="0" cellspacing="0"
cellpadding="2">
<tr>
<td align="right" class="loginTxt">Username&nbsp;</td>
<td class="loginTxt"><font
color="#003366">&raquo;</font></td>
<td><input name="txtUName" type="text" class="input1"
id="txtUName" size="15"></td>
</tr>
<tr>
<td align="right" class="loginTxt">Password&nbsp;</td>
<td class="loginTxt"><font
color="#003366">&raquo;</font></td>
<td><input name="txtPassword" type="password"
class="input1" id="txtPassword" size="15"></td>
</tr>
</table></td>
</tr>
<tr>
<td align="center" class="tNormal" style="border-top:1px solid
#666666"><input type="submit" name="Submit" value="Submit" class="input1" >
<input name="isNewUser" type="hidden" id="isNewUser">
<input name="newUser" type="checkbox" class="input1"
id="newUser" onClick="checkNewUser()" value="New User">
New User </input>
</td>
</tr>
</table>
</form>
<table width="200" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" class="tNormal"><a href="#"
onClick="javascript:window.open('forgotpassword.php','ForgotPassword','heigh
t=200,width=300')">Forgot Password</a></td>
</tr>
</table></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>

---------------login.php------------------------------------
<?php
session_start();
include_once("db_conn.php");

include_once("sendmail.php");

session_unregister("UName");
session_unregister("UID");
session_unregister("UserTypeID");


$UName = stripslashes(trim($HTTP_POST_VARS['txtUName']));
//$Password = md5($HTTP_POST_VARS['txtPassword']);
$Password = stripslashes(trim($HTTP_POST_VARS['txtPassword']));
//echo ("Username - ".$UName."<br>");
//echo ("Password - ".$Password."<br>");
//echo ($query);
//exit();

if($HTTP_POST_VARS['newUser']==true)
{
$query = "Select * from IHC_User where Name = '".$UName."'";
$str_qry = mysql_query($query) or die("Query failed: ".mysql_error());
$nrow = mysql_num_rows($str_qry);
if($nrow>=1)
{
$errLogin = "User already registered.";
session_register("errLogin");
header('location:index.php');
}
else
{

$username = str_pad($UName,41,"\0",1);
$query = "Select ListID, Name, Email from customer where Name =
'".$username."'";
$str_qry = mysql_query($query) or die("Query failed: ".mysql_error());
$nrow = mysql_num_rows($str_qry);
if($nrow>1)
{
$errLogin = "Duplicate Name(s) found.";
session_register("errLogin");
header('location:index.php');
}
else if($nrow==0)
{
$errLogin = "No such User<br>Please Try Again.";
session_register("errLogin");
header('location:index.php');
}
else
{
$str_result = mysql_fetch_array($str_qry);
if(trim($str_result["Email"])=="")
{
$errLogin = "No email found<br>Please Contact Administrator.";
session_register("errLogin");
header('location:index.php');
}
else
{
$UName = trim($str_result["Name"]);
$listid = $str_result["ListID"];
$len = strpos($UName,' ');
if(len==-1)
$len = strlen($UName);
$shortName = substr($UName,0,$len);
$password = $shortName;
$email = trim($str_result["Email"]);
$UserTypeID = 4;
$query = "Insert into IHC_User (Name,ShortName,Password,UserTypeID,Email)
Values('".$UName."','".$shortName."','".$password."',".$UserTypeID.",'".$ema
il."');";

mysql_query($query) or die("Error: ".mysql_error());

$lastinsertid = mysql_insert_id();

$query = "Insert into IHC_CustomerUser (CustomerListID,UserID) Values
('".$listid."', ".$lastinsertid.");";

mysql_query($query) or die("Error: ".mysql_error());

$mailto=$email;
$mailfrom=""; // Email from IHC hardcoded
$subject="Password";
$body="Date :- ".date("d-M-Y h:i a")."<br>";
$body=$body."UserName: ".$UName."<br>";
$body=$body."Password :- ".$password."<br>";
$body=$body."Regards.<br><br>";
$body=$body."<font size=1>Note:-Computerised message hence not
Signed</font>";
sendmail($mailto,$mailfrom,$subject,$body);

session_unregister("UName");
session_unregister("UserTypeID");
$newLogin = "New Login Successfull.<br>Please check your e-mail for
details.";
session_register("newLogin");
unset($errLogin);
header('location:index.php');
}
}
}
}
else
{
$query = "Select * from IHC_User where Name = '".$UName."'";
$str_qry = mysql_query($query) or die("Query failed : " . mysql_error());
$str_result = mysql_fetch_array($str_qry);
if ($str_result)
{
if($str_result["Password"] == $Password)
{
//echo ("Login Success");
//exit();
$UName = trim($str_result["Name"]);
$UID = trim($str_result["ID"]);
$UserTypeID = $str_result["UserTypeID"];

session_register("UName");
session_register("UID");
session_register("UserTypeID");
session_unregister("errLogin");
unset($errLogin);
header('location:uhome.php');
}else{
$errLogin = "Invalid UserName / Password... <br>Please Try Again.";
//$errLogin = $errLogin."Password Failed";
session_register("errLogin");
//echo ($errLogin);
header('location:index.php');
}
}else{
$errLogin = "Invalid UserName / Password... <br>Please Try Again.";
//$errLogin = $errLogin."UserName Failed";
session_register("errLogin");
//echo ($errLogin);
header('location:index.php');
}
}
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация