Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
whats wrong with this code
Old 09-26-2008, 02:37 AM whats wrong with this code
Novice Talker

Posts: 4
Name: dhakalall chhetri
Trades: 0
i want to move to next page if login name and password is correct with this code:


<html>
<head>
<form method='post' action='login.php'>
<input type='text' name='login' size='12'>
<input type='password' name='password' size='12'>
<input type='submit' value='go'>
</form>
</head>
</html>
<?
$user="root";
$host="localhost";
$password="";
$database="class_8";
$connection=mysql_connect($host,$user,$password);
$db=mysql_select_db($database,$connection) or die( "Unable to select database");
$sql = "select login_name from login where login_name='$_POST[login]'";
$result=mysql_query($sql) or die ("couldnot excute query");
$num=mysql_num_rows($result);
if($num==1)
{
$sql2="(SELECT login_name FROM login WHERE login_name='$_POST[login]' AND password ='$_POST[password]')";
$result2=mysql_query($sql2) or die ("couldnot excute query1");
$num2=mysql_num_rows($result2);
}
if ($num2>0)
{
echo header("location:result.php");
}
elseif($num==0)
{
echo "username doesnot exist,plz try again";
}
else
{
echo "The login name, '$_POST(login)' exist, but you have entered incorrect password";
}
mysql_close();
?>

but what i see is:
Warning: Cannot modify header information - headers already sent by (output started at C:\Program Files\xampp\htdocs\login.php:10) in C:\Program Files\xampp\htdocs\login.php on line 28

need help correcting this code plz
hotstar07 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-26-2008, 03:47 AM Re: whats wrong with this code
mtishetsky's Avatar
King Spam Talker

Posts: 1,226
Name: Mike
Location: Mataro, Spain
Trades: 0
RTFM output buffering or move your html lower than header() call.
__________________

Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE
-
Please login or register to view this content. Registration is FREE

And don't forget to give me talkupation!
mtishetsky is offline
Reply With Quote
View Public Profile Visit mtishetsky's homepage!
 
Old 09-26-2008, 08:48 AM Re: whats wrong with this code
Super Spam Talker

Latest Blog Post:
PSD Squirrel Launched
Posts: 933
Trades: 7
hi hotstar,

to build on what mtishetsky said...

In PHP you cannot change the header once you have printed output to the screen.. so you need your PHP code to go before your html code... as soon as html is printed the page has a header type.. then you go and try and change header location it doesnt work.

cheers,
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Sir P is offline
Reply With Quote
View Public Profile Visit Sir P's homepage!
 
Reply     « Reply to whats wrong with this code
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.44206 seconds with 12 queries