Jump to content

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 :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.