Page 1 of 1

Not recognising my textbox

Posted: Fri May 21, 2010 10:54 am
by Goofan
Hi!
I get this error:
Notice: Undefined index: user in C:\wamp\www\Banner\Login.php on line 40

Line 40:
if($_POST["Login"]){

same if i remove that line to check the rest then noone of the "$_POST" is responding!

Shouldnt this work? what hae i done wrong? please tell me

Code: Select all

<?php session_start() ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 <!--Includes, session starts, create Database connection-->
 <?php
 	require_once('database/OOP.Database.Login.php'); 
	$db = new database() 
 ?>
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Banner - Login</title>
	<link href="Style.css" rel="stylesheet" type="text/css">
 </head>
 <body>
 <!-- PHP Section -->
     <table width="100%" height="100%" cellspacing="1">
     	  <td height="25px" colspan="3"></td>
         <tr>
         </tr>
         <tr>
             <td width="14%" height="100%" valign="top">
             	<!--Left Empty Side-->
             </td>
             <td width="71%">
                <table width="100%" height="100%" cellspacing="1">
                    <tr>
                        <td class="TdColor" colspan="2" height="130px" valign="top">
                        <!--Top Picture-->
                        </td>
                    </tr>
                    <tr cellspacing='0'>
                        <td class="TdColor" width="18%" height="513px" valign="top">
                			  <!--Label Picture-->
                			  <!--Menu-->
                              	<?php 
								$mysql = "SELECT username, password FROM account_info";
							 	$result = $db->dbquery($mysql);
								
							  	while($array = $db->fetchArray($result)){
									if($_POST["Login"]){
										if (($_POST['user']== $array['username']) && ($_POST['pass']== $array['pass'])){
											echo "What the <span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>";
											//$_SESSION["inloggning"] = true; 
											//$_SESSION["user_id"] = $array['saved_id'];
											//$_SESSION["användare"] = $array['user'];
											//header('Refresh: 0; url=home.php?Action=Home');//Skickas till angiven sida.
											//exit;//Lämnar loop.
										}		
									}
								}
							  	?>
                                <center><b>Banner - Online</b></center>
                           	<p>
                                Username:
                                <input type="text" name="user"/>
                                Pass:
                                <input type="password" name="pass"/>
                                <input name="Login" type="submit" value="Login" />
               			  	</p>
                          </td>
                        <td class="TdColor" valign="top"> 
     						<!--Main-->
                        </td>
                    </tr>
                </table>
            </td>
            <td width="15%" valign="top">
        		<!--Right Empty Side-->
            </td>
         </tr>
         <tr>
         </tr>
 	</table>
 </body>
 </html>

Re: Not recognising my textbox

Posted: Fri May 21, 2010 12:02 pm
by requinix
Where's the <form>? Are you sure this is the exact code running?

Re: Not recognising my textbox

Posted: Fri May 21, 2010 1:32 pm
by Goofan
ahh right forgot the forms

Re: Not recognising my textbox

Posted: Sat May 22, 2010 3:45 pm
by Goofan
Ok so i added forms like this:

Code: Select all

<form action="" method="post" ENCTYPE="multipart/form-data">
 Username:
 <input type="text" name="user">
 Password:
 <input type="password" name="pass">
 <input name="Login" type="submit" value="Login">
</form>
Still got the same error as before got any idé of why this is?

Re: Not recognising my textbox

Posted: Sat May 22, 2010 7:26 pm
by xplosion
Login button? Surely you need the form action file too?

Re: Not recognising my textbox

Posted: Sun May 23, 2010 9:04 pm
by Jonah Bron
You forgot the isset() function.

Code: Select all

if(isset($_POST["Login"])){

Re: Not recognising my textbox

Posted: Mon May 24, 2010 2:52 pm
by Goofan
Thank you very much Jonah Bron I think that will do it =) To basic to be recognised =)