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
GET * FROM _____ Except?
I have a site that is for stock photography.
This section of the code calls images to display
Help, Base64 encoding url and decoding server side.
Hello everyone, i have a website with videos and games and also provide an embed code which people c
what does this mean? +=
is anyone able to explain what this code is saying?
i had it written for me awhile back and n
Help with form post data and arrays
Hi all,
I am new to this forum... It has been awhile since i have worked with arrays, and i a
RSS feed - FeedList for WordPress
Hi,
I'm trying to alter the FeedList plugin for WordPress so that I can click on the title of
GMail like Chat in ASP.NET
Hi,Can anyone suggest me, how to incorporate GMail like chat in my existing ASP.Net application.I wa
Need help with cin setw
I made a program here is my code:
#include
#include
#i
Create multiple (n) arrays
Hi there,
I have the following need:
I have 2 arrays (coming from a databases)
Renaming a file that a user uploads to site?
My site allows for registered users to upload images to the site under their own gallery. Currently
single page with referrer to show correct page
I have a simple website with a couple of different pages. I would like to be able to in a div tag w