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
71
15
Other php-forum
Fetching META TAGS through
Hello everybody
I want to fetch meta tags of a domain.
It will be done from following code of
Help on code output
My CODE:
Code: [Select] echo "<phone>".$line["phone"].&qu
need help in php variable
i have a php variable on one page
Code: [Select]$lastId = mysql_insert_id($db);
echo $lastId;<
Preg_match question
I want to use preg_match to make sure a string is always 6 characters long and only contains 0-9 and
please, need help coding this voting for your favorite car polling system.
hi, my code needs a lot of work, but i want to be able to let users vote on their favorite car, upda
unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_
Can anyone view my code and tell me why im getting the error:
Parse error: syntax error, unexpect
Facebook status update API
Hello,
So, I'm trying to create my first Facebook application with PHP.
Basic ideas fo
Update Myspace status with CURL
Logging in:
Code: <?php
class Myspace
{
function login($username, $pa
Checkbox info wont include in Mailto
Hey, im new to php.
Basically I have made a form to request which type of job(s) are needed, whic
Sort a two dimensional array.
Hi. I've set up a two dimensional array that reads as follows:
Code: $modifiedData = array(