For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > December 2004 > Re: [PHP-DB] help newbies :)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PHP-DB] help newbies :)
Jochem Maas

2004-12-24, 3:55 pm

Nayyar Ahmed wrote:
> Hello All,
>
> I am developing attendence mangement system, its my first application
> in PHP, I want to compaire the input text box value with table records
> the follwing is the code
>
>
> _____________index.htm_______________
> ..........
> <form name = 'loginfrm' method = post action = "index.php" >
>
> <pre> </td>
>
> </tr>
>
> <tr>
>
> <td width="100%" height="115"><html>
>
>
>
>
> <body>
>
>
>
>
> <div style="mso-border-alt: solid #AAAAFF .75pt; width: 675; height:
> 234; border: 1.0pt solid #AAAAFF; padding: 6.0pt; background:
> #EEEEFF">
>
> <table border="0" cellpadding="0" cellspacing="0"
> style="border-collapse: collapse" bordercolor="#111111" width="100%"
> id="AutoNumber2">
>
> <tr>
>
> <td width="25%"><font size="4">User Name:</font></td>
>
> <td width="25%">
>
>
>
> <p><input name = "uname" type = "text" size="20"></p>
>
> </td>
>
> <td width="25%"><font size="4">     Class:</font></td>
>
> <td width="25%"> <select name= "class">
>
> <option value = "BBA"> BBA</option>
>
> <option value = "BBA-IT"> BBA-IT</option>
>
> <option value = "BCS"> BCS</option>
>
> <option value = "B.Sc"> B.Sc</option>
>
> <option value = "MBA"> MBA</option>
>
> <option value = "MBA-IT"> MBA-IT</option>
>
> <option value = "MS-IT"> MS-IT</option>
>
> <option value = "MS-CS"> MS-CS</option>
>
> <option value = "Admin"> Admin</option>
>
> </select> </td>
>
>
>
> <td width="25%"><font size="4">Password:</font></td>
>
> <td width="25%"><input name ="passwd" type = "password" size="20"> </td>
>
> etc. etc. .......
> ________________________________________
_____________
>
> _________index.php_____________
>
> <?php
>
> $db= mysql_connect("localhost","root","masood");
> mysql_select_db("attendence",$db);
>
> $result= mysql_query("select uname,upasswd from user",$db);
> while ($myrow = mysql_fetch_array($result))
> {
> if(($uname == $myrow["uname"]) && ($upasswd == $myrow["uname"]));


firstly the preceeding line should probably be:

if(($uname == $myrow["uname"]) && ($upasswd == $myrow["upasswd"]));

> {
> echo $myrow["uname"];
> echo $myrow["upasswd"];
> }
> }
> ?>
> </body>
> </html>
>
> this give me error no 13, with uname,upasswd undefined, please help me out,
> TIA


get familiar with the var_dump() and print_r() functions. for instance
what does the following output:

$result= mysql_query("select * from user",$db);
while ($myrow = mysql_fetch_array($result)) {
print_r( $myrow );
}

are the indexes 'uname' and 'upasswd' defined in each dumped array?

>
>
>

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com