help with online databases
Posted: Fri Oct 30, 2009 4:17 am
hi everyone my name is rich im doing a project with online PHP and SQL, im trying to get data from a database and show it on a on-line database here is my code am i on the right tracks??
<?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/ww ... 1/Hospital Login Success.html');}
// 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/ww ... 1/Hospital Login Denied.html');}
?>
<?php
// this creates a connection to the database
$adCon = new COM ('ADODB.Connection');
// this is the path to the folder holding this PHP script
$sHere = dirname (_FILE_);
//MS Access
//this opens the commection using a standard Access connection string
$adoCon-> Open('Provider=Microsoft.ACE.OLDBE.12.0; Data Source=$sHere/intermed (1).accdb');
$sSQL= 'SELETC * FROM tblProducts WHERE
productReference Like '$SProductSurname'
$sBoolean
productName Like '$sProductName'
productDescription Like '$sProductDescription'
productPrice Like '$sProductPrice'
echo 'Running the SQL command:<br /> $sSQL <br /><br />';
// this will now search the DB
$rsMain = $adoCon->Execute( $sSQL );
//this will now output the selected fields that i have selected from 'tblProducts'
while (!$rsMain->EOF)
{ // gets each of the selected feilds from the DB
$sProductReference = $rsMain->Fields('ProductReference')->value;
$sProductName = $rsMain->Fields('ProductName')->value;
$sProductDescription = $rsMain->Fields('ProductDescription')->value;
$sProductPrice = $rsMain->Fields('ProductPrice')->value;
//prints each of the reccords onto the website, thats has been found from the database
print '$nID: $sProductReference; $sProductName; $sProductDescription; $sProductPrice<br />\n'
//this will move to the next reccord, or if no reccords then the count will run out
$rsMain->MoveNext();
}
// closes the reccord
$rsMain->Close();
$rsMain->Release();
$rsMain = null;
//closes the connection
$adoCon->Close();
$adoCon = null;
?>
</body>
</html>
<?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/ww ... 1/Hospital Login Success.html');}
// 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/ww ... 1/Hospital Login Denied.html');}
?>
<?php
// this creates a connection to the database
$adCon = new COM ('ADODB.Connection');
// this is the path to the folder holding this PHP script
$sHere = dirname (_FILE_);
//MS Access
//this opens the commection using a standard Access connection string
$adoCon-> Open('Provider=Microsoft.ACE.OLDBE.12.0; Data Source=$sHere/intermed (1).accdb');
$sSQL= 'SELETC * FROM tblProducts WHERE
productReference Like '$SProductSurname'
$sBoolean
productName Like '$sProductName'
productDescription Like '$sProductDescription'
productPrice Like '$sProductPrice'
echo 'Running the SQL command:<br /> $sSQL <br /><br />';
// this will now search the DB
$rsMain = $adoCon->Execute( $sSQL );
//this will now output the selected fields that i have selected from 'tblProducts'
while (!$rsMain->EOF)
{ // gets each of the selected feilds from the DB
$sProductReference = $rsMain->Fields('ProductReference')->value;
$sProductName = $rsMain->Fields('ProductName')->value;
$sProductDescription = $rsMain->Fields('ProductDescription')->value;
$sProductPrice = $rsMain->Fields('ProductPrice')->value;
//prints each of the reccords onto the website, thats has been found from the database
print '$nID: $sProductReference; $sProductName; $sProductDescription; $sProductPrice<br />\n'
//this will move to the next reccord, or if no reccords then the count will run out
$rsMain->MoveNext();
}
// closes the reccord
$rsMain->Close();
$rsMain->Release();
$rsMain = null;
//closes the connection
$adoCon->Close();
$adoCon = null;
?>
</body>
</html>