ShaolinF Posted June 26, 2007 Share Posted June 26, 2007 Hi guys, I want to be able to use php values in my html forms. See below.. I have two php declarations, the first is called username and the value is contains is test. The second declaration is called pword and contains the value 12345. What I want to do is to be-able to use the above two declarations in the following POST form: <form name="form" method="post" action="contact_thanks.php"><p class="bodymd">Your Name<br><input type="text" name="Name"></p><p class="bodymd">Your Email<br><input type="text" name="Email"></p> <input type="submit" name="Submit" value="Submit" /></p></form> The php script and form are on the same page, and rather than the user having to type it out all over again I would rather the fields already be filled in. So if I can get the PHP values into the appropriate form text boxes that will save alot of time. So any ideas ? Thanks Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/ Share on other sites More sharing options...
pocobueno1388 Posted June 26, 2007 Share Posted June 26, 2007 I don't see any fields that contain a username or a password... Here is what you do to fill in the values though... <form name="form" method="post" action="contact_thanks.php"> <p class="bodymd"> Your Name<br><input type="text" name="Name" value="<?php echo USERNAME; ?>"></p> <p class="bodymd"> Your Email<br><input type="text" name="Email" value="<?php echo PWORD; ?>"></p> <input type="submit" name="Submit" value="Submit" /></p> </form> Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/#findComment-283256 Share on other sites More sharing options...
aim25 Posted June 26, 2007 Share Posted June 26, 2007 Umm... not really sure what ur asking but i think ur trying to but variables into the text field, so if you want to do that just put <?php echo $(your variable); ?> in the value. <form name="form" method="post" action="contact_thanks.php"> <p class="bodymd">Your Name<br><input type="text" name="Name" value="<?php echo $(your variable); ?>"></p><p class="bodymd">Your Email<br><input type="text" name="Email" value="<?php echo $(your variable); ?>"></p> <input type="submit" name="Submit" value="Submit" /></p></form> Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/#findComment-283258 Share on other sites More sharing options...
ShaolinF Posted June 26, 2007 Author Share Posted June 26, 2007 Thanks. Thats what I was looking for. I have another question. How can I POST the form without the user needing to press the continue button ? Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/#findComment-283371 Share on other sites More sharing options...
pocobueno1388 Posted June 26, 2007 Share Posted June 26, 2007 You mean you don't want to have a submit button? If thats the case, then you will be working with JavaScript. If you only have text fields it may be difficult. Explain a bit more on how exactly you want it to happen. Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/#findComment-283393 Share on other sites More sharing options...
cooldude832 Posted June 26, 2007 Share Posted June 26, 2007 you can always submit the form to the same page and then the users seems to see nothing Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/#findComment-283398 Share on other sites More sharing options...
bbaker Posted June 26, 2007 Share Posted June 26, 2007 why use a form if you don't want the user to click a button or enter any information? Link to comment https://forums.phpfreaks.com/topic/57300-integrate-php-into-html-form/#findComment-283401 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.