Support Forums
Basic form question. - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Basic form question. (/showthread.php?tid=16616)



Basic form question. - Frank Yates - 03-06-2011

So this I got a basic login form on my index.php, and normally you would see two input boxes right ? Now, my question is how do I put a text in the input boxes when the page loads up. I tried echoing but it didn't work for me or I might did it wrong.

PHP Code:
<form action='index2.php' method='POST'>
<
input type='text' name='username'></br>
<
input type='password' name='password'></br>
<
input type='submit' value='Submit'></br>
</
form

Here is an example I made how I wanted it to show up.
[Image: vy84k0.png]

Thanks.


RE: Basic form question. - Gaijin - 03-06-2011

PHP Code:
<input type="text" name="username" value="User" />
// or within php
echo "<input type=\"text\" name=\"username\" value=\"{$some_var}\" />"

The attribute value defines what will be in there.




RE: Basic form question. - Frank Yates - 03-06-2011

(03-06-2011, 11:47 AM)Gaijin Wrote:
PHP Code:
<input type="text" name="username" value="User" />
// or within php
echo "<input type=\"text\" name=\"username\" value=\"{$some_var}\" />"

The attribute value defines what will be in there.

Oh thanks, that worked. I did that before and it didn't work, but now it does. Oh well, silly me.