php undefined index: email in /// on line 26 Help pls

Status
Not open for further replies.

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
hello, i was wondering if someone could help me out with this error im getting.
I am new to php, i have been studying it and watching videos on it from lynda.com
im totally self teaching and im trying to get this down but its still pretty confusing to me.

Notice: Undefined index: email in */*/public_html/forgot_pass.php on line 26
any help would be much apprciated i have been racking my brain on this one for hours now and i just dont know what im not getting right! Thank you so much!!
im also concerned about line 30 eregi_replace eeek pls help

$outputForUser = "";
if ($_POST['email'] != "") {
$email = $_POST['email'];
$email = strip_tags($email);
$email= eregi_replace("`", "", $email);
$email = mysql_real_escape_string($email);
$sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND email_activated='1'");
$emailcheck = mysql_num_rows($sql);
if ($emailcheck == 0){

$outputForUser = '<font color="#FF0000">There is no account with that info<br />
in our records, please try again.';
} else {

$emailcut = substr($email, 0, 4); // Takes first four characters from the user email address
$randNum = rand();
$tempPass = "$emailcut$randNum";
$hashTempPass = md5($tempPass);
@mysql_query("UPDATE myMembers SET password='$hashTempPass' where email='$email'") or die("cannot set your new password");
$headers ="From: $adminEmail\n"; // $adminEmail is established in [ scripts/connect_to_mysql.php ]
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
$subject ="Login Password Generated";
$body="<div align=center><br>----------------------------- New Login Password --------------------------------<br><br><br>
Your New Password for our site is: <font color=\"#006600\"><u>$tempPass</u></font><br><br />
</div>";
if(mail($email,$subject,$body,$headers)) {
$outputForUser = "<font color=\"#006600\"><strong>Your New Login password has been emailed to you.</strong></font>";
} else {

$outputForUser = '<font color="#FF0000">Password Not Sent.<br /><br />
Please Contact Us...</font>';
}

}
} else {

$outputForUser = 'Enter your email address into the field below.';
}
 
Last edited:

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
ok did i ask a stupic quesiton or did i not provide needed information? i have been sitting here for almost four hours trying to figure this out. i sure could use some help i'll be eternally greatful if someone can lend me a hand here.
 

descalzo

Grim Squeaker
Community Support
Messages
9,375
Reaction score
327
Points
83
Code:
if ($_POST['email'] != "")

is causing the problem. The $_POST array does not have an element indexed by 'email'. So you get the error notice.

You should test:

Code:
if ( isset($_POST['email']) && $_POST['email'] != "" )

which first tests to see if it is set, then tests to see if it is not the empty string.
 

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
ok thank you so much for your help that fixed the line 26 problem now on the same page though i still have the deprecated regi_replace on line 31 and an undefined variable on line 49

$outputForUser = "";
if ( isset($_POST['email']) && $_POST['email'] != "" )
{

$email = $_POST['email'];
$email = strip_tags($email);
$email= eregi_replace("`", "", $email);
$email = mysql_real_escape_string($email);
$sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND email_activated='1'");
$emailcheck = mysql_num_rows($sql);
if ($emailcheck == 0){

$outputForUser = '<font color="#FF0000">There is no account with that info<br />
in our records, please try again.';

} else {

line 49 $emailcut = substr($email, 0, 4); // Takes first four characters from the user email address
$randNum = rand();
$tempPass = "$emailcut$randNum";
$hashTempPass = md5($tempPass);

@mysql_query("UPDATE myMembers SET password='$hashTempPass' where email='$email'") or die("cannot set your new password");

$headers ="From: $adminEmail\n"; // $adminEmail is established in [ scripts/connect_to_mysql.php ]
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1 \n";
$subject ="Login Password Generated";

$body="<div align=center><br>----------------------------- New Login Password --------------------------------<br><br><br>
Your New Password for our site is: <font color=\"#006600\"><u>$tempPass</u></font><br><br />
</div>";

if(mail($email,$subject,$body,$headers)) {

$outputForUser = "<font color=\"#006600\"><strong>Your New Login password has been emailed to you.</strong></font>";
} else {

$outputForUser = '<font color="#FF0000">Password Not Sent.<br /><br />
Please Contact Us...</font>';
}

}

} else {

$outputForUser = 'Enter your email address into the field below.';

}
 

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
how if i could just figure out why this variable keeps coming up undefined, sheesh,

$headers ="From: $adminEmail\n"; // $adminEmail is established in [ scripts/connect_to_mysql.php ]

then everything will be perfect!! :)

says i have it established in connect_to_mysql but it's not...?...
 

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
it kinda bothers me that i have to put pressure on to get help with x10? i dont like that much at all im a really nice person and it makes me look like a jerk...
 
Messages
740
Reaction score
1
Points
18
People do have lives. You just need to be a tad more patient. Posting it in the correct section in the first place would have helped!
 

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
pardon me but i thought this was the right place. 1st and 2nd its taking hours to a response. dont misunderstand people have been helpful but its been very few and far between.

the problem im having im sure is not very complicated i just am so new to php that im not getting it just right.

i do appologise, like i said im not a jerk, just very frustrated with the x10 support, been trying to get into the irc chat all day aswell and i keep getting pat answers to my support tickets and no resolution. i have only actually gotten access 1 time for a few minuets and then it stopped working again.
 
Last edited:

chrismcf

New Member
Messages
18
Reaction score
0
Points
0
gonna close this one up. i looked in the third party applications and programming thread but there doesnt seem to be a way to post in there. not sure where else to post but here but i welcome instruction anytime. thank you guys for the help you have give me so far.
 
Status
Not open for further replies.
Top