physaux Posted October 15, 2009 Share Posted October 15, 2009 Ok so, let me explain what the problem is. Its easier if i just show you the code: <?php $initialvalue= "bob smith"; //Several lines later... echo '<form action="" method="post">'; echo " YourName: <input type='text' name='newname' value=".$initialvalue." /><br>"; echo '<input type="submit" name="submit" value="Proceed" /></form>'; ?> When i run this code, only bob comes out, and not bob smith, in the text box as the default value Anyone see a problem ? How can i make this work? THanks!! Link to comment https://forums.phpfreaks.com/topic/177808-solved-creating-a-form-with-php-putting-variable-for-initial-value-with-spacehow/ Share on other sites More sharing options...
cags Posted October 15, 2009 Share Posted October 15, 2009 You need to put delimeters around the value just like you have the name and type attributes... echo " YourName: <input type='text' name='newname' value='".$initialvalue."' /><br>"; Link to comment https://forums.phpfreaks.com/topic/177808-solved-creating-a-form-with-php-putting-variable-for-initial-value-with-spacehow/#findComment-937547 Share on other sites More sharing options...
mrMarcus Posted October 15, 2009 Share Posted October 15, 2009 and just to point something else out quick, stay consistent with your quotes, ie. first line you used single-quotes, second line double-quotes, then back to single-quotes .. will cause yourself some serious headaches. that is all. Link to comment https://forums.phpfreaks.com/topic/177808-solved-creating-a-form-with-php-putting-variable-for-initial-value-with-spacehow/#findComment-937579 Share on other sites More sharing options...
physaux Posted October 15, 2009 Author Share Posted October 15, 2009 cool thanks for the fix and advice! Link to comment https://forums.phpfreaks.com/topic/177808-solved-creating-a-form-with-php-putting-variable-for-initial-value-with-spacehow/#findComment-937601 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.