i am using the following code for form action,
// includes
require_once('inc/mysql_wrapper.php');
$DB=get_db_connection();
require_once('inc/defines.inc.php');
require_once('lib/functions.php');
require_once('lib/framework.php');
require_once('lib/specific.php');
require_once('lib/table_editor.php');
require_once('lib/user.php');
require_once('models/basic.php');
require_once('models/list.php');
require_once('swiftmailer/lib/swift_required.php');
require_once('recaptcha/recaptchalib.php');
// end includes
$q="SELECT value FROM $T_SETTINGS
WHERE name='register'";
$register=$DB->oq($q);
$optin=get_setting("optin");
// select custom fields if any
$q="SELECT * FROM $T_FIELDS
WHERE list_id='$_GET[list_id]'
ORDER BY id";
$efields=$DB->aq($q);
// select mailing list
$q="SELECT * FROM $T_LISTS WHERE id='$_GET[list_id]'";
$list=$DB->sq($q);
if(!empty($_POST['ok']))
{
// validate recaptcha if required
if($list['require_recaptcha'])
{
$resp = recaptcha_check_answer (RECAPTCHA_PRIVATE,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid)
{
$recaptcha_error="Looks like the words you entered are not correct!";
$template="templates/register.html";
require_once('templates/master.html');
exit;
}
}
User::register($_POST, $efields, $optin);
if(!empty($list['redirect_to']))
{
redirect($list['redirect_to']);
exit;
}
$template="templates/message.html";
}
else
{
$template="templates/register.html";
}
require_once('templates/master.html');
excluding some other options, majorly the form data which this form recieves is
name , email , ok (a flag to check that the the orginating form was submitted)
how can I redirect this page to thanks.php when the form has been submitted?
Can’t you post it directly in thanks.php?
Thanks.php should control data format and display message, or redirect (by place into header that string:
header('Location: urlOfForm-postedPage);.So, if data are correct (and if a control is needed, but I suppose yes) you don’t need a redirect.
More over, if controll are done into the original page (simply JS or JQuery?), you can save some redirects.
And that will be more efficient!