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);
?>
logical mistake
Moderator: General Moderators
Re: logical mistake
hi plz try this one....
$A=$_POST['text1'];
$B=$_POST['text2'];
$A=$_POST['text1'];
$B=$_POST['text2'];
-
yasir_memon
- Forum Commoner
- Posts: 48
- Joined: Tue Aug 11, 2009 12:29 am
Re: logical mistake
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.
-
yasir_memon
- Forum Commoner
- Posts: 48
- Joined: Tue Aug 11, 2009 12:29 am
Re: logical mistake
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);
?>
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
What's the entire script?
- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK
Re: logical mistake
Change:to better understand if a connection is being created successfully.
to:Code: Select all
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST');
Code: Select all
$conn=odbc_connect('AKTMAPP','ERP_TEST','ERP_TEST') or die('Failed to connect to database. Reason: ' . odbc_errormsg());- Ollie Saunders
- DevNet Master
- Posts: 3179
- Joined: Tue May 24, 2005 6:01 pm
- Location: UK