PDA

View Full Version : Dreamweaver Club PHP Form - Help please!


Martakeithy
03-03-2011, 01:12 PM
Hi everyone,
I do apologise for posting about this form again, I see it crops up on a regular basis. I did check archives, but couldn't find a solution so I hope you don't mind me posting about this.

I have created a similar form to the one given in the php tutorial here http://www.dreamweaverclub.com/dreamweaver-php-form.php

I have uploaded the form page and the confirmation page to my server, which does support PHP. When I go to the form page, it flashes up for an instant and then goes straight to the confirmation page without allowing any data to be input to the form.
It is as if the submit button is being bypassed? An empty email is being generated and sent.
I have pasted the code below. Could anyone help me get this form up and running.
Thanks in advance
Maisie :smile:


MY CODE BELOW

<form action="http://www.thewholeshebag.com/Confirmation.php" method="post" name="Contact form" id="Contact form">
<p>
<label for="name">Name</label>
<input type="text" name="name" id="name" accesskey="b" tabindex="1" />
</p>
<p>
<label for="Email">Email</label>
<input type="text" name="Email" id="Email" accesskey="b" tabindex="2" />
</p>
<p>
<label for="Query">Query</label>
<textarea name="Query" id="Query" cols="45" rows="5" accesskey="c" tabindex="3"></textarea>
</p>
<p>
<label for="submit"></label>
<input type="submit" name="submit" id="submit" value="Submit" accesskey="c" tabindex="3" />
</p>
</form>
<?php
//--------------------------Set these paramaters--------------------------

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

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

// Where to redirect after form is processed.
$url = 'http://www.thewholeshebag.com/Confirmation.php';

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

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

domedia
03-03-2011, 01:30 PM
Two separate files

Martakeithy
03-03-2011, 08:34 PM
Hi there,
what's the best way to combine the two files so that the data from the form is actually retrieved?
Thanks:-)

edbr
03-04-2011, 01:04 AM
i would suggest changing the action of the form make it relative
Confirmation.php

second there is a condition making the posts only 20 characters increase it if you still arent getting mail we can start again