Jump to content

PHP form question??


austin350s10

Recommended Posts

I am trying to use reCAPTCHA to validate the forms on my website.  Problem is when the user enters a wrong security code they are sent to an error page with a redirect button to the form they were working on.  When they are sent back to the form all the values in the form field are gone forcing the user to re-enter all their work. 

 

How can I make it so the form holds the values?  I have heard that $_GET request would work somehow but I have no idea how to make that work.

 

BTW....I am super new to PHP

 

The example form is here http://www.affordablehomecare.org/functions/example-captcha.php

 

Thanks,

 

-Austin-

Link to comment
https://forums.phpfreaks.com/topic/160140-php-form-question/
Share on other sites

try this:

<?php
//optout2.php
if (isset($_POST) && !empty($_POST['email'])){
session_start();
$_SESSION['email'] = $_POST['email'];
}
?>

<?php
//optout.php
session_start();
if (isset($_SESSION['email'])){
$email_value = "value=\"".$_SESSION['email']."\" ";
}
else{
$email_value = "";
}
?>
<form action="optout2.php" method="post">
  <fieldset class="radius">
  <legend>We're Sorry To See You Go</legend>

  <p>Please enter the email address you would like to have removed from our mailing list in the box below and click the unsubscribe button.</p>
  <dl>
  <dd><span id="sprytextfield1">
  <input type="text" name="email" id="email" <?php print $email_value; ?>tabindex="1"/>

 

I added the form just to show you how to do it, edit your form just adding the PHP I added.  Add the PHP that I wrote at the top of each page (the stuff below optout.php in optout.php, and the stuff below optout2.php at the top of optout2.php).

Link to comment
https://forums.phpfreaks.com/topic/160140-php-form-question/#findComment-844899
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.