Page 1 of 1
PHP in Single line TextField
Posted: Tue Aug 22, 2006 4:08 pm
by Leao
Is it possible to have a single line TextField that retrieves text using PHP from a Mysql database? I've managed to do it with a Multi line Textarea but the same code doesn't seem to work with a Single line TextField. It's necessary as the data to be retrieved is short and doesn't need the scroll bar that a Multi line TextField automatically wraps around it.
Thanks again
Leao
Posted: Tue Aug 22, 2006 4:10 pm
by feyd
Why wouldn't it be possible?
Posted: Tue Aug 22, 2006 4:13 pm
by Luke
Code: Select all
<input type="text" name="sometextfield" value="<?php echo $data_from_database; ?>" />
?
Posted: Tue Aug 22, 2006 4:17 pm
by feyd
Remember to do an
htmlentities() on that..

Posted: Tue Aug 22, 2006 4:33 pm
by Leao
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi, I've attached the code I used for the Multi line text area and the code I tried for the Single line TextField that failed. Haven't I done already what you suggested?
thanx
leao
Code: Select all
<form method="post" action="meetthecommunity.php">
<div align="center">
<p>
<textarea name="meetthecommunity" cols="43" rows="14" id="meetthecommunity"><?php
mysql_connect("mysql","username","password") or die(mysql_error());
mysql_select_db("database_text") or die(mysql_error());
$result = mysql_query("SELECT * FROM grid")
or die(mysql_error());
$row = mysql_fetch_array( $result );
echo $row['meetthecommunity'];
?>
</textarea>
</p>
<p>
<input type="submit" value="upload text">
</p>
</div>
</form>
Code: Select all
<form method="post" action="nnameamember1.php">
<div align="center">
<p>
<input name="nnameamember1" type="text" id="nnameamember1" value="<?phpmysql_connect("mysql","username","password") or die(mysql_error());mysql_select_db("database_text") or die(mysql_error()); $result = mysql_query("SELECT * FROM grid")or die(mysql_error()); $row = mysql_fetch_array( $result );echo $row['nnameamember1'];?>" size="20">
</p>
<p>
<input type="submit" value="change nickname">
</p>
</div>
</form>
feyd | Please use Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Posted: Wed Aug 23, 2006 4:28 am
by jito
yes.
need a space here:<?phpmysql_connect, should be
<?php mysql_connect("server","user","pass")...
what u really want to do? updation form?
Posted: Wed Aug 23, 2006 6:09 am
by Leao
Thanks, that works brilliantly. I'm using the form to update my mySQL database. Do you have any tips for making such a form secure?
Thanks again – Leao
Posted: Thu Aug 31, 2006 3:32 am
by jito
use @ instead of using die().