how to get test boxes filled in on load
Moderator: General Moderators
how to get test boxes filled in on load
once again, i come to you guys for help, and i hope u can help again
i have a section in my site where people login to edit their own personal profiles. however, i do not know how to make it so that when that page loads, it automatically reads the database, and fills in the specific columns into form elements.
for example, if their is a shout-out box, i want the editprofile.php to load up and whatever the user saved under te shout-out box will load up with the page inside the testbox
my explanation isnt too good, but you prolly get the idea by now. how do i do it?
i have a section in my site where people login to edit their own personal profiles. however, i do not know how to make it so that when that page loads, it automatically reads the database, and fills in the specific columns into form elements.
for example, if their is a shout-out box, i want the editprofile.php to load up and whatever the user saved under te shout-out box will load up with the page inside the testbox
my explanation isnt too good, but you prolly get the idea by now. how do i do it?
do you know how to load data from the database?
if you do, just use this:
if you do, just use this:
Code: Select all
<?php
$string = "this is what the textbox should contain";
echo "
<textarea name='textbox' cols='30' rows='6'>$string</textarea>
";
?>You can also do:
Code: Select all
<?php
$username = "Info From DB";
echo "<input type="text" name="username" value="$username">";
?>well, i got that all fixed, but now i have a new problem. When people write something, like their favorite quesote for example, in a multiline textbox, it is written to the database as one big strand with no endlines. for example if i wanted to write this:
it would show up as this"My nipples explode with delight!"
-John Cleese
how do i make it so it is written to the database like how it was written?"My nipples explode with delight!" -John Cleese
ok, that fixed that problem, and the profile thing is done. thank you very much
now i have another problem that is unrelated to this toppic, but i didnt want to spam your forums. so here it is: is there a random letter generator in php? for example, i want to create passwords that are completely random. how will i go through doing that.?
also..is there a reverse nl2br function that takes away the <br /> when the string is loaded later?
now i have another problem that is unrelated to this toppic, but i didnt want to spam your forums. so here it is: is there a random letter generator in php? for example, i want to create passwords that are completely random. how will i go through doing that.?
also..is there a reverse nl2br function that takes away the <br /> when the string is loaded later?
Code: Select all
function generatePassword ($length =
// from Jon Haworth
{
// start with a blank password
$password = "";
// define possible characters
$possible = "0123456789bcdfghjkmnpqrstvwxyz";
// set up a counter
$i = 0;
// add random characters to $password until $length is reached
while ($i < $length) {
// pick a random character from the possible ones
$char = substr($possible, mt_rand(0, strlen($possible)-1), 1);
// we don't want this character if it's already in the password
if (!strstr($password, $char)) {
$password .= $char;
$i++;
}
}
// done!
return $password;
}