Form input field advice needed - Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more
Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Webmaster Tech > Programming > PHP Development

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-08-2011, 04:21 PM   #1 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 11
Default Form input field advice needed

Hi,

I am new to these forums and to php itself. I have recently started working on a php based website and stumbled on the following issue. This is most likely something very simple, however I am struggling to explain what is wrong in google search to get to the right solution.

The following code works fine except for 1 problem.

variables $row['t1name'] and row['t2name'] contain 3 words each. However the value of the field is assigned as the first word only. Nothing after 1st space is included.

Any help would be really appreciated.

Many Thanks
bodis

Code:
<?php
while ($row = mysql_fetch_array($result)) {
  echo "<form action='login.php' method='POST'>";
  echo "<tr>";
  echo "<td align='center' valign='middle'><input type='text' name='gameid' value=" . $row['g_id'] . " readonly size='15'></td>";
  echo "<td align='center' valign='middle'><input type='text' name='gameid' value=" . $row['t1name'] . " readonly size='15'></td>";
  echo "<td align='center' valign='middle'><input type='text' name='gameid' value=" . $row['t2name'] . " readonly size='15'></td>";
  echo "<td align='center' valign='middle'><input type ='submit' value ='Confirm game'></td>";
  echo "</form>";
  echo "</tr>";
}
?>
bodis is offline   Reply With Quote
Sponsored Links
Old 04-08-2011, 05:26 PM   #2 (permalink)
Junior Member
 
Join Date: Apr 2011
Location: Los Angeles, California
Posts: 44
Default Re: Form input field advice needed

Could you do a

Code:
echo "<pre>";
print_r($row);
echo "</pre>";
and copy and paste for us to see the data contained within the array?
websonalized is offline   Reply With Quote
Old 04-08-2011, 07:32 PM   #3 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 11
Default Re: Form input field advice needed

Thanks for looking into this.

Thats what I get:

Code:
Array
(
    [0] => 1
    [g_id] => 1
    [1] => 2011-03-22
    [date] => 2011-03-22
    [2] => 1
    [team1] => 1
    [3] => John Hanson A
    [t1name] => John Hanson A
    [4] => 9
    [t1pnts] => 9
    [5] => 2
    [team2] => 2
    [6] => JohnHanson B
    [t2name] => JohnHanson B
    [7] => 1
    [t2pnts] => 1
    [8] => 1
    [p1] => 1
    [9] => 3
    [p1p] => 3
    [10] => 3
    [p1w] => 3
    [11] => 2
    [p2] => 2
    [12] => 3
    [p2p] => 3
    [13] => 3
    [p2w] => 3
    [14] => 3
    [p3] => 3
    [15] => 3
    [p3p] => 3
    [16] => 3
    [p3w] => 3
    [17] => 6
    [p4] => 6
    [18] => 3
    [p4p] => 3
    [19] => 0
    [p4w] => 0
    [20] => 7
    [p5] => 7
    [21] => 3
    [p5p] => 3
    [22] => 0
    [p5w] => 0
    [23] => 8
    [p6] => 8
    [24] => 3
    [p6p] => 3
    [25] => 0
    [p6w] => 0
    [26] => 50
    [confirmed] => 50
)
Thanks
bodis is offline   Reply With Quote
Old 04-08-2011, 08:52 PM   #4 (permalink)
Junior Member
 
Join Date: Apr 2011
Location: Los Angeles, California
Posts: 44
Default Re: Form input field advice needed

in the form code, you are missing the quotes around the value attributes of each field, and it is recommended that you add htmlentities to prevent malicious code. See below:

<?php
while ($row = mysql_fetch_array($result)) {
echo "<form action='login.php' method='POST'>";
echo "<tr>";
echo "<td align='center' valign='middle'><input type='text' name='gameid' value='" . htmlentities($row['g_id']) . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='gameid' value='" . htmlentities($row['t1name']) . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='gameid' value='" . htmlentities($row['t2name']) . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type ='submit' value ='Confirm game'></td>";
echo "</form>";
echo "</tr>";
}
?>
websonalized is offline   Reply With Quote
Old 04-09-2011, 03:33 AM   #5 (permalink)
Junior Member
 
Join Date: Apr 2011
Posts: 11
Default Re: Form input field advice needed

Thats done the trick

Thank you very much
bodis is offline   Reply With Quote
Old 05-16-2012, 11:42 PM   #6 (permalink)
Regular User
 
Join Date: May 2012
Location: usa
Posts: 18
Smile Re: Form input field advice needed

<?php
while ($row = mysql_fetch_array($result)) {
echo "<form action='login.php' method='POST'>";
echo "<tr>";
echo "<td align='center' valign='middle'><input type='text' name='gameid' value='" . $row['g_id'] . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='gameid' value='" . $row['t1name'] . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type='text' name='gameid' value='" . $row['t2name'] . "' readonly size='15'></td>";
echo "<td align='center' valign='middle'><input type ='submit' value ='Confirm game'></td>";
echo "</form>";
echo "</tr>";
}
?>

htmlentities() function is not necessary . Your only replace value=" . $row['t1name'] . " to value='" . $row['t1name'] . "' .
__________________
a games
y8games2012 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Sponsors

» Links

» Affiliates
Web Hosting
Online Backup Reviews
Marketing Find
Merchant Select
SiteMap Builder
Host Compare

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 04:39 PM.


Powered by vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2
Webmaster Forums
Web Hosting | Chicago Web Hosting | Web Hosting