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 » Tue Aug 31, 2004 2:37 pm
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";
}
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 2:45 pm
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 » Tue Aug 31, 2004 2:56 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 2:59 pm
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 » Tue Aug 31, 2004 3:03 pm
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
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 3:06 pm
add more fields into the $changeover array..
Kingo
Forum Contributor
Posts: 146 Joined: Thu Jun 03, 2004 9:38 am
Post
by Kingo » Tue Aug 31, 2004 3:10 pm
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 » Tue Aug 31, 2004 3:12 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 3:14 pm
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 » Tue Aug 31, 2004 3:14 pm
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 3:15 pm
not directly.
Kingo
Forum Contributor
Posts: 146 Joined: Thu Jun 03, 2004 9:38 am
Post
by Kingo » Tue Aug 31, 2004 3:19 pm
I added the submit button. I also added the form tag. But i dont know what to specify in the action?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 3:21 pm
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 » Tue Aug 31, 2004 3:23 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Aug 31, 2004 3:26 pm
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