Hi guys,
I just got a new pc and copied all my php projects from the old pc.
I also installed the latest version of XAMPP, Netbeans and PHP.
All my projects were fine but now are showing the following errors:
Notice: Undefined index: Submit in C:\xampp\htdocs\QuickBeam\index.php on line 8
Notice: Undefined index: action in C:\xampp\htdocs\QuickBeam\index.php on line 63
Notice: Undefined variable: warning in C:\xampp\htdocs\QuickBeam\index.php on line 104
I have been working with PHP 5 for the last 2 years and never saw this error.
I dont know if it has anything to do with the new version of PHP I installed.
Code:
<?php
require_once 'inc.php';
?>
<?php
//DO Login when the button is clicked
if("Login" == $_POST['Submit']){
$_user = CleanData($_POST['user_name']);
$_pwd = CleanData($_POST['user_pwd']);
//both fields required
if("" != $_user && "" != $_pwd)
{
$hash_val = md5($_pwd);
$password = $hash_val;
//set object from authentication class
$User = strtolower($_user);
$auth = new Registration();
$auth->Login($User, $password);
//call the helper function to find out the valaue of sucsees property
if($auth->Success()){
//set user session
$_SESSION['regis_user'] =$User;
//redirect the user
header("location: index.php");
exit();
}else{
$auth2 = new Authentication();
$auth2->login($User,$password);
if($auth2->Success()){
//set user session
$_SESSION['admin_user'] =$User;
//redirect the user
header("location: admin/home.php");
exit();
}else{
$warning=" Incorrect username or Password!";
}
}
} else{
$warning=" Both fields are required!";
}
}
?>
<?php
//check for logout
if("logout"==$_GET['action']){
$auth=new Authentication();
$auth->logout();
$auth2=new Registration();
$auth2->Logout();
}
?>
<?php PublicHeader();?>
<?php PublicNav();?>
<div id="wrapper">
<div id="content">
<?php if(!isset($_SESSION['regis_user'])){
if(!isset($_SESSION['admin_user'])) {?>
<fieldset id="fld_login">
<form method="post" action="index.php">
<table>
<td>
<label for="user_name" class="required">Name:</label>
<input type="text" name="user_name" id="user_name" size="30" value="<?php echo $_user; ?>">
</td>
<td>
<label for="user_pwd" class="required">Password:</label>
<input type="password" name="user_pwd" id="user_pwd" size="30">
</td>
<td>
<input type="submit" name="Submit" value="Login" class="button">
</td>
<td><?php if($warning){ echo("<p class='error_message'>{$warning}");}?></td>
</table>
</form>
</fieldset>
<?php }} ?>
<div align="center"><h2>Welcome to QuickBeam</h2></div>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']?>">
<input type="text" name="date" id="date">
</form>
<div align="left"><img alt ="" src="images/myimg2.jpg" />
</div>
</div>
</div>
<?php PublicFooter();?>
Any help is welcome,
Mike
Last edited by MikeSpider; 09-22-2012 at 10:16 AM.
I deleted the all block just an experiment, the errors are still there.
What exactly should I change the line to?
Also, if this is a default for the latest version of PHP, wIll the remote host have the same error reporting? I know I cannot change the remote host .ini config file.
Thanks for your reply,
Mike
Last edited by MikeSpider; 09-23-2012 at 05:01 AM.
On production machines it is usually set to not display errors, so when uploading to your host it is not a concern. I would leave it set to e_all on your testing machine, but if you really want to turn them off, you will need to go down further. That part is showing the differences between default, development and production machines. On my php.ini it is about line 461 that has the actual setting, and below that is the display_error setting, you can turn that off if you wish. I recommend it be on for your testing machine though, or else you will get a white screen and not know what happened.
You are getting it because the error_reporting or display_errors is set differently in this new installation of XAMPP. As these are just warnings, your script will work fine as it is. Some people like to have all their variables declared, which is good practice. if you do that, you will not have the warnings.
DAH! lol
How did I forget that?
I guess this is what happens when you give yourself some php holidays.
I stayed away from PHP the entire month just doing vb.net. And when I got back got all this errors
it's been a very cold welcome back indeed. 2 days and I should get back on my feet again.
Bookmarks