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! Quote 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']; } ?>" Quote 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. Quote 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. Quote 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. Quote 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! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.