PDA

View Full Version : Form not returning results



royhunters
Aug 14th, 2009, 08:27 PM
I am having some trouble with this form and I was hoping someone could help me with it. It is not returning any errors, it is simply not returning the results of the form fields.

The clear form works, the redirect works, the layout is fine, just no results. I am just beginning to learn how to do this and I know this is a pretty basic form, but could someone be so kind to show me what it is I am doing wrong and teach me the right way to do this?

I know it has to be something very simple but I keep going over it and i can not see what I am doing wrong.

Rather than just post a snipit of the code I included the whole form so I do not forget to include any information.

Thanks guys, I really appreciate it! :thumbsup:



<form name="evaluation"
action="http://www.YOURURL.com/webformmailer.php"
target="_self" method="post"><input
value="Submission" name="subject" type="hidden" /><input
value="evaluationreturn.html" name="redirect"
type="hidden" />
<span style="font-family: Arial,Helvetica,sans-serif;"><span
style="font-weight: bold;"><br />
<table bgcolor="F7F5F2" border="0"
cellpadding="0" cellspacing="0" width="456">
<tbody>
<tr>
<td><span style="color: rgb(40, 89, 161);">Comment 1</span><br
style="color: rgb(40, 89, 161);" />
<br style="color: rgb(40, 89, 161);" />
<span style="color: rgb(40, 89, 161);">Comment 2</span><br
style="color: rgb(40, 89, 161);" />
<br style="color: rgb(40, 89, 161);" />
<span style="color: rgb(40, 89, 161);">comment 3</span><br />
<br />
</td>
</tr>
<tr>
<td height="28" valign="top">
<table style="width: 456px; height: 52px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="width: 137px; text-align: left; color: rgb(40, 89, 161);"
class="text_1">Your name:</td>
<td style="width: 40px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 271px;"><input
name="yourname" class="form_1" type="text" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="28" valign="top">
<table style="width: 456px; height: 52px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="width: 137px; text-align: left; color: rgb(40, 89, 161);"
class="text_1">Business name:</td>
<td style="width: 40px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 271px;"><input
name="businessname" class="form_1" type="text" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="75" valign="top">
<table style="width: 456px;" border="0"
cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="text_1"
style="padding-top: 3px; width: 138px; text-align: left; vertical-align: middle; color: rgb(40, 89, 161);">Business
Location:</td>
<td style="width: 38px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 272px;"><textarea
name="location" class="form_1"></textarea></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="40" valign="top">
<table style="width: 456px;" border="0"
cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="padding-top: 3px; width: 138px; text-align: left; vertical-align: middle; color: rgb(40, 89, 161);"
class="text_1">Business
Hours:</td>
<td style="width: 38px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 272px;"><textarea
name="businesshours" class="form_1"></textarea></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="28" valign="top">
<table style="width: 456px; height: 50px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="text-align: left; width: 143px; color: rgb(40, 89, 161);"
class="text_1">Reservation required?</td>
<td style="width: 34px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 271px;"><input
name="reservation" class="form_1" type="text" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="28" valign="top">
<table style="width: 456px; height: 50px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="width: 138px; text-align: left; color: rgb(40, 89, 161);"
class="text_1">Reservation Telephone Number:</td>
<td style="width: 39px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 271px;"><input
name="reservationphone" class="form_1" type="text" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="28" valign="top">
<table style="width: 456px; height: 50px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="width: 138px; text-align: left; color: rgb(40, 89, 161);"
class="text_1">E-mail address:</td>
<td style="width: 39px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 271px;"><input
name="email" class="form_1" type="text" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="28" valign="top">
<table style="width: 456px; height: 50px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td
style="width: 138px; text-align: left; color: rgb(40, 89, 161);"
class="text_1">Your contact number:</td>
<td style="width: 39px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 271px;"><input
name="yournumber" class="form_1" type="text" /></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td height="91" valign="top">
<table style="width: 456px;" border="0"
cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td class="text_1"
style="vertical-align: top; padding-top: 3px; width: 138px; text-align: left; color: rgb(40, 89, 161);">Select
dates to perform evaluation: From/To &nbsp;<br />
Maximum of 30 days</td>
<td style="width: 38px;"><img
src="images/spacer.gif" height="1" width="1" /></td>
<td style="width: 272px;"><textarea
name="performdate" class="form_2"></textarea></td>
</tr>
<tr>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<br />
</span></span>
<table style="text-align: left; width: 458px;"
border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td style="width: 220px; text-align: center;">
<p> <input value="Clear Form"
onclick="reset(); return false;" type="reset" /></p>
<input value="alpha" name="form_order"
type="hidden" />&nbsp;
</td>
<td style="width: 218px; text-align: center;">
<p> <input value="Submit"
onclick="submit();" type="submit" /></p>
<input value="alpha" name="form_order"
type="hidden" />
</td>
</tr>
</tbody>
</table>
<span style="font-family: Arial,Helvetica,sans-serif;"><span
style="font-weight: bold;"></span></span></form>

noneforit
Aug 14th, 2009, 08:56 PM
The HTML in the form looks ok but we really need to see the PHP code behind it to look into the problem further.

The action of the form is to call the PHP script from a different website, did you use a form generator or did you write your own PHP code?

Also tables for layout is not a good idea......

tomws
Aug 14th, 2009, 08:57 PM
I'll state the obvious question: did you actually change the code in the form tag to the correct URL?

action="http://www.YOURURL.com/webformmailer.php"

royhunters
Aug 14th, 2009, 09:05 PM
I took my url out for the post, it is nearly the same script I use for my newsletter submission form which works fine. here is a link to the page on my server:

http://www.mymarketingcompany.com/business-evaluations.html

Thanks for your posts!!!!! :thumbsup:

royhunters
Aug 14th, 2009, 09:07 PM
I am pretty new at this so I am sure there are some mistakes, the tables just seem to be an easy way to manage the layout. Go easy on me, I am learning :)

tomws
Aug 14th, 2009, 09:13 PM
Bad link. Should be 'my' rather than 'may', yes?

I think you may need to consult the documentation for webformmailer.php again. The form does submit and then the user is redirected to the home page. That means something is happening on the server.

You could debug with php, but I don't know how to see what's happening otherwise.

EDIT: Not redirected to the home page. Redirected to the defined return page. My mistake.

royhunters
Aug 14th, 2009, 09:25 PM
Did I mention I can not type either? :p

Yes it is "my" I edited the post.

royhunters
Aug 14th, 2009, 09:30 PM
Ok, is the problem because I am trying to use the webformailer.php for two different form scripts?

I did not do the code for webformailier so I do not know if it will work for both the newsletter form and this form I posted above.

I just assumed the webformmailer.php script defined the mailbox to send the submission to.

tomws
Aug 14th, 2009, 09:37 PM
I don't know what the config parameters are since I can't find the source code. It seems to be commonly used on godaddy. Here's one of their help pages on the topic:

http://help.godaddy.com/article/510#webformmailer

royhunters
Aug 14th, 2009, 09:39 PM
Perhaps I need to clarify,

The webformailer is returning the names of the fields but not the information typed into those fields...

It seems like I am missing something in the script that tells webformailer to return the content as well as the fields

noneforit
Aug 14th, 2009, 09:53 PM
You need to make sure the ID's you have called in the PHP script are the same name as the ones in the HTML code

For example:


<input
name="businessname" class="form_1" type="text" />

The ID in the input form element above is 'businessname'

When you look at the PHP, the ID must be the exact same name, such as this:


$businessname = $_POST['businessname'];

If the names dont match exactly then your PHP script will execute but you wont get any of the results back

Edit- If you can show us the PHP code it will make it much easier

royhunters
Aug 14th, 2009, 09:59 PM
Here is the webformailer PHP code and this is where I get over my head. If you guys are able to help me with this, you will have my eternal gratitude!!! :thumbsup:



<?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);
if (count($formhomedir) <= 4) {
$formhome="/home/content/".$formhomedir[1]."/".$formhomedir[2]."/data/";
}
else {
$formhome="/home/content/".$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");

reset($query_vars);
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;
}

reset($query_vars);
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"]."/");
}


?>

royhunters
Aug 14th, 2009, 10:02 PM
Also wanted to mention if you look at the "live page" there is a newsletter submission form on it as well, the PHP DOES return the results of that form.

royhunters
Aug 14th, 2009, 10:08 PM
The more I look at this the more I think there is a problem with godaddy and not the form.

tomws
Aug 14th, 2009, 10:16 PM
Yeah, I'd recommend going back through godaddy's little wizard to see if you come out with what you need.

royhunters
Aug 14th, 2009, 11:42 PM
Thanks Tom,

It turns out is was Godaddy's problem.

I am really glad it was, at lest I pulled this form off first try and that is a BIG milestone for me! Wooo Hooo!

Sorry to bug you guys with this I have added to your reputation on this forum!

jeffinmass
Dec 4th, 2009, 11:04 PM
This program is a parameter filled program generated from godaddy.com. If it is not - you will have to really study and know how this code is functioning and all the options available to you. So, again if you have it generated by godaddy you just reference this in your object that is going to send the form via email as a I think a Third Party application with the <form action="/webformmailer.php" method=post> part of the code pulled into your output html files to be published in the dialog window and ensure the radio button POST is selected then press update you good. Otherwise, it will be all manual. I wish you good luck and please feel free to bounce questions off me - I might be able to help you as I'm doing some modifications myself. Jeff