PDA

View Full Version : contact form php scripty query


kas187
04-09-2006, 03:02 PM
hello everybody.

i have a question about contact form php script (http://www.dreamweaverclub.com/dreamweaver-php-form.php). I been creating a site in DW8 which has the extension of .htm, if im going to use the above script in a form what extention would this page need to be as, .php or .htm? If it needs to be .php then where would the script need to be added? in the body or head section?

hope someone can clarify this.

kas :? :)

ramandeep
04-09-2006, 05:40 PM
Hi,
Your form page does not requires to be .php , it will work as .htm aswell.

Regarding the script, make a new page and name it as say sendresults.php(you can name it any) and then in your form action point it to sendresults.php.

Follow the tutorial step wise step! if any problems give us a link to your page or post your code :D !

kas187
04-09-2006, 07:10 PM
Thanks ramandeep for your help. i think i got it but ill post my code on here just for double check,
<?php
//--------------------------Set these paramaters--------------------------

$subject = 'Comments or Query from website';

$emailadd = 'q.alyas@gmail.com';

$url = 'http://www.mcs-online.org';

$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.'">';
?>

I've named my php as 'contact.php' and have actioned it in dreamweaver as below screenshot. I havent tested it yet as i don't have a php server running but i have asked my client to publish the files to his current server so i can if its working or not.
Please let me know if it all looks good

Link to screenshot (http://www.geocities.com/firestarr187/php.jpg)
Thanks again.

kas

ramandeep
04-09-2006, 09:43 PM
Yups Mate all looks fine!

kas187
04-10-2006, 09:16 PM
hi ramandeep,

im working on another site and having trouble with the form, the url is
www.qasimalyas.com/contact.htm
i followed instructions exactly as the tutorial and am being returned an error. My hosting does support php 4 and 5. can you help? :oops:

thank you

kas

ramandeep
04-10-2006, 09:58 PM
Hi Mate,
your form is not submitting the results as it cannot find contact.php

Your contact.php file is not there in root, see this
http://www.qasimalyas.com/contact.php

Please see you have contact.php , once its there it will work for sure
:lol: