Jump to content

help with log in form


stokie-rich

Recommended Posts

hey can any one help im designing a website with php for uni and i cannot get my log in page to work

 

it keeps saying sometging about the else statement

 

<?php
//password parameter 
if ($_POST["user"] == "user" && $_POST["password"]== "password")

//this is if the users password matches the one on the systems, it will then load into the main website 		
  {header('location:http://Fcetdev1.student.staffs.ac.uk/wwwdata/DSA/2009-2010/hv001341/Hospital Login Success.html');}
  //new connection object

$adoCon = new COM("ADODB.Connection");
$sHere = dirname(__FILE__);

//opens the connection using a standard connection string




$adoCon->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\Fcetdev1.student.staffs.ac.uk\wwwdata\DSA\2009-2010\0db\Hv001341");

$rsmain = $adoCon->Execute ("SELECT * FROM tblusers WHERE usname ='$sUser';");

$suserfirstname =$rsmain->Fields("userfirstname")->Value;
$suserlastname =$rsmain->Fields("userlastname")->Value;
echo "Welcome $sfname $slname you have succesfully logged in <br/> \n" 
// if the password is not correct then the user will be show  a incorrect password screen and then re-directed back to the main log in page

else
{header('location:http://Fcetdev1.student.staffs.ac.uk/wwwdata/DSA/2009-2010/hv001341/Hospital Login Denied.html');}
//Assigning of the variables  to php

$sUser = $_POST["Username"];
$sPass = $_POST["Password"];
?>


 

thanks

 

rich

Link to comment
https://forums.phpfreaks.com/topic/184268-help-with-log-in-form/
Share on other sites

You need to close the if before you start an else. You don't have an end bracket }

 

He has the end bracket, but you are almost there. You have to start the else right after the if ends. Not doing so causes some syntax errors.

 

if ($correct) {
// code here
}else {
//code here
}

 

The above is correct way to do it, below is the wrong way

if (!$correct) {

} 
//code here
else {

}

 

Hope that clears it up for you :)

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.