Not recognising my textbox

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Not recognising my textbox

Post 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>
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Not recognising my textbox

Post by requinix »

Where's the <form>? Are you sure this is the exact code running?
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Not recognising my textbox

Post by Goofan »

ahh right forgot the forms
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Not recognising my textbox

Post 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?
xplosion
Forum Newbie
Posts: 4
Joined: Sat May 22, 2010 6:34 pm

Re: Not recognising my textbox

Post by xplosion »

Login button? Surely you need the form action file too?
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: Not recognising my textbox

Post by Jonah Bron »

You forgot the isset() function.

Code: Select all

if(isset($_POST["Login"])){
User avatar
Goofan
Forum Contributor
Posts: 305
Joined: Wed Nov 04, 2009 2:11 pm
Location: Sweden

Re: Not recognising my textbox

Post by Goofan »

Thank you very much Jonah Bron I think that will do it =) To basic to be recognised =)
Post Reply