Page 1 of 1
logical mistake
Posted: Wed Aug 19, 2009 12:23 am
by yasir_memon
i am using this code it only show else condition message wether i am writing right user name and password so kindly help me in this regard if any one knows
thanks
<?php
$A=$_POST["text1"];
$B=$_POST["text2"];
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST');
$sql="SELECT * FROM USERS WHERE USR_NAME='$A' and PASSWORD='$B'";
$rs=odbc_exec($conn,$sql);
$count=odbc_num_rows($rs);
if (!$rs)
{
exit("Error in SQL");
}
if($count>0)
{
echo "good";
}
else
{
echo "invalid user";
}
odbc_close($conn);
?>
Re: logical mistake
Posted: Wed Aug 19, 2009 12:59 am
by bala_1225
hi plz try this one....
$A=$_POST['text1'];
$B=$_POST['text2'];
Re: logical mistake
Posted: Wed Aug 19, 2009 1:04 am
by yasir_memon
still same error kindly check this code atur side is it working properly there is no any connection error when i am runing selece statment it displys all the records i think there is any logical mistake so kindly check this waiting for replies.
Re: logical mistake
Posted: Wed Aug 19, 2009 2:47 am
by yasir_memon
this code is working properly but it is not redirecting to other page it shows the warning message
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\RMS\login.php:8) in C:\wamp\www\RMS\login.php on line 105
if i replace header with echo it give me right output so kindlt tell me now why it is not redirecting to other page
<?php
$A=$_POST["text1"];
$B=$_POST["text2"];
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST');
$sql="SELECT 1 A FROM USERS WHERE USR_NAME='$A' and PASSWORD='$B'";
$rs=odbc_exec($conn,$sql);
$count = odbc_result($rs,"A");
if($count>0)
{
header("Location:log.html");
}
else
{
echo "invalid user name or password";
}
odbc_close($conn);
?>
Re: logical mistake
Posted: Wed Aug 19, 2009 8:43 am
by jackpf
What's the entire script?
Re: logical mistake
Posted: Wed Aug 19, 2009 9:17 am
by Ollie Saunders
Change:
Code: Select all
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST');
to:
Code: Select all
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST') or die('Failed to connect to database. Reason: ' . odbc_errormsg());
to better understand if a connection is being created successfully.
Re: logical mistake
Posted: Wed Aug 19, 2009 9:29 am
by Ollie Saunders