Page 2 of 3
Posted: Tue Aug 31, 2004 2:37 pm
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";
}
Posted: Tue Aug 31, 2004 2:45 pm
by feyd
that just generates blank inputs (provided the actual syntax is correct)
example ONLYCode: 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 />';
}
}
?>
Posted: Tue Aug 31, 2004 2:56 pm
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
Posted: Tue Aug 31, 2004 2:59 pm
by feyd
did you try adding that code into your if statement's true block?
Posted: Tue Aug 31, 2004 3:03 pm
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
Posted: Tue Aug 31, 2004 3:06 pm
by feyd
add more fields into the $changeover array..
Posted: Tue Aug 31, 2004 3:10 pm
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.
Posted: Tue Aug 31, 2004 3:12 pm
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.
Posted: Tue Aug 31, 2004 3:14 pm
by feyd
just echo a standard html form submit button.
there are hundreds of examples here, on the net, everywhere.
Posted: Tue Aug 31, 2004 3:14 pm
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?
Posted: Tue Aug 31, 2004 3:15 pm
by feyd
not directly.
Posted: Tue Aug 31, 2004 3:19 pm
by Kingo
I added the submit button. I also added the form tag. But i dont know what to specify in the action?
Posted: Tue Aug 31, 2004 3:21 pm
by feyd
if you specify nothing, it'll generally get sent to the current page. However, explicitly specifying it, is always a good idea.
Posted: Tue Aug 31, 2004 3:23 pm
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.
Posted: Tue Aug 31, 2004 3:26 pm
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