Login Authentication

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

Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

can you give me a sample code?

I used the following . But it is not working.

Code: Select all

if($worked)
   {
   //echo "Welcome $username!";  
   echo "<form name="form1" method="post" action="$_SERVER['PHP_SELF']" > ";
   echo " <input type="\text" name="\cvalue1"><br><br> ";
   echo " <input type="\text" name="\cvalue2"><br><br> ";
   echo "<input type="\submit" name="\btnsubmit" value="\Go"> ";
   echo "<br> </form> ";
   }

   else
   {
   echo "The Username and Password donot match";
   }
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that just generates blank inputs (provided the actual syntax is correct)
example ONLY

Code: Select all

<?php

$changeover = array(
'Uname' => array('text'=>'Username:','element'=>'username','type'=>'text'),
);

foreach($changeover as $key => $val)
{
  if(isset($worked[$key]))
  {
    echo $val['text'] . '<input type="' . $val['type'] . '" name="' . $val['element'] . '" value="' . $worked[$key] . '" /><br />';
  }
}

?>
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Gosh, It looks very complex for me. I'm not able to understand your code.
I just want to get the following functionality.

I want to retrive a row from the database based on the user name and password and display the values in the FORM from the database.

I know that i'm bugging you. I'm really sorry for that. But any help is really really appreciated.

Thanx
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

did you try adding that code into your if statement's true block?
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Its working if I add that code. But actually i did not understand the code. I'm getting the username in the text box. BUt i actually want other fields. I went for a form because, If i change some values in the boxes these changes should be reflected in the database. Hope you understand my problem
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

add more fields into the $changeover array..
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

I added thsi way ...but it is not working.

Code: Select all

$changeover = array( 
'Uname' => array('text'=>'Username:','element'=>'username','type'=>'text'), 
'Cvalue1' => array('text'=>'Cvalue1','element'=>'Cvalue1','type'=>'text'), 

);
Cvalue1 is the name of the field in the table.
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Sorry, i typed the field name wrongly. It is working....
Thanx very much.....Last part of my question.

I want to have a Submit button at the bottom....so that if i change any values in the text boxes these changes should be reflected in the database and displayed on the screen.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

just echo a standard html form submit button.

there are hundreds of examples here, on the net, everywhere.
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

Is there no way where i can embed the HTML form tag in the PHP code and link the text boxes to the fileds in the database?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

not directly.
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

I added the submit button. I also added the form tag. But i dont know what to specify in the action?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

if you specify nothing, it'll generally get sent to the current page. However, explicitly specifying it, is always a good idea.
Kingo
Forum Contributor
Posts: 146
Joined: Thu Jun 03, 2004 9:38 am

Post by Kingo »

I only want to change the values in some fileds and I donot want to allow modifying some fileds. Is there a way this can be achieved.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yep.. don't allow modification of those fields. Basically.. create an accepted_fields list on your processing page. Those are the only fields you will allow modification to. Of course, you'll need to make sure the values sent for each are valid and whatnot. There are many threads here talking about these sorts of things.

viewtopic.php?t=25418&highlight=accept%2A
Post Reply