Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Fillable Form: How to Automatically Fill in Email Address Field on 2nd Form

Contributor ,
Feb 19, 2019 Feb 19, 2019

My clients must fill out their email address field in order for a fillable form to be sent to me. After they press Submit they are taken to another fillable form. Can their email address automatically appear in this form?

Here is an example page:

1959 Corvette Options

2.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 19, 2019 Feb 19, 2019

In the documment where the action for the first form takes place, contact.php, add the following code

<?php

  session_start();

  $_SESSION["email"] = $_POST["email"];

?>

then in the document where the action for the second form takes place, (not known), insert the following code

<?php

  session_start();

  $_POST["email"] = $_SESSION["email"];

?>

There is no need to have a form input field for email because it will be automatically added.

Translate
Community Expert ,
Feb 19, 2019 Feb 19, 2019

Yes, there are a number of ways to do this, namely

  • using a URL parameter
  • using a cookie
  • using a session variable

Personally I would go for the last option. For more see PHP 5 Sessions or Google the subject.

Also have a look at https://www.webascender.com/blog/do-i-need-an-ssl-certificate-for-my-website/

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 19, 2019 Feb 19, 2019

I checked the link but it offers general info on php pages. I really need a more specific answer to my question.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2019 Feb 19, 2019

This is not a Dreamweaver question.  It's a question for your web hosting provider an/or your web developer.

Server Security begins at the hosting level with qualified technicians who understand server threats and do everything possible to keep your server safe.  Regular software & security upgrades are essential.   If your server isn't using the latest  technology it's probably not as secure as it should be.

Secure Socket Layer (SSL/TLS Certificates) are obtained from a recognized authority like Comodo CA, DigiCert, or Let's Encrypt and installed on your server.  Site visitors will then see a secure HTTPS protocol in their browser.   Decide beforehand how  much assurance & warranty you need.  And how many domain names to cover.   Additionally, there are 3 types of verification levels to consider.

  • Domain Verified (DV) is the most common and takes as little as 15 minutes with no paperwork to complete.
  • Organization Verified (OV) -- takes 1-3 business days to verify domain name, business ownership records and address.

  • Extended Verified (EV)  - similar to OV above but adds a green organization name to the browser address bar.

For more on obtaining and installing SSL/TLS Certificates yourself, refer to the knowledgebase at Namecheap.com.

https://www.namecheap.com/security/ssl-certificates/

https://www.namecheap.com/support/knowledgebase/category.aspx/14/ssl-certificates

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2019 Feb 19, 2019

In the documment where the action for the first form takes place, contact.php, add the following code

<?php

  session_start();

  $_SESSION["email"] = $_POST["email"];

?>

then in the document where the action for the second form takes place, (not known), insert the following code

<?php

  session_start();

  $_POST["email"] = $_SESSION["email"];

?>

There is no need to have a form input field for email because it will be automatically added.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 19, 2019 Feb 19, 2019

It didn't work.

Here is the new contact.php page code where I inserted the first code:

<?php 

if ($_POST){ 

    if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)){

echo ('<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">

            <b>' . $_POST['email'] . '</b> Email is not valid. Return to previous page and enter a valid email.

          </div>');

        } else { 

        $body = "";

$Miscellaneous = $_POST['Miscellaneous'];

if (preg_match("~\bhttp\b~", $Miscellaneous) or preg_match("~\bHTTP\b~", $Miscellaneous)) {

exit;

}

else {

        foreach ($_POST as $param_name => $param_val) { 

            $body .= "$param_name: $param_val\n"; 

        } 

}

        $headers = 'From: ' .$_POST['email']; 

        if (mail("steve@videoclassics.com", "Contact form submitted.", $body, $headers)) { 

            header('Location: http://www.winvoices.com/orderform.php'); 

  } else { 

  $message = 'Sorry an error occurred. Please try again later.'; 

        } 

    } 

?> 

<?php

  session_start();

  $_SESSION["email"] = $_POST["email"];

?>

And here is the orderform.php page where I inserted the 2nd code:

Order Form

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 19, 2019 Feb 19, 2019

I also tried adding the 2nd code to the contact2.php page. See below:

<?php

  session_start();

  $_POST["email"] = $_SESSION["email"];

?>

<?php

if ($_POST){

    if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)){

echo ('<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">

            <b>' . $_POST['email'] . '</b> Email is not valid. Return to previous page and enter a valid email.

          </div>');

        } else {

        $body = "";

$Miscellaneous = $_POST['Miscellaneous'];

if (preg_match("~\bhttp\b~", $Miscellaneous) or preg_match("~\bHTTP\b~", $Miscellaneous)) {

exit;

}

else {

        foreach ($_POST as $param_name => $param_val) {

            $body .= "$param_name: $param_val\n";

        }

}

        $headers = 'From: ' .$_POST['email'];

        if (mail("steve@videoclassics.com", "Contact form submitted.", $body, $headers)) { 

            header('Location: http://www.winvoices.com/paymentform-deposit.php'); 

  } else {

  $message = 'Sorry an error occurred. Please try again later.';

        }

    }

}

?>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2019 Feb 20, 2019

For contact2.php try

<?php

  session_start();

  if ($_POST) {

    $body = "";

$Miscellaneous = $_POST['Miscellaneous'];

if (preg_match("~\bhttp\b~", $Miscellaneous) or preg_match("~\bHTTP\b~", $Miscellaneous)) {

exit;

} else {

      foreach ($_POST as $param_name => $param_val) {

        $body .= "$param_name: $param_val\n";

      }

}

    $headers = 'From: ' .$_SESSION["email"];

    if (mail("steve@videoclassics.com", "Contact form submitted.", $body, $headers)) {

      header('Location: http://www.winvoices.com/paymentform-deposit.php');

    } else {

  $message = 'Sorry an error occurred. Please try again later.';

    }

  }

Sorry, couldn't get the indentation right on this one. Also too many lines in between.

For the order form, you can leave out the email address.

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 20, 2019 Feb 20, 2019

It appears both forms are cut off.

For contact.php there is no   "?>"   at the end. Is anything else missing?

For contact2.php, the new code you sent me: " $_POST["email"] = $_SESSION["email"];"

does not appear anywhere in the code, and again there is no ending  "?>".

The form gets sent to me, but without any email info.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2019 Feb 20, 2019

There looks to be some kind of redirect going on in or your first form to your second one as in the first form you have

contact.php as the action form field but when you click the submit button the user is redirected to the orderform.php page......maybe that is why your $_SESSION is not working as it needs to go at the top of your orderform.page and contact2.php presumably emails you what the user has chosen BEFORE they are  then redirected to the page with the paypal 50 dollar deposit button on.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2019 Feb 20, 2019
LATEST

sneedbreedley  wrote

It appears both forms are cut off.

For contact.php there is no   "?>"   at the end. Is anything else missing?

For contact2.php, the new code you sent me: " $_POST["email"] = $_SESSION["email"];"

does not appear anywhere in the code, and again there is no ending  "?>".

The form gets sent to me, but without any email info.

Have a look at PHP: PHP tags - Manual where it states:

If a file contains only PHP code, it is preferable to omit the PHP closing tag at the end of the file. This prevents accidental whitespace or new lines being added after the PHP closing tag, which may cause unwanted effects because PHP will start output buffering when there is no intention from the programmer to send any output at that point in the script.
Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2019 Feb 19, 2019

For contact.php try

<?php

  session_start();

  if ($_POST){

    if (!filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL)){

      echo ('<div style="background-color:red;padding:10px;color:#fff;font-size:16px;">

            <b>' . $_POST['email'] . '</b> Email is not valid. Return to previous page and enter a valid email.

            </div>');

    } else {

      $body = "";

      $Miscellaneous = $_POST['Miscellaneous'];

      if (preg_match("~\bhttp\b~", $Miscellaneous) or preg_match("~\bHTTP\b~", $Miscellaneous)) {

        exit;

      } else {

        foreach ($_POST as $param_name => $param_val) {

          $body .= "$param_name: $param_val\n";

        }

      }

      $headers = 'From: ' .$_POST['email'];

      if (mail("steve@videoclassics.com", "Contact form submitted.", $body, $headers)) {

        header('Location: http://www.winvoices.com/orderform.php');

      } else {

        $message = 'Sorry an error occurred. Please try again later.';

      }

    }

    $_SESSION["email"] = $_POST["email"];

  }

Wappler is the DMXzone-made Dreamweaver replacement and includes the best of their powerful extensions, as well as much more!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2019 Feb 19, 2019

Why must your customers complete 2 forms?

And why are you collecting user data from a non HTTPS  site? 

Screenshot from Chrome:

 

Nancy O'Shea— Product User, Community Expert & Moderator
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 19, 2019 Feb 19, 2019

No sensitive info is required, but how do I secure the site? I built it in Dreamweaver?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2019 Feb 20, 2019

https://forums.adobe.com/people/Nancy+OShea  wrote

Why must your customers complete 2 forms?

I don't know. I'm giving up on this one as it's a flawed workflow - why get an email sent prior to the user actually checking out via a payment gateway - the order that never was..........hummm.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 20, 2019 Feb 20, 2019

It's 2 forms because there are 75 pages of various car forms to fill out and I didn't want to add the document order form to 75 different pages.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 20, 2019 Feb 20, 2019

OK, I added the missing code and everything works.

Thanks so much for your help!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 20, 2019 Feb 20, 2019

sneedbreedley  wrote

OK, I added the missing code and everything works.

Thanks so much for your help!

Oh well glad you got it working eventually..........seems like a bit of a long-winded approach to me but if it works it works!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines