PDA

View Full Version : Submit Form Results -- No Email!!! HEELLLLPP!


aestronza
07-05-2006, 03:48 AM
Okay, here's the deal ... :?

I am trying to get a submit form to work. I followed the awesome instructions found here on DW Club http://www.dreamweaverclub.com/dreamweaver-php-form.php

I followed the instructions to the "T." I have my php file, created a Thank you Page to come up after "submit" was clicked and everything! Worked like a charm ... the downside of this story is ... I didn't get the results via email as I put in the code. I even checked it twice!!! HEEEEEEEEEELP!!!!

Here's the PHP code:

<?php
//--------------------------Set these paramaters--------------------------


$subject = 'Results from Contact form';


$emailadd = 'aestronza@digitaldesignspro.com';


$url = 'thankyou.htm';


$req = '0';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

aestronza
07-05-2006, 03:51 AM
BTW ... I forgot to mention, I'm using DW MX 2004!

Creative Insanity
07-05-2006, 06:53 AM
If you are doing this locally on your system THEN IT WILL NOT WORK! It requires either an email server or sendmail from linux server. Upload to hoster and it will work.

It really stuns me that people do not think of what is really required before they try something.
You cannot bake a cake without an oven.

moondog
07-11-2006, 06:05 PM
I'm new at this all and I have no idea where the PHP code is supposed to go.

also, what program do I use to save the file to .PHP format?

It's okay to call me stupid, but I'd prefer if you didn't out loud!

Ricky55
07-11-2006, 08:52 PM
i agree don't call him stupid this is one of the hardest things to setup.

Use notepad and save with the extension .php

Ricky55
07-11-2006, 08:55 PM
btw

i really struggled to get my first form working but I found a really easy to use cgi script that is really easy to use if your server can use these I'll email you it if you want and explain how to set it up.

check and see if you can use this type of script your server most support perl.

Thanks

Ricky55

Creative Insanity
07-11-2006, 09:12 PM
Further note on Rick's first comment.
There is a better option that notepad and that is win32pad.
Displays in a nicer manner and you can have line numbers which is very good for bug fixing. It is free and you can fine it here (http://www.free2u.org/freeware/business_and_productivity/word_processing/text_editors/win32pad.html)
Very small file. ;)

Another good option which supports MANY scripting languages and also has colour line coding is CONtext (http://www.context.cx/) This is also freeware.

moondog
07-12-2006, 05:00 PM
Okay, I downloaded win32pad and saved the file. Now if I understand the tutorial correctly, I'm supposed to put that .php file in the same place the rest of the pages are located or somewhere on the web and have the ACTION point to that .php file?

Ricky55
07-13-2006, 01:05 PM
you need to check with your host they will tell you where you need to save the script.

You may also need to alter the permissions of the script once its on the server. This can be done in dreamweaver though. Just view remote files right click on the file and select permissions. Usually these need to be set so you can write to them and execute them.

The form in your dreamweaver document will point to the script, in the action section, it will read somthing like

http://www.domain/cgi-bin/script name.cgi

your location will change depending on what your host tells you / what type of script you are using.

If you go onto your hosts website they should have a help section all about forms and scripts.

Ricky55

ramandeep
07-13-2006, 01:38 PM
ok if you are using the php script, it has a very simple concept .

Make your form, it doesnt matter if it has 1 or 10 fields.
The "Action" (in form properties) tells where to go when you press the submit button of your form.
So in your Form Action give the path where you saved your PHP file (it can be located anywhere as far as the given path is correct)
example
http://www.yourdomain.com/files/sendresults.php
or
/files/sendresults.php


---------------------------------------------------------------------------
Here you need to understand what Relative and Absolute paths are
Absolute Path:
http://www.yourdomain.com/images/dw.gif
Relative Path:
images/dw.gif
----------------------------------------------------------------------------


once you give the right path to the PHP file in form action it works like a charm.

Also do read Points to remember: at the end of the tutorial.

moondog
07-14-2006, 04:24 PM
I use godaddy to host a page for a local genealogy society. I have a page for queries and research and put a form there using information gained here. I set it up so that when you click the submit button it should take you to a page that says your request has been sent. However when I click the submit button I get the following error.

HTTP Error 405 - The HTTP verb used to access this page is not allowed. Internet Information Services (IIS)

My code used was

<?php
//--------------------------Set these paramaters--------------------------

// Subject of email sent to you.
$subject = 'Query from Contact form';

// Your email address. This is where the form information will be sent.
$emailadd = 'mygladwingenealogy@yahoo.com';

// Where to redirect after form is processed.
$url = 'http://www.gladwingenealogyqueries@yahoo.com/formsent.htm ';

// 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 = '1';

// --------------------------Do not edit below this line--------------------------
$text = "Results from form:\n\n";
$space = ' ';
$line = '
';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>

Any Ideas why it's not working right?

Thanks alot guys!

ramandeep
07-14-2006, 07:35 PM
IIS...? are you on Windows hosting plan? if yes then there is no PHP support on there windows plans.

and if you are on Linux hosting plan then post the link to your form page.

moondog
07-14-2006, 11:52 PM
that means I can't use the PHP form ..... so then back to the reason I got into this question in this forum .... how do I set up a form similar to the PHP one that this tutorial had?