big problem, lots of undefined indexes help
Moderator: General Moderators
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
big problem, lots of undefined indexes help
I have lots of undefined indexes, ( Notices ) but they're all over my screen
I cant get them off
Question 1: will they be seen, when I actually upload the website to a server?
Question 2: how do I get rid of them
I dont know how cus
I have 2 pages...
"Signup" and "mailpage"
when you click signup it checks if the text boxes have enough or not to much text in them
(username, password, confirm password)
it also checks if password matches confirm password & e-mail matches confirm e-mail
but the way I check is if (strlen($_POST['nameofbox'], but I get the notice, because 'nameofbox' doesnt exist on this page, but it exists on another page, and must be checked
how do I fix this?
I cant get them off
Question 1: will they be seen, when I actually upload the website to a server?
Question 2: how do I get rid of them
I dont know how cus
I have 2 pages...
"Signup" and "mailpage"
when you click signup it checks if the text boxes have enough or not to much text in them
(username, password, confirm password)
it also checks if password matches confirm password & e-mail matches confirm e-mail
but the way I check is if (strlen($_POST['nameofbox'], but I get the notice, because 'nameofbox' doesnt exist on this page, but it exists on another page, and must be checked
how do I fix this?
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
isset() and/or array_key_exists() may be of interest.
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
ty
Thanks, but how would I use it, 
Code: Select all
if(isset($var)){
print $var;
}-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
hmm
Burrito | Please use
this is the error...
Notice: Undefined index: user in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 25
putting that isset() thing infront of it didnt make it go away
( I have 12 others of these )
there not actually variables incase you didnt realize, there names of textboxes / radio buttons / check boxes / password boxes
Burrito | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Didnt do anythingCode: Select all
if(isset($_POST['user']))
{
print $_POST['user'];
}Notice: Undefined index: user in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 25
putting that isset() thing infront of it didnt make it go away
( I have 12 others of these )
there not actually variables incase you didnt realize, there names of textboxes / radio buttons / check boxes / password boxes
Burrito | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact:
hmm
it works fine, BUT I HATE THIS NOTICES, they're evil, they make the page look funny, this is the entire code OK?
These are the errors
the ERROR: your username/password n so is my personal errors ignore them
Code: Select all
<html>
<head>
<style type="text/css">
body
{
background-image:
url('SilverBG.jpg')
}
</style>
</head>
<img src="Mythic Aeons Banner.jpg" width="1008" height="125">
<div align='center'>
<body>
<?php
$bool[3]=true;
$bool[4]=true;
$bool[5]=true;
$bool[6]=true;
$bool[7]=true;
$bool[8]=true;
if (strlen($_POST['user']) < 5)
{
$bool[3]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no less then 5 characters long.<br/></i></font>';
}
else if (strlen($_POST['user']) > 18)
{
$bool[6]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no more then 18 characters long.<br/></i></font>';
}
else
{
echo '<b>Your username is the correct length.</b><br/>';
}
if (strlen($_POST['pw1']) < 5)
{
$bool[4]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your password must be no less then 5 characters long.<br/></i></font>';
}
else if (strlen($_POST['pw1']) > 20)
{
$bool[7]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your password must be no more then 20 characters long.<br/></i></font>';
}
else
{
echo '<b>Your password is the correct length.</b><br/>';
}
if (strlen($_POST['pw2']) < 5)
{
$bool[5]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your confirm password must be no less then 5 characters long.<br/></i></font>';
}
else if (strlen($_POST['pw2']) > 20)
{
$bool[8]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your confirm password must be no more then 20 characters long.<br/></i></font>';
}
else
{
echo '<b>Your confirm password is the correct length.</b><br/>';
}
if (strlen($_POST['user']) > 18)
{
$bool[6]=false;
echo 'bool 6';
}
if (strlen($_POST['pw1']) > 20)
{
$bool[7]=false;
echo 'bool 7';
}
if (strlen($_POST['pw2']) > 20)
{
$bool[8]=false;
echo 'bool 8';
}
$email[1]=$_POST['email1'];
$email[2]=$_POST['email2'];
$pw[1]=$_POST['pw1'];
$pw[2]=$_POST['pw2'];
$bool[1]=true;
$bool[2]=true;
if ($email[1] == $email[2])
{
echo " <b>Your e-mail's match.</b> <br/>";
}
else
{
echo "<b><font color='darkblue' size='4'>Your e-mail's do not match.</font></b></br>";
$bool[1]=false;
}
if ($pw[1] == $pw[2])
{
echo "<b>Your passwords match.</b>";
}
else
{
echo "<b><font color='darkred' size='4'>Your password's do not match.</font></b>";
$bool[2]=false;
}
if ($bool[1] == true && $bool[2] == true && $bool[3] == true && $bool[4] == true && $bool[5] == true && $bool[6] == true && $bool[7] == true && $bool[8] == true)
{
$msg='<font color="darkred" size="4">Welcome to Mythic Aeons</font>';
$subject='Activation Code';
$from='MythicAeons@yahoo.com.au';
$headers='From: '.$from;
mail($_POST['email1'],$subject,$msg,$headers);
echo '<font color="blue" size="4">Your Activation code & details have been e-mailed to you</font>';
}
?>
</body>
</html>These are the errors
the ERROR: your username/password n so is my personal errors ignore them
Code: Select all
Notice: Undefined index: user in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 22
Error: Your username must be no less then 5 characters long.
Notice: Undefined index: pw1 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 40
Error: Your password must be no less then 5 characters long.
Notice: Undefined index: pw2 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 55
Error: Your confirm password must be no less then 5 characters long.
Notice: Undefined index: user in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 70
Notice: Undefined index: pw1 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 76
Notice: Undefined index: pw2 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 82
Notice: Undefined index: email1 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 93
Notice: Undefined index: email2 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 94
Notice: Undefined index: pw1 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 95
Notice: Undefined index: pw2 in c:\program files\easyphp1-8\www\test\youhavebeene-mailed.php on line 96- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
wrap all code that makes use of $_POST inside a condition such as this...
Code: Select all
if (!empty($_POST)) { }Re: hmm
Code: Select all
<?php
if (isset($_POST['user']) && strlen($_POST['user']) < 5){
$bool[3]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no less then 5 characters long.<br/></i></font>';
}else if (isset($_POST['user']) && strlen($_POST['user']) > 18){
$bool[6]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no more then 18 characters long.<br/></i></font>';
}else{
echo '<b>Your username is the correct length.</b><br/>';
}
?>Code: Select all
<?php
if(isset($_POST['user'])){
if (strlen($_POST['user']) < 5){
$bool[3]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no less then 5 characters long.<br/></i></font>';
}else if (strlen($_POST['user']) > 18){
$bool[6]=false;
echo '<font color="blue" size="4">Error:</font><font color="blue" size="3"><i> Your username must be no more then 18 characters long.<br/></i></font>';
}else{
echo '<b>Your username is the correct length.</b><br/>';
}
}
?>But if the user doesn't fill out some part of the form, he still would get notices..ole wrote:wrap all code that makes use of $_POST inside a condition such as this...Code: Select all
if (!empty($_POST)) { }
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
-
Mythic Fr0st
- Forum Contributor
- Posts: 137
- Joined: Sat Dec 02, 2006 3:23 am
- Contact: