-
[PHP] Echo in an echo?
PHP Code:
echo "<form action=\"?do=update\" method=\"post\">
first name: <input type=\"text\" name=\"firstname\" value=\"\" /><br />
last name: <input type=\"text\" name=\"lastname\" /><br />
nick name: <input type=\"text\" name=\"nickname\" /><br />
location: <input type=\"text\" name=\"location\" /><br />
email: <input type=\"text\" name=\"email\" /><br />
gender: <input type=\"checkbox\" name=\"male\" /> male <input type=\"checkbox\" name=\"female\" /> female<br />
bio: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"bio\" /><br />
fav movies: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"favmovies\" /><br />
fav music: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"favmusic\" /><br />
fav books: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"favbooks\" /><br />
<input type=\"submit\" value=\"update profile\" />
</form><br />
<br />
want to change your password?
<form action=\"?do=updatepw\" method=\"post\">
current password: <input type=\"password\" name=\"currentpassword\" /><br />
new password: <input type=\"password\" name=\"newpassword\" /><br />
<input type=\"submit\" value=\"update password\" />
</form>";
On the text inputs I want to add a value with an echo inside it, how would I do that? +rep
-
What do you mean? As in, in the boxes you get the data from the database and put that as the values?
If you meant that try this:
PHP Code:
$profile = mysql_query("SELECT * from users where username = '$logged[username]'");
$profile = mysql_fetch_array($profile);
echo "<form action=\"?do=update\" method=\"post\">
first name: <input type=\"text\" name=\"firstname\" value=\"$user[name]\" /><br />
last name: <input type=\"text\" name=\"lastname\" value=\"$user[lastname] /><br />
nick name: <input type=\"text\" name=\"nickname\" value=\"$user[nickname] /><br />
location: <input type=\"text\" name=\"location\" value=\"$user[location] /><br />
email: <input type=\"text\" name=\"email\" value=\"$user[email] /><br />
gender: <input type=\"checkbox\" name=\"male\" /> male <input type=\"checkbox\" name=\"female\" /> female<br />
bio: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"bio\" value=\"$user[bio] /><br />
fav movies: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"favmovies\" value=\"$user[favmovies] /><br />
fav music: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"favmusic\" value=\"$user[favmusic] /><br />
fav books: <input type=\"text\" height=\"200px\" width=\"300px\" name=\"favbooks\" value=\"$user[favbooks] /><br />
<input type=\"submit\" value=\"update profile\" />
</form><br />
<br />
want to change your password?
<form action=\"?do=updatepw\" method=\"post\">
current password: <input type=\"password\" name=\"currentpassword\" /><br />
new password: <input type=\"password\" name=\"newpassword\" /><br />
<input type=\"submit\" value=\"update password\" />
</form>";
-
I'm not 100% sure what you mean, but couldn't you just put the text that you want to display into a variable, then add the variable into value?
i.e.
Code:
<input type='text' value='$textHere' />
-
Trinity: I tried that, gives me an error.
-
-
You both suggested the same thing.
-
well what do you mean by 'add an echo inside it'?
-
Exactly what you thought I meant, just what you gave me errored.
-
okay.
It errored because i did it wrong ;)
PHP Code:
$profile = mysql_query("SELECT * from users where username = '$logged[username]'");
$user = mysql_fetch_array($profile);
try that instead of the:
PHP Code:
$profile = mysql_query("SELECT * from users where username = '$logged[username]'");
$profile = mysql_fetch_array($profile);
-
No, not the mysql codes, the code inside the form.