PDA

View Full Version : Mail form help - GoDaddy


initialimpressions
09-06-2008, 06:35 AM
I am creating my first website and have included a web form, which I have operating using GoDaddy's webformmailer.php script. However, that script only works with the email address entered in the Go Daddy hosting account control centre ... therefore all forms from all websites I have on my multiple-domain hosting account will go to the same address. This is not what I want as it defeats the purpose of having multiple domains and multiple email addresses in the one account!!!

Anyway, Go Daddy says I need to create my own code to get it working how I want and they can't help with that. I'm wondering if anyone else has encountered this problem and whether anyone else has found a solution.

I'm very new to web design and even newer to web hosting, so I know little (next to nothing) about coding. Can someone offer an example (please note that I've read elsewhere that Go Daddy doesn't accept 3rd party scripts, so I guess that means it needs to fit within its requirements ... hence why I'm asking if someone who has already found the solution for this specific problem can help!

Below if the code, between [ and ], used within the form itself:

<form action="webformmailer.php">
<input type="hidden" name="email" value="me@myemailaddress.com" />
<input type="hidden" name="subject" value="Contact Form Submission from My Website" />
<input type="hidden" name="redirect" value="thankyou.html" />
<label><span class="style1">First name:
<input name="First name" type="text" id="First name" size="50" />
</span></label>
<p class="style1">
<label>Surname:
<input name="Surname" type="text" id="Surname" size="50" />
</label>
</p>
<p class="style1">
<label>Address:
<input name="Address" type="text" id="Address" size="50" />
</label>
</p>
<p class="style1">
<label>Suburb:
<input name="Suburb" type="text" id="Suburb" size="50" />
</label>
</p>
<p class="style1">
<label>Postcode:
<input name="Postcode" type="text" id="Postcode" size="50" />
</label>
</p>
<p class="style1">
<label></label>
<label></label>
<label>Home phone:
<input name="Home phone" type="text" id="Home phone" size="50" />
</label>
</p>
<p class="style1">
<label>Mobile phone:
<input name="Mobile phone" type="text" id="Mobile phone" size="50" />
</label>
</p>
<p class="style1">
<label>Email address:
<input name="Email address" type="text" id="Email address" size="50" />
</label>
</p>
<p class="style1">
<label>Message:
<textarea name="Message" cols="42" rows="8" id="Message"></textarea>
</label>
</p>
<p class="style1">
<label>
<input type="submit" name="submit" value="submit" />
</label> <input type="hidden" name="form_order" value="default"/>
<input type="hidden" name="form_delivery" value="default"/>
<input type="hidden" name="form_format" value="default"/>
</form>]

Clicking submit currently initialises the file webformmailer.php, which has the following code (again written within [ and ]) but as stated above this is the file that uses the email address entered in the control panel and regardless of the email address you type in the code above it always sends to that same address:

<?php
if ( !isset($_SERVER['SPI'])) {
die();
}
if (!isset($_SERVER['DOCUMENT_ROOT'])) {
echo("CRITICAL: we seem to be running outside of the norm.\n");
header("Location: http://".$_SERVER["HTTP_HOST"]."/");
die("CRITICAL: Document root unavailable.\n");
}
$request_method = $_SERVER["REQUEST_METHOD"];
if($request_method == "GET") {
$query_vars = $_GET;
}
elseif ($request_method == "POST") {
$query_vars = $_POST;
}
reset($query_vars);
function customsort($a,$b) {
// $a is array for form vars, $b is comma seperated case sensitive field order
// this is case sensitive -- good idea to hrc that.
$data = array();
if ( strstr($b,',') == FALSE ) {
$b = $b.",";
}
$ordering = split(',',$b);
foreach ($ordering as $orderitem) {
if ( ($orderitem != null) && ($orderitem != "") ) {
if (isset($a[$orderitem])) {
$data[$orderitem] = $a[$orderitem];
}
}
}
foreach ($a as $key=>$val) {
$data[$key] = $a[$key];
}
return $data;
}
function xmlentities($string) {
return str_replace ( array('&', '"', "'", '<', '>'), array('&amp;', '&quot;', '&apos;', '&lt;', '&gt;'), $string);
}
$t = date("U");
$formhomedir = preg_replace('/.*\/home\/content/','',$_SERVER['DOCUMENT_ROOT']);
$formhomedir = explode('/',$formhomedir);
$formhome="/home/content".$formhomedir[0]."/".$formhomedir[1]."/".$formhomedir[2]."/".$formhomedir[3]."/".$formhomedir[4]."/data/";
$file_order = ".default";
$file_format = ".text";
$file_interval = ".15m";
$field_order = "";
if (isset($query_vars['form_order'])) {
if ($query_vars['form_order'] != "alpha") {
$field_order=$query_vars['form_order'];
$file_order=".custom";
$query_vars = customsort($query_vars,$field_order);
}
else {
switch ($query_vars['form_order']) {
case "alpha":
uksort($query_vars,'strnatcasecmp');
$file_order=".alpha";
break;
default:
$file_order=".default";
break;
}
}
}
if (isset($query_vars['form_format'])) {
switch ($query_vars['form_format']) {
case "csv":
$file_format = ".csv";
break;
case "html":
$file_format = ".html";
break;
case "xml":
$file_format = ".xml";
break;
case "text":
case "default":
default:
$file_format = ".text";
break;
}
}
if (isset($query_vars['form_delivery'])) {
switch ($query_vars['form_delivery']) {
case "hourly":
$file_interval = ".60m";
break;
case "hourly_digest":
$file_interval = ".60mc";
break;
case "daily":
$file_interval = ".24h";
break;
case "daily_digest":
$file_interval = ".24hc";
break;
case "digest":
$file_interval = ".15mc";
break;
case "default":
default:
$file_interval = ".15m";
break;
}
}
$file = $formhome."form_".$t.$file_order.$file_format.$file_interval;
$fp = fopen($file,"w");
switch ($file_format) {
case ".csv":
$csvkeys = "";
$csvvals= "";
$firsttime = "";
while (list ($key, $val) = each ($query_vars)) {
if ( ($key == "form_order") ||
($key == "form_format") ||
($key == "form_delivery") ||
($key == "redirect") ) {
}
else {
if ($csvkeys != "") {
$firsttime=",";
}
$tmpkey=escapeshellcmd($key);
$csvkeys = $csvkeys.$firsttime."'".$tmpkey."'";
$tmpval=escapeshellcmd($val);
$csvvals = $csvvals.$firsttime."'".$tmpval."'";
}
}
fputs($fp,"$csvkeys\n");
fputs($fp,"$csvvals\n");
break;
case ".html":
fputs($fp,"<table border=\"1\" cellspacing=\"1\" cellpadding=\"2\">\n");
break;
case ".xml":
fputs($fp,"<form>\n");
break;
}

while (list ($key, $val) = each ($query_vars)) {
if ($key == "redirect") {
$landing_page = $val;
}
if ( ($key == "form_order") ||
($key == "form_format") ||
($key == "form_delivery") ||
($key == "redirect") ) {
}
else {
switch ($file_format) {
case ".html":
fputs($fp,"\t<tr>\n");
fputs($fp,"\t\t<td><b>$key</b></td>\n");
fputs($fp,"\t\t<td>$val</td>\n");
fputs($fp,"\t</tr>\n");

break;
case ".csv":
// content is already output
break;
case ".xml":
fputs($fp,"\t<field>\n");
fputs($fp,"\t\t<fieldname>".xmlentities($key)."</fieldname>\n");
fputs($fp,"\t\t<fieldvalue>".xmlentities($val)."</fieldvalue>\n");
fputs($fp,"\t</field>\n");
break;
case ".text":
default:
fputs($fp,$key.": ".$val."\n");
break;
}
}
}
switch ($file_format) {
case ".html":
fputs($fp,"</table>\n");
break;
case ".xml":
fputs($fp,"</form>\n");
break;
}

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

?>

edbr
09-08-2008, 01:32 AM
<input type="hidden" name="email" value="me@myemailaddress.com" />

by changing that on any form you make will determinre the destination address. There are often problems posted with go -daddy, what made you choose it? Is it a very cheap hoster?

rattlsnak
09-08-2008, 01:34 AM
read this: http://www.dreamweaverclub.com/dreamweaver-php-form.php
You can use the script in this example, but just edit the form entires to use your specific form data.

initialimpressions
09-08-2008, 12:35 PM
by changing that on any form you make will determinre the destination address. There are often problems posted with go -daddy, what made you choose it? Is it a very cheap hoster?
Unfortunately changing the email address doesn't work ... I'm assuming because Go Daddy's webformmailer.php file overrides it.

I chose Go Daddy because it was recommended to me by a colleague ... but yeah, I've had various problems and not all have been easy to sort out and they've not been overly helpful on all occasions.

domedia
09-08-2008, 12:51 PM
My experience:
Godaddy and domains = good idea
Godaddy and hosting = not good idea

initialimpressions
09-08-2008, 12:53 PM
read this: http://www.dreamweaverclub.com/dreamweaver-php-form.php
You can use the script in this example, but just edit the form entires to use your specific form data.

When I saw your post I really hoped it was going to be that easy, but alas, it's not.

I've used the script in the example, edited it as stated but when I click 'Submit' it takes me to a HTTP 404 Not Found error page. Very odd.

Curse GO DADDY!!!! Hahaha

Are there any club members who use Go Daddy themselves and have found a solution to this problem???

rattlsnak
09-08-2008, 02:16 PM
did you change this line?

// Where to redirect after form is processed.
$url = 'http://www.rdsnetworks.net/confirmation.html';

domedia
09-08-2008, 02:27 PM
I've used the script in the example, edited it as stated but when I click 'Submit' it takes me to a HTTP 404 Not Found error page. Very odd.No, it's not odd, it just means you did something wrong. :-(

initialimpressions
09-08-2008, 11:16 PM
did you change this line?

// Where to redirect after form is processed.
$url = 'http://www.rdsnetworks.net/confirmation.html';


Yeah I did ... this is what I have (I've replaced my email address because I don't want to get spammed, but it is correct in the script)

$subject = 'Contact Form Submission from IKPS Website';
$emailadd = 'myemail@mydomain.com.au';
$url = 'http://www.ikps.info/thankyou.html';
$req = '0';

initialimpressions
09-08-2008, 11:21 PM
Just to double check, the $subject, $emailadd, $url and $req lines should be in the "sendresults" php file only shouldn't they and are not needed in the file where the form is????

initialimpressions
09-09-2008, 12:59 AM
Got it! :grin:

I tried dropping the domain name in the "Action" attribute and it worked!!! 8)

Thanks for the help! It's much appreciated.

Upright
12-29-2008, 05:37 PM
Your thread on how to setup a php form was helpful. However, is it possible to specify only certain fields as required? In the script, there is only an option for all or nothing. What if you only want to require certain fields but leave others optional?
Thanks

rattlsnak
12-31-2008, 03:32 AM
Which script are you using? the one from godaddy, or the one from the dreamweaver club that i gave the link to?

Upright
12-31-2008, 05:55 AM
I'm using the one from the Dreamweaver club that you linked to - not GoDaddy's. It looks like in the script, there are only two options - all required or none required.

rattlsnak
01-02-2009, 12:49 AM
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '0';

foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}

You would have to edit this part. You could remove the $req variable and use an if statement for each field you want or don't want to make mandatory.

if ($YourFormNameHere == ' ')
{echo "You must fill out this section' } or whatever you want to say.

iwhenry
07-31-2009, 06:47 PM
Very helpful form posting!! Is there a way to get this form processor to send the results to more than one e-mail?

edbr
08-01-2009, 12:52 AM
yes it could be adapted

vinnyvangogh
08-08-2009, 12:32 PM
When I saw your post I really hoped it was going to be that easy, but alas, it's not.

I've used the script in the example, edited it as stated but when I click 'Submit' it takes me to a HTTP 404 Not Found error page. Very odd.

Curse GO DADDY!!!! Hahaha

Are there any club members who use Go Daddy themselves and have found a solution to this problem???


Hi,

I am brain dead when it comes to thinking code! I found this script yesterday and had it running in about an hour.

I found that "Post" is sometimes blocked by some servers and I needed to remove this enctype="text/plain which was in the HTML version.

I assume you created a notification page, and used the correct path in the form to your web files location.