Jump to content

form mailer script


jamichelli

Recommended Posts

It's been a while since I posted on here.  Since then I've changed directions in what I am doing with my site programming, going from forms that post to a database to forms that email.  Because of the extensive time in getting all the prior coding down, I don't want to abandon everything that has come before, just the method used to submit the forms.  I already have all the validation up and working.  The first part of the validation goes through the step:

$opMode='gather';

Once the "gather" mode is done, the user checks their input to verify everything is correct:

if (isset($_POST['subdone']))

If the input is incorrect, the user goes back to the "gather" mode and corrects the incorrect input:

if (isset($_POST['subedit'])) {
  $opMode='gather'; 
}

or, if all the input is correct, then that input gets submitted:

if (isset($_POST['subapprove']))

The method I was using before was submitted to an SQL database:

if (isset($_POST['subapprove'])) {
if (mysql_query("INSERT INTO contact_info (full_name, address1, address2, city, state, zip, phone, altphone, email, altemail, time_to_contact, how_find_us) 
VALUES 
('$_POST[full_name]','$_POST[address1]','$_POST[address2]','$_POST[city]','$_POST[state]','$_POST[zip]','$_POST[phone]','$_POST[altphone]','$_POST[email]','$_POST[altemail]','$_POST[time_to_contact]','$_POST[how_find_us]')")) {
  	$opMode='added';
header("Location:http://www.mywebsite.com/tempform2.php");
exit;
  } else {
  	$opMode='fail';
  }
}

My challenge, as far as I can tell (being a non-professional, newbie, very green coder), is two-fold.  First, I'm hosted on GoDaddy's servers.  It's a Windows based server and is limited on php coding that is allowed, apparently.  They have a form mailer code that is included, which happens to be php (gdform.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");
$file = $_SERVER['DOCUMENT_ROOT'] . "\ssfm\gdform_" . $t;
$fp = fopen($file,"w");

while (list ($key, $val) = each ($query_vars)) 
{
	fputs($fp,"<GDFORM_VARIABLE NAME=$key START>\r\n"); 
	fputs($fp,"$val\r\n");
	fputs($fp,"<GDFORM_VARIABLE NAME=$key END>\r\n");
	if ($key == "redirect") 
	{ 
		$landing_page = $val;
	}
}

fclose($fp);

if ($landing_page != "")
{
	header("Location: http://".$_SERVER["HTTP_HOST"]."/$landing_page");
} 
else 
{
	header("Location: http://".$_SERVER["HTTP_HOST"]."/");
}
?>

Seeing that GoDaddy limits what can be done on this type of server, how would I go about modifying the code after the:

if (isset($_POST['subapprove']))

to get the form's input to mail instead of trying to submit to a db?  I'm pretty sure that coding in the GoDaddy supplied form mailer script needs to be modified as well to do what I want it to do.  It presently submits all the data, then forwards the user back to the home page (www.mywebsite.com) of my site.  I want to redirect to the next page on my site (www.mywebsite.com/tempform2.php), not the home page.  Suggestions?

Link to comment
https://forums.phpfreaks.com/topic/183372-form-mailer-script/
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.