Page 1 of 1

pass form variable via POST not working

Posted: Thu Aug 11, 2016 8:21 am
by jonnyfortis
what am i missing. got a simple form with an email address that i need passing to another page so i can send a confirmation mail saying we have their email address but the variable is not passing

form

Code: Select all

      <form method="post" name="form2" action="<?php echo $editFormAction; ?>">
        <input type="text" name="maillistEmail" placeholder="email address" class="textox">
        <input type="submit" name="btn2" class="btn" value="SIGNUP">
        <input type="hidden" name="MM_insert" value="form2">
          </div>
        </form>
code

Code: Select all

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
  $insertSQL = sprintf("INSERT INTO beau_mailist (maillistEmail) VALUES (%s)",
                       GetSQLValueString($_POST['maillistEmail'], "text"));

  mysql_select_db($database_beauSS15, $beauSS15);
  $Result1 = mysql_query($insertSQL, $beauSS15) or die(mysql_error());

  $insertGoTo = "mail-list-thank-you.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
then all i want on the next page mail-list-thank-you.php

$customerEmail = $_POST["maillistEmail"];

then the mail script...

Re: pass form variable via POST not working

Posted: Thu Aug 11, 2016 8:32 am
by Celauran
After processing the form, you're performing a header redirect. That's not a POST request, so $_POST will be an empty array. You could append a query string, use a session, or redirect with a post request instead.