Hello, and thanks in advance for any assistance -
I have a website on godaddy, and I've been using their gdform.php script for form mailing.
It is in 2 parts - the gdform.php which is in my folder, and the mailer which I cannot view or edit, on their server.
As it exists, the email subject is determined in my html, and the mailto address was entered in godaddy control panel.
My objective:
A) To create a php form mailer script which will replace the gdform entirely.
😎 I want new script to grab the contents of 1 form field (customer name) and add it to the emial subject line.
ie: I want the email subject to read "Order from: 'customer name'" //from "Editbox14"
I am a complete novice in php. I have moderate knowledge with HTML. I am quick and creative, but I lack background - so please don't make assumptions on what I know. Since this is a short script, the most helpful would be fully formed script suggestions for me to play with. (doctor mine below)
Here is the html line which posts the form and defines the email subject line:
<form name="Form1" method="post" action="http://www.mywebsite.com/test/mmcform.php" enctype="multipart/form-data" id="Form1" onsubmit="return ValidateForm1(this)" ><input type="hidden" name="redirect" value="purchase.html"><input type="hidden" name="subject" value="Order From:">
Here is the existing 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'] . "/../data/gdform" . $t;
$fp = fopen($file,"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 != ""){
header("Location: http://".$SERVER["HTTP_HOST"]."/$landing_page");
} else {
header("Location: http://".$SERVER["HTTP_HOST"]."/");
}
?>
Here is a variant I've been modifying and testing (with no success so far)
(I changed the script name to mmcform.php, and replaced all references to gdform with mmcform in both php and html.)
<?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");
$to ="myemail@email";
$from = $POST['Editbox14'];
$subject ="Order from:" . $POST['Editbox14'];
mail($to ,$from , $subject, $message)
$message .= '$POST['Editbox1']
$message .= '$POST['Editbox2']
$message .= '$_POST['Editbox14']
$file = $_SERVER['DOCUMENT_ROOT'] . "/../data/gdform_" . $t;
$fp = fopen($file,"w");
while (list ($key, $val) = each ($query_vars)) {
fputs($fp,"<MMCFORM_VARIABLE NAME=$key START>\n");
fputs($fp,"$val\n");
fputs($fp,"<MMCFORM_VARIABLE NAME=$key END>\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"]."/");
}
mail($to,$from, $subject, $message)
if(!mail){
echo 'Message Not sent!';
}
echo 'Message was sent!';
?>
Thanks so much again for any assistance