thesaleboat Posted August 11, 2008 Share Posted August 11, 2008 I have a question about this, how would you make a form stay filled out if, for example, they entered an email address in the wrong format, and still telling them that they need to re-enter their email address? #php $EmailAddress = trim($EmailAddress); $_name = "/^[-!#$%&\'*+\\.\/0-9=?A-Z^_`{|}~]+"; $_host = "([-0-9A-Z]+\.)+"; $_tlds = "([0-9A-Z]){2,4}$/i"; $EmailAddress=$_POST['EmailAddress'];//reset EmailAddress $from = "From: ".$EmailAddress; if(preg_match($_name."@".$_host.$_tlds,$EmailAddress)){ if(!empty($EmailAddress)){ if (!empty($myusername) ) { mail($to, $subject, $message, $from); //Send EmailAddress to them echo "Thank you for your request ".$myusername.", your EmailAddress has been sent."; echo '<meta content="3; URL=contacts.htm" http-equiv="Refresh" />'; }//end filled out form check }//end EmailAddress exists check else { echo "Sorry, you did not fill in your email address."; echo '<meta content="3; URL=forgotpassword.php" http-equiv="Refresh" />'; } }//end proper email validation else { echo "Sorry, your email address is not in the correct format."; echo '<meta content="3; URL=forgotpassword.php" http-equiv="Refresh" />'; } I know it has to do with the forms action but i am not sure how you have a form post to itself and yet still have another php file which processes the infomation submited in the form? Please help... Link to comment https://forums.phpfreaks.com/topic/119170-solved-form-action-post-to-self/ Share on other sites More sharing options...
tibberous Posted August 11, 2008 Share Posted August 11, 2008 Have the process file be an include. Link to comment https://forums.phpfreaks.com/topic/119170-solved-form-action-post-to-self/#findComment-613676 Share on other sites More sharing options...
obsidian Posted August 11, 2008 Share Posted August 11, 2008 This is "sticky forms," and a Google search will give you a world of help, but the gist is this: <?php $email = isset($_POST['email']) ? htmlentities($_POST['email'], ENT_QUOTES) : ''; ?> <input type="text" name="email" value="<?php echo $email; ?>" /> Good luck! Link to comment https://forums.phpfreaks.com/topic/119170-solved-form-action-post-to-self/#findComment-613677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.