Membership is FREE, giving all registered users unlimited access to every DNForum feature, resource, and tool! Optional membership upgrades unlock exclusive benefits like profile signatures with links, banner placements, appearances in the weekly newsletter, and much more - customized to your membership level!

Feedback form [PHP]

Status
Not open for further replies.

chidoug

Level 4
Legacy Platinum Member
Joined
Jan 31, 2005
Messages
137
Reaction score
1
A friend wanted to put a feedback form on his site, and I did the best I could. Just about everything works. People are able to input their data and then summit it, but when it comes to the redirect after hitting the summit button, it doesn’t load the way I would prefer.



I have a [thank you] page, but after hitting summit the index loads in the Iframe…. Can anyone take a look at the coding and maybe point me in the right direction? PM me if you want to take a look at the feedback page, i will then supply the url

PHP:
<?php
	$request_method = $_SERVER["REQUEST_METHOD"];
	if($request_method == "GET"){
	 $query_vars = $_GET;
	} elseif ($request_method == "POST"){
	 $query_vars = $_POST;
	}
	reset($query_vars);
	$t = date("U");
	$fp = fopen("../data/gdform_$t","w");
	while (list ($key, $val) = each ($query_vars)) {
	 fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\n");
	 fputs($fp,"$val\n");
	 fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\n");
	 if ($key == "redirect") { $landing_page = $val;}
	}
	fclose($fp);
	if ($landing_page != "thanks.htm"){
header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
	} else {
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
	}
 
 
?>
 

Gray

Level 4
Legacy Platinum Member
Joined
Oct 28, 2004
Messages
201
Reaction score
0
on the last line change "/" to "/thanks.htm"
 

chidoug

Level 4
Legacy Platinum Member
Joined
Jan 31, 2005
Messages
137
Reaction score
1
Gray said:
on the last line change "/" to "/thanks.htm"
Thanks for your help, but this didn’t work either, the index page continues to load in the iFrame


hey i got it, thanks again for the help. i had to do what you suggested, but another change'
this is what i had
PHP:
if ($landing_page != "thanks.htm"){
</FONT>

and this is what i had to change it to
PHP:
if ($landing_page == "thanks.htm"){
</FONT>
 

Gray

Level 4
Legacy Platinum Member
Joined
Oct 28, 2004
Messages
201
Reaction score
0
On your form is there something like this?

<input type="hidden" name="redirect" value="index.html">


[EDIT] OK no problem then. :eek:k:
 

hostele

Level 7
Legacy Platinum Member
Joined
Nov 16, 2004
Messages
981
Reaction score
1
Hi

This is what im using in most of my sites:

PHP:
<?

// ------------- CONFIGURABLE SECTION ------------------------

// $mailto - set to the email address you want the form
// sent to, eg
//$mailto		= "[email protected]" ;

$mailto = '[email protected];

// $subject - set to the Subject line of the email, eg
//$subject	= "Feedback Form" ;

$subject = "Contact Form" ;

// the pages to be displayed, eg
//$formurl		= "http://www.example.com/feedback.html" ;
//$errorurl		= "http://www.example.com/error.html" ;
//$thankyouurl	= "http://www.example.com/thankyou.html" ;

$formurl = "http://www.YourDomain.com/offer.html" ;
$errorurl = "http://www.YourDomain.com/error.html" ;
$thankyouurl = "http://www.YourDomain.com/thank.html" ;

// -------------------- END OF CONFIGURABLE SECTION ---------------

$name = $_POST['name'] ;
$email = $_POST['email'] ;
$domain = $_POST['domain'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );

if (!isset($_POST['email'])) {
	header( "Location: $formurl" );
	exit ;
}
if (empty($name) || empty($email) || empty($domain) || empty($comments)) {
   header( "Location: $errorurl" );
   exit ;
}
if (get_magic_quotes_gpc()) {
	$comments = stripslashes( $comments );
}

$messageproper =

	"NAME:\n" .
	"$name\n\n" .
        "EMAIL:\n" .
        "$email\n\n" .
        "DOMAIN:\n" .
        "$domain\n\n" .
	"COMMENTS\n" .
        "$comments\n" .
	"\n" ;

mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.02" );
header( "Location: $thankyouurl" );
exit ;

?>

*Copy the code and save it as feedback.php
*You will need a thank you page & error page.
*You will also need to place this in your contact page:
<form action="http://www.YourDomain.com/feedback.php" method="post">

It always work for me. :)
 
Status
Not open for further replies.

Who has viewed this thread (Total: 1) View details

Who has watched this thread (Total: 3) View details

Top Bottom