Jump to content

opening new page on submit


CleoK

Recommended Posts

i'm using this PhP script..

 

http://tinyurl.com/2ycjv7

 

as a server side include in an html file (works great!) but.. I would like the thank you page that shows up after the submit button is successfully hit.. to.. either include a link back to the site's home page... OR.. open a new "Thank You" page.

 

Is there a simple way to do that within this script?

 

 

 

Link to comment
Share on other sites

CleoK,

 

    You could add a <meta> tag to link back to your index.php page.  That's a nice, simple way to do it.  So you can set the thank you page to display for 3 seconds (or whatever you want) then it goes back automatically.  Just do this....

 

<head> <meta http-equiv='refresh' content='4; url=index.php'> </head>

 

The <meta> tag has to be between your <head></head> tags.  Where it says "content='4;" - the for is for 4 seconds, you can change it to whatever you like.  Just play with it and see which one you like. 

 

Hope this helps.

Link to comment
Share on other sites

Whenever I write scripts like email forms I always incorporate my "thank you" message into the same script and this is the method I use...

<?php
  $opmode="getinfo";
  $msg="Please complete the following form:";
  //Get all form data here (eg. $fromname=$_POST['from']
  if ($_POST['subsend']) {
    //validate form data eg:
    if (!empty($fromname)) {
      //Send the email
      $opmode="emailsent";
    } else {
      $msg='You need to supply a "from" name";
    }
  }
?>
<html>
<body>
  <?=$msg?><br /><br />
<?php if ($opmode=="getinfo") { ?>
  <form action="<?=$_SERVER['PHP_SELF']?>" method="post">
  <?=$msg?><br /><br />
  Name: <input type="text" name="from" value="<?=$fromname?>" /><br />
  Email: <input type="text" name="email" value="<?=$fromemail?>" /><br />
  <input type="submit" name="subsend" value="Send Email" />
  </form>
<?php } else if ($opmode=="emailsent") { ?>
  Thank-you <?=$fromname?>,<br /><br />
  Your email has been sent.<br /><br />
  <a href="index.php">Click here to go back to the main page</a>
<?php } ?>
</body>
</html>

I'm not sure how well that will work if you that code as a basic template as it's all off the top of my head. I use this method for all my scripts that require alternative information to be sent to the browser and it works fine without problems. Some scripts may get a little large but I do comment my code and use meaningful variable names etc. which all helps when tracking down problems.

 

In the HTML section of the script I check the contents of $opmode and display the relevant section. The contents of $opmode change depending on various conditions in the script like whether I'm wanting to get information from the user, show the information was accepted or various other scenarios.

Link to comment
Share on other sites

Thanks for the suggestions, but so far nothing is working.. the redirect in the meta tag probably isn't an option since the php script is a server side include in an html file.. the page would refrest before they could type in their responses.

 

Here is the script itself.. and the html that has it as a server side include is ordinary.. but the thank you opens the script url NOT the original contact.html page :-(  Even if i could figure out how to put a link back to the home page in the script I'd be happy!

 

<?php
session_start();

// Secure PHP Form Mailer Script v4.21
// Created by Aleister 
// http://www.dagondesign.com/articles/secure-php-form-mailer-script/
// Visit site for help, and new versions, including a Wordpress plugin version



// --------------------------------
// START OF OPTIONS
// --------------------------------


// RECIPIENTS
// ----------
// One:       "onerecip|(email)"
// Multiple:  "mulrecip|(cc or bcc)|(email 1)|(email 2)  etc.. "
// Drop-down: "selrecip"  
// (the drop-down data must be added to the form structure below)

$recipients = "onerecip|user@domain.com";



// FORM STRUCTURE
// --------------
// Please see the website for a full explanation of the structure.
// It is easy to use, but a bit too long to explain here 

$form_structure = array(	
"openfieldset|fmset",
"info|fminfofull|Send me an email...",
"text|fmtext|Name|fm_name|32|100|true|none",
"text|fmtext|Email|fm_email|32|100|false|email",
"text|fmtext|Subject|fm_subject|32|100|false|none",
"text|fmtext|Verify|fm_verify|7|5|true|none",
"textarea|fmtextarea|Message|fm_message|6 |26 |true",
"closefieldset"
);


// SPECIAL FIELDS
// ----------------
// This lets the script know the names of the 'special' fields
//
// VERIFICATION FIELD
// To disable verification, set this to "", and 
// remove the verification line from the form structure

$field_verification = "fm_verify";

// EMAIL HEADER FIELDS
// These are the fields that will be used to generate the header
// for the email(s). If these are set to "", the email will use
// the default values (and you will not see the user's info in
// the email header - only in the message)

$field_name = "fm_name";
$field_subject = "fm_subject";
$field_email = "fm_email";

// DROP DOWN RECIPIENT
// Only applies if you are using a drop down to select a recipient

$field_dropdownrecip = "fm_sendto";



// FORM OPTIONS
// ------------
// SHOW USER WHICH FIELDS ARE REQUIRED
//
// If enabled, this will put an asterisk next to required fields.
// (styled with .fmrequired)

$show_required = TRUE;



// MESSAGE GENERATION
// ------------------

// SUBJECT [PREFIX]
// If you ask for a subject, this will be its prefix.
// If not, this will be the complete subject line.

$subject = 'Website Contact: ';

// SHOW HEADER FIELDS IN MESSAGE
// If using name, email, and/or subject fields in the email header, 
// disabling this option will keep those fields from being shown in the 
// body of the message. (since the information will already be in the header)

$show_headers_in_message = FALSE;

// SHOW VERIFICATION CODE IN MESSAGE
// If enabled, this will show the entered code in the email.

$show_code_in_message = FALSE;

// WRAP MESSAGES
// Required to meet RFC specifications (70 characters per line).

$wrap_messages = TRUE;

// INCLUDE IP
// If enabled, adds the sender's IP and host info to the message

$include_ip = FALSE;



// LANGUAGE OPTIONS
// ----------------

// SERVER ERROR MESSAGE
// Shown when message cannot be sent (do not use html tags).

$msg_mailserver = "No connection to the mailserver. Please try again later.";

// SUCCESS MESSAGE
// Shown when message has been sent (you can use html tags).

$msg_sent = "<h2>Thank you!</h2><p>Your message has been sent!</p>";

// FORM ERROR MESSAGE
// Shown when there is a mistake on the form 
// (do not use html tags - styled with .fmerrortitle).

$msg_error = "Error!";

// SUBMIT BUTTON
// The text for the send button (do not use html tags).

$msg_submit = "Send Email";






// --------------------------------
// END OF OPTIONS
// --------------------------------



// --------------------------------
// CSS DECLARATIONS
// --------------------------------

// It is best to put these declarations in your main style sheet
// Since it is not always proper to have CSS declarations in the middle
// of a file. 

// In the form structure above, you can specify custom class names
// for each input field if you like.

?>


<style type="text/css">
<!--


.mailwrapper {
text-align: center;
}


.maildiv {
margin: 0 auto 0 auto;
text-align: left;
width: 365px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 90%;
}
.maildiv form {
text-align: left;
}
.maildiv label {
/* used for right side captions */
vertical-align: top;
padding: 0 0 0 3px;
}

.maildiv .sidelbl {
/* used for left side labels */
width: 95px;
text-align: right;
padding: 0 10px 0 0;
vertical-align: top;
position: relative;
    display: block; 
    float: left; 
clear: left;
}
.maildiv a {
color: #005ABE;
}
.maildiv h2 {
color: #005ABE;
font-size: 120%;
}
.maildiv input {
margin-bottom: 10px;

}
.maildiv select {
margin-bottom: 10px;

}
.maildiv textarea {
margin-bottom: 10px;

}
.maildiv .ver_img {
padding: 0;
margin: 0 0 10px 10px;
vertical-align:bottom;  
border: 1px solid #005ABE; 
}
.maildiv fieldset {
padding: 5px 5px 5px 5px;
margin-bottom: 10px;
}
.maildiv .legendspacing {
height: 10px;
}
.maildiv .fmcredits {
float: left;
font-size: 90%;
}
.maildiv .fmsubmit {
float: right;
}
.maildiv .fmrequired {
color: #005ABE;
font-size: 90%; 
float: left;
margin-top: 3px;
margin-left: 5px;
}
.maildiv .fmspacer {
height: 10px;
}

.maildiv .fminfofull {
padding: 0 10px 0 10px;
color: #005ABE;
margin-bottom: 15px;
}
.maildiv .fminfohalf {
padding: 0 10px 0 10px;
color: #005ABE;
margin-left: 110px;
margin-bottom: 15px;
}
.maildiv .fmerrorbox {
text-align: left;
}
.maildiv li {
margin: 0 0 4px 0;
}
.maildiv .fmerrortitle {
color: #FF0000;
font-size: 120%;
}

-->
</style>


<?php

// --------------------------------
// END OF CSS DECLARATIONS
// --------------------------------





// Do not edit anything below unless you know what you are doing 


$email_sent = FALSE;
$t_out = "";


// turn $recipients into a useable array
$recipients = explode("|", $recipients);
for ($i = 0; $i < count($recipients); $i++) {
$recipients[$i] = trim($recipients[$i]);
}

// turn form fields into a useable array
for ($i = 0; $i < count($form_structure); $i++) {
$form_structure[$i] = explode("|", $form_structure[$i]);
for ($j = 0; $j < count($form_structure[$i]); $j++) {
	$form_structure[$i][$j] = trim($form_structure[$i][$j]);
}
}


function is_valid_url($link) { 
// returns TRUE if url actually exists

if (strpos($link, "http://") === FALSE) { $link = "http://" . $link; }
    $url_parts = @parse_url($link);
if (empty($url_parts["host"])) return( false );
if (!empty($url_parts["path"])) { $documentpath = $url_parts["path"]; } 
    else { $documentpath = "/"; }
if (!empty($url_parts["query"])) { $documentpath .= "?" . $url_parts["query"]; }
$host = $url_parts["host"];	$port = $url_parts["port"];
if (empty($port)) $port = "80";
$socket = @fsockopen( $host, $port, $errno, $errstr, 30 );
if (!$socket) {	return(false); } 
    else {fwrite ($socket, "HEAD ".$documentpath." HTTP/1.0\r\nHost: $host\r\n\r\n");
$http_response = fgets( $socket, 22 );
if (ereg("200 OK", $http_response, $regs)) { return(true); fclose($socket);	} 
else { return(false); } }
}


function is_valid_email($email) {
// returns TRUE if email address is valid

$qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
$dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
$atom = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
	'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+';
$quoted_pair = '\\x5c[\\x00-\\x7f]';
$domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
$quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
$domain_ref = $atom;
$sub_domain = "($domain_ref|$domain_literal)";
$word = "($atom|$quoted_string)";
$domain = "$sub_domain(\\x2e$sub_domain)*";
$local_part = "$word(\\x2e$word)*";
$addr_spec = "$local_part\\x40$domain";
return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
}


function injection_chars($s) {
// returns TRUE if 'bad' characters are found
return (eregi("\r", $s) || eregi("\n", $s) || eregi("%0a", $s) || eregi("%0d", $s)) ? TRUE : FALSE;
}


function generate_verification() {
srand((double)microtime()*1000000); 
$rand = rand(0,999999999);  
$thecode = substr(strtoupper(md5($rand)), 2, 5); 
$thecode = str_replace("O", "A", $thecode);
$thecode = str_replace("0", "B", $thecode);
$_SESSION["thecode"] = $thecode;
}

function strip_colons($s) {
return str_replace(array(':', '%3a'), " ", $s);
}


$first_load = TRUE;

if (isset($_POST["form_submitted"])) {
// if the form has been submitted

$first_load = FALSE;

// prepare error list
unset($errors);


// prepare mail variables
$mail_message = "";
$mail_name = "Anonymous";
$mail_subject = $subject;
$mail_email = 'noone@nowhere.com';


// process input
foreach ($form_structure as $form_field) {


switch ($form_field[0]) {

case "text":
case "password":

	$f_type = $form_field[0];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_max = $form_field[5];
	$f_req = $form_field[6];
	$f_ver = $form_field[7];

	// get data
	$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : "";
	if (get_magic_quotes_gpc()) {
		$t = stripslashes($t);
	}

	// check for size limits
	if (strlen($t) > $f_max) {
		$errors[] = "There is a $f_max character limit for '$f_name'.";
	}

	// check for required fields
	if (($f_req == "true") && ($t == "")) {
		if ($f_fmname != $field_verification) { // has it's own check
			$errors[] = "Missing required field: '$f_name'.";
		}
	}

	// check for injection characters
	if (($f_type != "textarea") && (injection_chars($t))) {
		$errors[] = "Invalid input in '$f_name'!";
	}

	// check for valid email (if present/required)
	if (($f_ver == 'email') && ($f_req == "true" || (trim($t) != ""))) {
		if (!is_valid_email($t)) {
			$errors[] = "Invalid email address: '$f_name'";
		}
	}
	// check for valid url (if present/required)
	if (($f_ver == 'url') && ($f_req == "true" || (trim($t) != ""))) {
		if (!is_valid_url($t)) {
			$errors[] = "Invalid link: '$f_name'";
		}
	}


	// check for headers/verification fields
	if ($f_fmname == $field_name) {

		if ($t != "") {
			$mail_name = strip_colons($t);
			if ($show_headers_in_message)
				$mail_message .= $f_name . ' = ' . $t . "\n\n";
		}

	} elseif ($f_fmname == $field_subject) {

		if ($t != "") {
			$mail_subject = $subject . strip_colons($t);
			if ($show_headers_in_message)
				$mail_message .= $f_name . ' = ' . $t . "\n\n";
		}

	} elseif ($f_fmname == $field_email) {

		if ($t != "") {
			$mail_email = strip_colons($t);
			if ($show_headers_in_message)
				$mail_message .= $f_name . ' = ' . $t . "\n\n";
		}

	} elseif ($f_fmname == $field_verification) {

		if ($t == "") { 
			$errors[] = "Enter the verification code!";
		} else if (trim($_SESSION["thecode"]) == "") { 
			$errors[] = "No verification code generated!";
		} else if ($_SESSION["thecode"] != strtoupper($t)) { 
			$errors[] = "Invalid verification code!";
		} else {
			if ($show_code_in_message)
				$mail_message .= $f_name . ' = ' . $t . "\n\n";
		}

	} else {

		if ($t != "") {
			$mail_message .= $f_name . ' = ' . $t . "\n\n";
		}

	}	


	break;


case "textarea":

	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_req = $form_field[6];

	// get data
	$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : "";
	if (get_magic_quotes_gpc()) {
		$t = stripslashes($t);
	}

	// check for required fields
	if (($f_req == "true") && ($t == "")) {
		if ($f_fmname != $field_verification) { // has it's own check
			$errors[] = "Missing required field: '$f_name'.";
		}
	}

	if ($t != "") {
		$mail_message .= $f_name . " = \n" . $t . "\n\n";
	}

	break;


case "checkbox":

	$f_name = $form_field[2];

	$t_message = $f_name . ' =';

	$f = FALSE;
	for ($i = 3; $i < count($form_field); $i+=3) {
		$f_fmname = $form_field[$i];
		$f_caption = $form_field[$i+1];

		$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : "";
		if ($t == 'on') {
			$t_message .= " " . $f_caption . ","; 
			$f = TRUE;
		}
	}

	$t_message = rtrim($t_message, ',');

	if ($f) {
		$mail_message .= $t_message . "\n\n";
	}

	break;


case "radio":

	$f_name = $form_field[2];
	$f_fmname = $form_field[3];

	$t = (isset($_POST[$f_fmname])) ? trim($_POST[$f_fmname]) : "";

	$f = FALSE;
	for ($i = 5; $i < count($form_field); $i+=2) {
		if ($t == $form_field[$i]) {
			$f = TRUE;
		}
	}

	if ($f) {
		$mail_message .= $f_name . ' = ' . $t . "\n\n";
	}

	break;


case "select":

	$f_name = $form_field[2];
	$f_fmname = $form_field[3];

	$t_message = $f_name . ' =';

	$t = (isset($_POST[$f_fmname])) ? $_POST[$f_fmname] : "";

	foreach ((array)$t as $tt) {

		$f = FALSE;		
		for ($i = 6; $i < count($form_field); $i++) {
			if (($form_field[$i] == $tt) && (trim($tt) != "")) {
				$f = TRUE;
			}
		}
		if ($f) {
			$t_message .= ' ' . $tt . ',';
		}

	}


	$t_message = rtrim($t_message, ',');

	if ($f) {
		$mail_message .= $t_message . "\n\n";
	}

	break;


}

}


// if no errors, process
if (empty($errors)) {

	$mail_message = trim($mail_message);

	// wrap messages if set
	if ($wrap_messages) {
		$mail_message = wordwrap($mail_message, 70);
	}


	// prepare the headers
	// \r\n seems to be the best method for most servers to handle
	$ip = $_SERVER["REMOTE_ADDR"];
	$mail_header = "";
	$mail_header .= "MIME-Version: 1.0\r\n"; 
	$mail_header .= "X-Sender-IP: $ip\r\n";
	$mail_header .= "Content-Type: text/plain\r\n";
	$mail_header .= "From: " . $mail_name . " <" . $mail_email . ">";


	if ($recipients[0] == 'onerecip') {

		$mail_to = $recipients[1];

	} elseif ($recipients[0] == 'mulrecip') {

		$mail_to = $recipients[2];
		for ($i = 3; $i < count($recipients); $i++) {

			$mail_header .= "\r\n";
			if ($recipients[1] == 'cc') {
				$mail_header .= "Cc: ";
			} else {
				$mail_header .= "Bcc: ";
			}
			$mail_header .= $recipients[$i];
		}

	} elseif ($recipients[0] == 'selrecip') {

		$recip_number = (int)$_POST[$field_dropdownrecip];
		foreach ($form_structure as $form_field) {
			if ($form_field[0] == 'selrecip') {
				$j = 1;
				for ($i = 4; $i < count($form_field); $i++) {
					if (strpos($form_field[$i], "#") === 0) {
						$i++;
					}
					$i++;
					if ($recip_number == $j) {
						$mail_to = $form_field[$i];
					}
					$j++;
				}
			}
		}
	} 


	// send mail, setting $email_sent to true or false


		if ($include_ip) {
			$mail_message .= "\n";
			$mail_message .= "\nHost: " . $_SERVER["HTTP_HOST"];
			$mail_message .= "\nIP: " . $_SERVER["REMOTE_ADDR"];
			$mail_message .= "\nBrowser: " . $_SERVER["HTTP_USER_AGENT"];
		}


	if (mail($mail_to, $mail_subject, $mail_message, $mail_header, "-f $mail_email")) {
		$email_sent = true; 
	} else {
		$errors[] = $msg_mailserver;
		$email_sent = false;
	}

}


if (isset($errors)) {

	// if there were errors, list them

	$t_out .= '<div class="mailwrapper"><div class="maildiv"><div class="fmerrorbox">';
	$t_out .= '<p class="fmerrortitle">' . $msg_error . '</p><ul>';

	foreach ($errors as $f)
		$t_out .= '<li>' . $f . '</li>';

	$t_out .= '</ul></div></div></div>';

} else {

	// the message was sent, display message


	$t_out .= '<div class="mailwrapper"><div class="maildiv">';

	$t_out .= $msg_sent;

	$t_out .= '</div></div>';

	generate_verification();

}

}





if (!$email_sent) {

// SHOW FORM

generate_verification();

if (!extension_loaded("gd")) {
   $t_out .= "<p><b>GD Support not detected!</b> GD is required for this script.</p>";
}

$t_out .= '<div class="mailwrapper"><div class="maildiv">';
$t_out .= '<form method="post" action="' . basename($_SERVER["PHP_SELF"]) . '" enctype="multipart/form-data">';


// go through fields
foreach ($form_structure as $form_field) {


// process field types
switch ($form_field[0]) {


case "openfieldset":

	$f_class = $form_field[1];

	$t_out .= '<fieldset class="' . $f_class . '">';

	if (count($form_field) > 2) {

		$f_legend = $form_field[2];

		$t_out .= '<legend>' . $f_legend . '</legend><div class="legendspacing"></div>';
	}

	break;


case "closefieldset":

	$t_out .= '</fieldset>';

	break;


case "info":

	$f_class = $form_field[1];
	$f_text = $form_field[2];

	$t_out .= '<div class="' . $f_class . '">' . $f_text . '</div>';

	break;


case "text":

	$f_class = $form_field[1];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_size = $form_field[4];
	$f_max = $form_field[5];
	$f_req = $form_field[6];

	$t_out .= '<label class="sidelbl" for="' . $f_fmname . '">';
	if (($f_req == "true") && ($show_required)) 
		$t_out .= '<span class="fmrequired">* </span>';
	$t_out .= $f_name . '</label>';

	$t_out .= '<input type="text" class="' . $f_class . '" name="' . $f_fmname . '" 
				id="' . $f_fmname . '" size="' . $f_size . '" maxlength="' . $f_max . '"';

	if (isset($_POST[$f_fmname])) {
		if ($f_fmname != $field_verification) {
			$t_out .= ' value="' . htmlspecialchars($_POST[$f_fmname]) . '"';
		}
	}

	$t_out .= ' />';

	if ($f_fmname == $field_verification) {
		$t_out .= '<img class="ver_img" src="formmailer_verify.php" width="60" height="20" alt="Please enter the number from this image" />';
	}

	$t_out .= '<br />';

	break;


	case "password":

	$f_class = $form_field[1];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_size = $form_field[4];
	$f_max = $form_field[5];
	$f_req = $form_field[6];

	$t_out .= '<label class="sidelbl" for="' . $f_fmname . '">';
	if (($f_req == "true") && ($show_required)) 
		$t_out .= '<span class="fmrequired">* </span>';
	$t_out .= $f_name . '</label>';

	$t_out .= '<input type="password" class="' . $f_class . '" name="' . $f_fmname . '" 
				id="' . $f_fmname . '" size="' . $f_size . '" maxlength="' . $f_max . '"';

	if (isset($_POST[$f_fmname])) {
		if ($f_fmname != $field_verification) {
			$t_out .= ' value="' . htmlspecialchars($_POST[$f_fmname]) . '"';
		}
	}

	$t_out .= ' /><br />';

	break;


case "textarea":

	$f_class = $form_field[1];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_rows = $form_field[4];
	$f_cols = $form_field[5];
	$f_req = $form_field[6];

	$t_out .= '<label class="sidelbl" for="' . $f_fmname . '">';
	if (($f_req == "true") && ($show_required)) 
		$t_out .= '<span class="fmrequired">* </span>';
	$t_out .= $f_name . '</label>';

	$t_out .= '<textarea class="' . $f_class . '" name="' . $f_fmname . '" 
				id="' . $f_fmname . '" rows="' . $f_rows . '" cols="' . $f_cols . '" >';

	if (isset($_POST[$f_fmname])) {
		if ($f_fmname != $field_verification) {
			$t_out .= htmlspecialchars($_POST[$f_fmname]);
		}
	}

	$t_out .= '</textarea><br />';

	break;


case "checkbox":

	$f_class = $form_field[1];
	$f_name = $form_field[2];

	$t_out .= '<label class="sidelbl">' . $f_name . '</label>';

	for ($i = 3; $i < count($form_field)-1; $i+=3) {
		if ($i > 3) {
			$t_out .= '<label class="sidelbl"> </label>';
		}

		$f_fmname = $form_field[$i];
		$f_caption = $form_field[$i+1];
		$f_checked = $form_field[$i+2];

		$t_out .= '<input class="' . $f_class . '" type="checkbox" name="' . $f_fmname . '" id="' . $f_fmname . '"';

		if ($first_load) {
			if ($f_checked == 'true') {
				$t_out .= ' checked="checked" ';
			}
		} else {
			if (isset($_POST[$f_fmname])) {
				if ($_POST[$f_fmname] == "on") {
					$t_out .= ' checked ';
				} 	
			} 
		}

		$t_out .= ' />';
		$t_out .= '<label for="' . $f_fmname . '">' . $f_caption . '</label> <br />';
	}

	break;


case "radio":

	$f_class = $form_field[1];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_def = $form_field[4];

	$t_out .= '<label class="sidelbl">' . $f_name . '</label>';

	$j = 1;
	for ($i = 5; $i < count($form_field); $i+=2) {

		$f_value = $form_field[$i];
		$f_caption = $form_field[$i+1];

		if ($i > 5) {
			$t_out .= '<label class="sidelbl"> </label>';
		}
		$t_out .= '<input class="' . $f_class . '" type="radio" name="' . $f_fmname . '" id="' . $f_fmname . $j . '" value="' . $f_value . '"';


		if ($first_load) {
			if ((int)$f_def == $j) {
				$t_out .= ' checked="checked" ';
			}
		} else {

			if (isset($_POST[$f_fmname])) {
				if ($_POST[$f_fmname] == $f_value) {
					$t_out .= ' checked="checked" ';
				} 	
			} 
		}

		$t_out .= ' />';
		$t_out .= '<label for="' . $f_fmname . $j . '">' . $f_caption . '</label> <br />';

		$j++;
	}

	break;


case "select":

	$f_class = $form_field[1];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];
	$f_mul = $form_field[4];

	$t_out .= '<label class="sidelbl" for="' . $f_fmname . '">' . $f_name . '</label>';
	$t_out .= '<select class="' . $f_class . '" name="' . $f_fmname;
	if ($f_mul === "true") {
		$t_out .= '[]';
	}	
	$t_out .= '" id="' . $f_fmname . '"';
	if ($f_mul === "true") {
		$t_out .= ' multiple="multiple" ';
	}

	$t_out .= '>';

	$grp_count = 0;
	for ($i = 5; $i < count($form_field)-1; $i++) {

		if (strpos($form_field[$i], "#") === 0) {

			if ($grp_count > 0) {
				$t_out .= "</optgroup>";
			}

			$t_out .= '<optgroup label="' . ltrim($form_field[$i], "#") . '">';

			$grp_count++;
			$i++;
		}

		$t_out .= '<option value="' . $form_field[$i] . '"';

		if ($f_mul == "true") {
			if (isset($_POST[$f_fmname])) {
				foreach ($_POST[$f_fmname] as $p) {
					if ($p == $form_field[$i]) {
						$t_out .= ' selected';
					} 
				}
			} 		
		} else {
			if (isset($_POST[$f_fmname])) {
				if ($_POST[$f_fmname] == $form_field[$i]) {
					$t_out .= ' selected';
				} 	
			} 		
		}


		$t_out .= ' > ' . $form_field[$i+1] . '</option>';

		$i++;

	}

	if ($grp_count > 0) {
		$t_out .= "</optgroup>";
	}
	$t_out .= '</select><br />';

	break;


case "selrecip":

	$f_class = $form_field[1];
	$f_name = $form_field[2];
	$f_fmname = $form_field[3];

	$t_out .= '<label class="sidelbl" for="' . $f_fmname . '">' . $f_name . '</label>';
	$t_out .= '<select class="' . $f_class . '" name="' . $f_fmname . '" id="' . $f_fmname . '" >';


	$j = 1;
	$grp_count = 0;
	for ($i = 4; $i < count($form_field)-1; $i++) {

		if (strpos($form_field[$i], "#") === 0) {

			if ($grp_count > 0) {
				$t_out .= "</optgroup>";
			}

			$t_out .= '<optgroup label="' . ltrim($form_field[$i], "#") . '">';

			$grp_count++;
			$i++;
		}

		$t_out .= '<option value="' . $j . '"';


		if (isset($_POST[$f_fmname])) {
			if ($_POST[$f_fmname] == $j) {
				$t_out .= ' selected';
			} 	
		} 		

		$t_out .= ' > ' . $form_field[$i] . '</option>';

		$i++;
		$j++;
	}

	if ($grp_count > 0) {
		$t_out .= "</optgroup>";
	}
	$t_out .= '</select><br />';

	break;

}	
}

$t_out .= '<div class="fmspacer"><!-- --></div>';

$t_out .= '<div class="fmcredits">script by <a href="http://www.dagondesign.com">dagondesign.com</a></div>';

$t_out .= '<div class="fmsubmit"><input name="form_submitted" type="submit" id="Submit" value="' . $msg_submit . '" /></div>';

$t_out .= '</form></div></div>';

}



echo $t_out;


?>

 

If anyone is playing around with this and needs the verifier code.. it's short and here: http://www.dagondesign.com/files/formmailer_verify.txt.

 

 

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.