isset undefined variable
Posted on
16th Feb 2014 07:03 pm by
admin
Hi all,
Hope someone can point out the obvious. I've a log in script, if you dont enter a username or pw, you get a red asterix show by the field and a pop up.
If you enter an email but not the pw, it says Undefined variable: email_error .
This is the code:
// Validate the email address.
if (!empty($_POST['email'])) {
$e = escape_data($_POST['email']);
} else {
echo '<script type="text/javascript">alert("You forgot to enter your email address!");</script>';
#echo '<p class="error">You forgot to enter your email address!</p>';
$e = FALSE;
$email_error = '<span class="required"><img src="images/star.gif" /></span>';
}
// Validate the password.
if (!empty($_POST['pass'])) {
$p = escape_data($_POST['pass']);
} else {
$p = FALSE;
echo '<script type="text/javascript">alert("You forgot to enter your password!");</script>';
$pw_error = '<span class="required"><img src="images/star.gif" /></span>';
#echo '<p class="error">You forgot to enter your password!</p>';
}
My form looks like:
<form action="login.php" method="post">
<table border="0" width="310">
<tr>
<td><img src="images/email_address.gif" /></td>
<td><div class="myBoxLh"></div><input type="text" name="email" style="width:150px;" maxlength="90" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /><div class="myBoxRh"></div><?php if (isset($_POST['submitted'])) { echo $email_error; }?></td>
</tr>
<tr>
<td><img src="images/password.gif" /></td>
<td><div class="myBoxLh"></div><input type="password" name="pass" style="width:150px;" maxlength="20" /><div class="myBoxRh"></div><?php if (isset($_POST['submitted'])) { echo $pw_error; }?></td>
</tr>
<tr>
<td colspan="2"><div align="left"><?php if (isset($_POST['submitted'])) { echo $error_message; }?></div><div align="right"><input type="image" src="images/submit.jpg" name="submit" value="Login" class="submit_small" /></div>
<input type="hidden" name="submitted" value="TRUE" /></td>
</tr>
</table>
</form>
How can I stop this error as I thought I'd coded the correct way?
Thanks in advance
No comments posted yet
Your Answer:
Login to answer
71
15
Other forums
Character Sets/Collations Stuff
Can someone please give me a check list of things I must do to setup all the charset stuff for my ph
POST into Array problem
Hi Chaps,
I have a repeat region, displaying rows of data: jobid, fromtable, translatorcharge
drop-down with sub-category appear
Hello,
i know how to build a simple dro-down list, im looking for a code when im gonna choose
Pipe email to PHP - get mail adress from MySQL - send?
Hi all,
this is the challenge:
1) Our faculty at the college where I'm employed includ
Scene graph using Direct3D?
There are several C++ scene graph based packages available for OpenGl, like say OSG,
http://w
selection tool on raster image
Hi!
I have to implement in my app a selection tool which lets users to select region of any shape
Get content from table into a list, without repeating.
Alright this is kinda an odd thing, so I need some help.
I have a table "quote" wit
paginate search result
Hi, I have a paginations script to display data from my database but i would like to paginate someon
Problem assigning value to variable in "IF" function
Does this script makes sense? I am trying to take the value that is set to "authenticat" a
Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re