Click here to Skip to main content
14,698,883 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<?php
$emailErr = " ";
$email = " ";
$errors = 0;

if ($_SERVER ["REQUEST_METHOD"] == "POST")
{
  if (empty($_POST ["email"]))
  {
    $emailErr = "Email is required";
    $errors = 1;
  } 
else 
{
  $email = test_input ($_POST ["email"]);
  if (!filter_var ($email , FILTER_VALIDATE_EMAIL))
  {
    $emailErr = "invalid format";
    $errors = 1;
  }
}
}
?>

<title> my website 


<center>
<embed src="BTS.MP3" autostart="true" hidden="true">
<a href="abc.com"></a><br>
<h1 align=" center "> Login </h1><br>
">
<font color="white">
EMAIL ID 
<span class="error">*<?php echo $emailErr;?></span><br>
<br>
PASSWORD<br>
<br>
<br>
<br>

<?php
if ( isset ( $_POST [ 'submit' ] ) && ( $errors == 0) )
{
   echo "<a href="abc.com">Home </a>"
}
?>
<a href="resendpass.html" target="_blank">Forgot password..CLICK HERE </a>
</font>
<font color="red">
NOT REGISTERED YET ?? <a href="http://localhostma1.php" target="_blank">SignUp </a> 
</font>
<br>
<br>
<br>
<br>
<br>
<hr size="2" color="black" noshade="">
<font size="1">  Copyright © 2018 abc Private Limited, India. All rights reserved </font><br>
<a href="https://www.youtube.com" target="_blank"></a>
<a href="https://www.blogger.com" target="_blank"></a>
</center>


What I have tried:

i have tried removing the else and removing spaces between semicolons
Posted
Updated 7-Oct-18 3:28am
v6
Comments
Member 14000568 7-Oct-18 6:33am
   
i have removed the semi colon but still there has been no difference
Kornfeld Eliyahu Peter 7-Oct-18 8:03am
   
That's of course impossible. You may have problems, but removing the semicolon removes the error you reported...
Richard MacCutchan 7-Oct-18 8:10am
   
There should be a semi-colon at the end of the echo statement in the PHP in the second code section. Also, line 10 is not an else clause.

if (empty($_POST ["email"]));

This line represents an empty if - because of the ; at the end - so the actual structure of the code is different from what you may expect!
   
v2
Comments
Richard MacCutchan 7-Oct-18 8:06am
   
You are right in your comment. I deleted my entry.
Quote:
How to remove parse error: syntax error, unexpected 'else' (T_ELSE), expecting end of file in C:\xampp\htdocs\ma.php on line 10

Make sure anything match, even after changes in question;
There is no 'else' on line 10.

Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
<?php
$emailErr = " ";
$email = " ";
$errors = 0;

if ($_SERVER ["REQUEST_METHOD"] == "POST")
{
    if (empty($_POST ["email"]))
    {
        $emailErr = "Email is required";
        $errors = 1;
    }
    else
    {
        $email = test_input ($_POST ["email"]);
        if (!filter_var ($email , FILTER_VALIDATE_EMAIL))
        {
            $emailErr = "invalid format";
            $errors = 1;
        }
    }
}
?>

Professional programmer's editors have this feature and others ones such as parenthesis matching and syntax highlighting.
Notepad++ Home[^]
ultraedit[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900