"Error" Messages

Problems with the Windows version of XAMPP, questions, comments, and anything related.

"Error" Messages

Postby KeithAus » 19. April 2011 22:41

Recently I updated from Xampp 1.7.3 to 1.7.4, when I go into a login page on my site (written in PHP) i get an error message "Notice: Undefined index: submitbutt in C:\xampp\htdocs\bazaar\login.php on line 22" this message is in the Begin Body Content area of the code when it displays on the page.

If I enter a user name that is in my database, it allows me to log in, but i then get 2 error message appearing at the top of the Begin Header, messages read:
1"Notice: Use of undefined constant myusername - assumed 'myusername' in C:\xampp\htdocs\bazaar\purchase.php on line 4"
And
2"Deprecated: Function session_is_registered() is deprecated in C:\xampp\htdocs\bazaar\purchase.php on line 4"

Until I updated Xampp, I had none of these code errors. Can someone help out please?

The codes for the login page is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Login</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascript/date.js"></script>
<script language="JavaScript" type="text/javascript"></script>
</head>
<body>
<div id="wrapper">
<!--Begin Header-->
<?php
include ("header.php");
?>
<!--End Header-->
<div>
<!--Begin Body Content-->
<div id="bcell_1_1">.:&nbsp;Login&nbsp;:.</div>
<div id="bcell_1_2">Existing Member<br />
<?php
if($_POST['submitbutt']) {
echo "myusername: ". $_POST['UserName'] ."<br />";
echo "mypassword: ". $_POST['Password'] ."<br />";
}
else {
?>

<form name="form1" method="post" action="checklogin.php">
<p>User Name:<br>
<input name="UserName" type="text" id="UserName">
<p>Password:<br />
<input name="Password" type="password" id="Password">
<p>
<input type="submit" name="login" value="Login" />
</form>
<?php
}
?>
</div>
<!--End Body Content-->
</div>
<div>
<!--Begin Footer Content-->
<?php
include ("footer.php");
?>
<!--End Footer Content-->
</div>
</div>
</div>
</body>
</html>


And the code for the purchase page is as follows:

<?php // Check if session is not registered , redirect back to main page.
// Put this code in first line of web page.
session_start();
if(!session_is_registered(myusername))
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Purchase</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="javascript/date.js"></script>
<script language="JavaScript" type="text/javascript"></script>
</head>
<body>
<div id="wrapper">
<!--Begin Header-->
<?php
include ("headerli.php");
?>
<!--End Header-->
<div>
<!--Begin Body Content-->
<div id="bcell_1_1">.:&nbsp;Purchase&nbsp;:.&nbsp;&nbsp;&nbsp;Welcome, <?php echo $_SESSION["UserName"]?>, you are now logged in!</div>
<div id="bcell_1_2">To make a purchase simly click the "add to cart" button and then select the "purchase" button when you have completed your shopping</div>
<!--End Body Content-->
</div>
<div>
<!--Begin Footer Content-->
<?php
include ("footer.php");
?>
<!--End Footer Content-->
</div>
</body>
</html>
KeithAus
 
Posts: 1
Joined: 19. April 2011 22:34

Re: "Error" Messages

Postby Altrea » 20. April 2011 04:42

Hi KeithAus,

KeithAus wrote:Until I updated Xampp, I had none of these code errors.

Because your error_reporting level was set to a less strict value in your previous installation.

KeithAus wrote:Notice: Undefined index: submitbutt in C:\xampp\htdocs\bazaar\login.php on line 22

This message occurs because you want to use an array index, which doesn't exist in your context.
Your line 22 is this one:
Code: Select all
if($_POST['submitbutt']) {

You test if $_POST['submitbutt'] is true, but $_POST['submitbutt'] is not true or false, it's not set until you send your form.
So the better test will be this one:
Code: Select all
if(!empty($_POST['submitbutt'])) {


KeithAus wrote:Notice: Use of undefined constant myusername - assumed 'myusername' in C:\xampp\htdocs\bazaar\purchase.php on line 4
Deprecated: Function session_is_registered() is deprecated in C:\xampp\htdocs\bazaar\purchase.php on line 4

line 4 is that one:
Code: Select all
if(!session_is_registered(myusername))

1.: Everytime you want to use a word as string, you should wrap it into single or double quotes. Otherwise PHP tries to find this word as setted constant first.
2.:You used an old implementation of session handling. These session functions are marked as deprecated because they will be fully removed in one of the next major php releases (PHP 6). You should inform yourself how to handle with sessions in the current PHP versions.

Again you want to check if a value (in this case a Session value) is empty/setted or not
This should work for line 4:
Code: Select all
if(!empty($_SESSION['myusername']))
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11935
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 94 guests

cron