Jump to content

[SOLVED] Form action: Post to self


thesaleboat

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.