SarahB87 Posted July 21, 2008 Share Posted July 21, 2008 Hey guys! I've been working on a Ajax/PHP Validation form, and have managed to get everything to work, but I cannot seem to retain the values the user enters when the form validates. The following link will give you an example of what I am talking about: http://www.juniatamutual.com/general/contact_us.php I believe that I have narrowed the error down to this line of code <input name="FirstName" type="text" id="FirstName" value="<?php (isset($_POST['FirstName'])) ?>"> Any advise would be greatly appreciated! Thanks! Link to comment https://forums.phpfreaks.com/topic/115908-solved-php-validation-value-dissapears/ Share on other sites More sharing options...
KevinM1 Posted July 21, 2008 Share Posted July 21, 2008 Hey guys! I've been working on a Ajax/PHP Validation form, and have managed to get everything to work, but I cannot seem to retain the values the user enters when the form validates. The following link will give you an example of what I am talking about: http://www.juniatamutual.com/general/contact_us.php I believe that I have narrowed the error down to this line of code <input name="FirstName" type="text" id="FirstName" value="<?php (isset($_POST['FirstName'])) ?>"> Any advise would be greatly appreciated! Thanks! Without being able to see your PHP, try something like: value="<?php if(isset($_POST['FirstName'])){ echo $_POST['FirstName']; } ?>" Link to comment https://forums.phpfreaks.com/topic/115908-solved-php-validation-value-dissapears/#findComment-595933 Share on other sites More sharing options...
revraz Posted July 21, 2008 Share Posted July 21, 2008 Acually, you should just need value="<?php echo $_POST['FirstName'] ?>" Since if it's not set, it will be empty anyways. Link to comment https://forums.phpfreaks.com/topic/115908-solved-php-validation-value-dissapears/#findComment-595946 Share on other sites More sharing options...
jonsjava Posted July 21, 2008 Share Posted July 21, 2008 Acually, you should just need value="<?php echo $_POST['FirstName'] ?>" Since if it's not set, it will be empty anyways. While that is true, it is good code practice to verify that a value has been set. Nightslyr is correct on that count. Link to comment https://forums.phpfreaks.com/topic/115908-solved-php-validation-value-dissapears/#findComment-595947 Share on other sites More sharing options...
Barand Posted July 21, 2008 Share Posted July 21, 2008 Acually, you should just need value="<?php echo $_POST['FirstName'] ?>" Since if it's not set, it will be empty anyways. I'd recommend developing with error_reporting set to E_ALL, in which case your code is going to throw out a warning message. Link to comment https://forums.phpfreaks.com/topic/115908-solved-php-validation-value-dissapears/#findComment-595988 Share on other sites More sharing options...
SarahB87 Posted July 21, 2008 Author Share Posted July 21, 2008 You guys rock! Nightslyr, your solution works perfect! Thanks! Link to comment https://forums.phpfreaks.com/topic/115908-solved-php-validation-value-dissapears/#findComment-596022 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.