Jump to content

Need Help: Else code


Cyan

Recommended Posts

Just new to this website and I keep getting several errors in my "else" code. I can't seem to find wrong codes in it (I'm just a rookie in programming) 

 

My codes is here:

<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username == '12345' and $password == '12345');
{
 
echo 
'<h1> Welcome To The Site! </h1>
 <br>
 <br>
 <br>
 This site will let you post your ideas!
  <br>';
}
 
else
 
{
 
echo 'Wrong Username and Password';
 
}
 
?>
 
I keep having errors in bold text. Since I'm new at programming, I don't understand some errors that were shown to me in the actual site. The only error that I get is (T_ELSE) which I don't understand. So can someone help me what should I do with it since I'm just new. (I am also new to the site so I'm sorry if I did anything wrong)
Link to comment
https://forums.phpfreaks.com/topic/289811-need-help-else-code/
Share on other sites

It sounds like you are running the script without sending any POST data to it. You need check if the data exists.

$username = isset($_POST['username'] ? $_POST['username'] : '';
$password = isset($_POST['password'] ? $_POST['password'] : '';
Link to comment
https://forums.phpfreaks.com/topic/289811-need-help-else-code/#findComment-1484879
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.