tpsilver10 Posted May 10, 2007 Share Posted May 10, 2007 So I finally got my CAPTCHA to implement just nicely. What I'm wondering is...is there a way to produce an error message on the same page without wiping the fields that the user just filled in? At the moment I have if ($_SESSION['security_code'] != $_POST['security_code'] && !empty($_SESSION['security_code'])){ header("Location: /pacesetter/index.php?id=quotes&subid=downunder&error=1"); exit; if($_GET['error'] == 1){ echo "<span class='wrongcode'>You entered an incorrect security Code...</span><br />"; If you want to see what I mean: www.pacesettertravel.com/pacesetter/index.php?id=quotes&subid=downunder Quote Link to comment https://forums.phpfreaks.com/topic/50853-form-error-message-keep-fields-filled-in/ Share on other sites More sharing options...
kvigor Posted May 10, 2007 Share Posted May 10, 2007 Yes, keep assign the form field value to the input tag. e.g. <input name='Name' type='text' class='nameAddressCity_pos' id='textfield' value='{$_POST['Name']}' size='100'/> Quote Link to comment https://forums.phpfreaks.com/topic/50853-form-error-message-keep-fields-filled-in/#findComment-250112 Share on other sites More sharing options...
Caesar Posted May 10, 2007 Share Posted May 10, 2007 <?php $oldvalu = ''; if(isset($_POST['username'])) { $oldvalu = $_POST['username']; } echo"<input name=\"username\" type=\"text\" size=\"15\" value=\"$oldvalu\">"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/50853-form-error-message-keep-fields-filled-in/#findComment-250113 Share on other sites More sharing options...
tpsilver10 Posted May 10, 2007 Author Share Posted May 10, 2007 Hmm...dunno where the hell I'm going wrong, but I can't seem to get either of them to work. Odd... <?php $oldvalu = ''; if(isset($_POST['name'])) { $oldvalu = $_POST['name']; } echo"<input name=\"name\" type=\"text\" value=\"$oldvalu\" class=\"formstyles\" />"; ?> <input type='text' name='email' class="formstyles" value='{$_POST['email']}' /> Quote Link to comment https://forums.phpfreaks.com/topic/50853-form-error-message-keep-fields-filled-in/#findComment-250121 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.