•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,273 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,284 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 479 | Replies: 5
![]() |
•
•
Join Date: Jul 2007
Posts: 20
Reputation:
Rep Power: 2
Solved Threads: 0
<head>
<?php
$db=mysql_connect("localhost","root","") or die ('Connection error'. mysql_error());
echo "ajay<br/>";
mysql_select_db("chat") or die ('Error connecting to database'. mysql_error());
echo "connected to database";
$fr_username=$_POST["txt_username"];
$fr_password=$_POST["txt_password"];
$result = mysql_query("SELECT username,password FROM login WHERE username='$fr_username' AND password='$fr_password' ");
while($row = mysql_fetch_assoc($result))
{
if($result!="")
{
echo "good";
}
else
{
if ($result="")
{
echo "bad";
}
}
}
mysql_close($db);
$date = date("a");
if ($date=="am")
{
$title="Good Morning";
}
else
{
$title="Good Afternoon";
}
?>
</head>
<title>met-ene-dialogue</title>
<?php echo $title ?>
<style type="text/css">
<!--
body {
background-image: url();
}
.style1 {color: #C13167}
.style2 {font-size: large}
-->
</style></head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<th width="16%" bgcolor="#FFFFFF" scope="col"><img src="images/queascopf4.gif" width="124" height="145"/></th>
<th width="77%" bgcolor="#FFCCFF" scope="col"><p class="style1">WELCOME</p>
<p class="style1">TO </p>
<p class="style1">METE-ENE-DIALOGUE DOT COM </p></th>
<th width="7%" background="Drag to a file to choose it." bgcolor="#FFFFFF" scope="col"><img src="images/queascopf4.gif" width="124" height="145" /></th>
</tr>
<tr>
<td colspan="3" bgcolor="#FFFFFF"><table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<th width="50%" bordercolor="#330033" scope="col" border = "5">MEMBERS LOGIN </th>
<th width="50%" bordercolor="#330033" scope="col">NEW USER? SIGN IN </th>
</tr>
<tr>
<td height="139">
<form action = "<?php $page?>" method ="post">
<p>Username:
<input type = "text" name = "txt_username"/>
</p>
<p>Password:
<input type = "password" name = "txt_password"/>
</p>
<p>
<input name="Submit" type = "submit" value="Submit"/>
</p>
</form></td>
<td height="139" align="center" valign="middle"><span class="style2">Sign in as new user </span></td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>hi! i need help! i created a code and sql db for store usere name and password, but i only doest the $result wen if found the username and password. help plz and also i want to open anothe page wen the username and password is ok! i used header, but it sent erorr that "cant modify header, already sent" plz help
•
•
Join Date: Jul 2007
Location: Sofia, Bulgaria
Posts: 138
Reputation:
Rep Power: 2
Solved Threads: 10
•
•
•
•
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include(), or require(), functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file.
header()
PS : Why do you put your code in HEAD ?
- Mitko Kostov
Last edited by MitkOK : Aug 20th, 2007 at 4:23 am.
•
•
Join Date: Jul 2007
Location: Sofia, Bulgaria
Posts: 138
Reputation:
Rep Power: 2
Solved Threads: 10
If you want to use header() you must write it before any html code.
php Syntax (Toggle Plain Text)
<?php // check if submit button is clicked if (isset($_POST['submit'])) { $db=mysql_connect("localhost","root","") or die ('Connection error'. mysql_error()); echo "ajay<br/>"; mysql_select_db("chat") or die ('Error connecting to database'. mysql_error()); echo "connected to database"; $fr_username=$_POST["txt_username"]; $fr_password=$_POST["txt_password"]; $result = mysql_query("SELECT username,password FROM login WHERE username='$fr_username' AND password='$fr_password' "); while($row = mysql_fetch_assoc($result)) { if($result!="") { header("Location: page1.php"); } else { if ($result="") { echo "bad"; } } } mysql_close($db); } $date = date("a"); if ($date=="am") { $title="Good Morning"; } else { $title="Good Afternoon"; } ?> </head> <title>met-ene-dialogue</title> <?php echo $title ?> <style type="text/css"> <!-- body { background-image: url(); } .style1 {color: #C13167} .style2 {font-size: large} --> </style></head> <body> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <th width="16%" bgcolor="#FFFFFF" scope="col"><img src="images/queascopf4.gif" width="124" height="145"/></th> <th width="77%" bgcolor="#FFCCFF" scope="col"><p class="style1">WELCOME</p> <p class="style1">TO </p> <p class="style1">METE-ENE-DIALOGUE DOT COM </p></th> <th width="7%" background="Drag to a file to choose it." bgcolor="#FFFFFF" scope="col"><img src="images/queascopf4.gif" width="124" height="145" /></th> </tr> <tr> <td colspan="3" bgcolor="#FFFFFF"><table width="100%" border="1" cellspacing="0" cellpadding="0"> <tr> <th width="50%" bordercolor="#330033" scope="col" border = "5">MEMBERS LOGIN </th> <th width="50%" bordercolor="#330033" scope="col">NEW USER? SIGN IN </th> </tr> <tr> <td height="139"> <form action = "<?php $page?>" method ="post"> <p>Username: <input type = "text" name = "txt_username"/> </p> <p>Password: <input type = "password" name = "txt_password"/> </p> <p> <input name="Submit" type = "submit" value="Submit"/> </p> </form></td> <td height="139" align="center" valign="middle"><span class="style2">Sign in as new user </span></td> </tr> </table></td> </tr> </table> </body> </html>
•
•
Join Date: Jul 2007
Posts: 20
Reputation:
Rep Power: 2
Solved Threads: 0
ok, y did u resend me the code? i used a javascript for that and its working fine! but the problem is that, it doeasnt do wen the username and password is not found! i mean the else part, y?
<script language="javascript">
top.location.replace("./a.php");
</script>•
•
Join Date: Jul 2007
Location: Sofia, Bulgaria
Posts: 138
Reputation:
Rep Power: 2
Solved Threads: 10
I don't understand you.
So, if the username and password are found
in DB the page redirects. What do you want
to do if it's incorrect ?
Hint: You can put $_SERVER['PHP_SELF'] in form action url to reload login page
until username and password are correct.
- Mitko Kostov
So, if the username and password are found
in DB the page redirects. What do you want
to do if it's incorrect ?
Hint: You can put $_SERVER['PHP_SELF'] in form action url to reload login page
until username and password are correct.
- Mitko Kostov
Last edited by MitkOK : Aug 20th, 2007 at 7:22 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- HELP!! Monitor Shows NO SIGNAL after windows loading / before login page (Windows NT / 2000 / XP / 2003)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Making a page read-only
- Next Thread: tips & tricks of web development


Linear Mode