Forum Moderators: coopster

Message Too Old, No Replies

interesting form problem for the experts...

strange or maybe not..?

         

kumarsena

6:19 pm on Oct 17, 2004 (gmt 0)

10+ Year Member



hey,

i got a eamail form on a page and then antoher mailinglist form as well. each form calls different scripts, so...

i go to this page and then ignore the mail form but fill in the mailing list form. then i press submit but it is running the mail form script instead!

ive checked the scripts and the forms, and there is no clash in form element name as i can see.

anyone ever encountered this problme?

k

kumarsena

6:20 pm on Oct 17, 2004 (gmt 0)

10+ Year Member



an yes, there are two buttons calling two different scripts.

dreamcatcher

8:01 pm on Oct 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think this is a hard one unless we see your exact code. It does sound like the form tags are in place wrong or the form action is wrong. Have you got a form within a form?

kumarsena

9:03 pm on Oct 17, 2004 (gmt 0)

10+ Year Member



the code...

this one is included into the main body..

<form method="post" enctype="multipart/form-data" action="scripts/send_mail.php">

<table>

<tr>
<td>Name: </td><td align="right"><input type=text name="name">
</tr>

<tr>
<td>E-Mail: </td><td align="right"><input type=text name="email">
</tr>
<tr>
<td>Subject: </td><td align="right"><input type=text name="subject">
</tr>

<tr>
<td>Send To: </td><td align="right"><select name="sendto"size=1>
<option>[Sasi]Kumar
<option>Wolfheart
</select>

</tr>

<tr>
<td>Comments: </td>
</tr>

<tr>
<td colspan=2 align="right"><textarea cols=28 rows=4 name="messege"></textarea>
</tr>

<tr>
<td colspan=2 align="right"><input type="submit" value="submit">
</tr>

</table>

<!------------------------------------------------------------------------->

while this is part of the index.php(where the above is included) inside a seperate div:

<div class="sidebox">
<p>
<strong>MAILING LIST</strong>
<br /> Be notified of updates. Your privacy will not be compromised.
<form method="POST" action="scripts/mail_list.php">
<input type="text" name="add" size="10"><br /> <br />
<input type="submit" value="Submit">

</form>
</p>
</div>

as you can see they call a seprate script, so why the mailing list button triggers the email script is beyond me...

i searched on google and saw seeral people with similar problem, but no solution..

k

kumarsena

9:10 pm on Oct 17, 2004 (gmt 0)

10+ Year Member



this mailing list code

<?php
//thanks to jatar_k at webmasterworld.com php forum
$emailpattern = '^([._a-zA-Z0-9-]){2,255}@([._a-zA-Z0-9-]){2,255}\.([.a-zA-Z]){2,7}$';

if (!isset($_POST['add']) ¦¦ empty($_POST['add']))
{
echo 'HA! HA! very funny, now ENTER an address befdore you submit, moron!';
}

else if (!ereg($emailpattern, $_POST['add']))
{
echo 'Is it so hard to proviude a proper address....?';
}

else
{
$add = $_POST['add'];
$fh = fopen('adds.php', 'a');
fwrite($fh, $add);
fclose($fh);
echo 'Thank You for signing up to the list. you will get regular updates.';

}
?>


and this is the email script


<?php

if ( empty($_POST['name']) ¦¦ empty($_POST['email']) ¦¦ empty($_POST['messege']) ¦¦ empty($_POST['subject']))
{
echo 'Please fill in all fields';
exit();
}

else
{
//thanks to jatar_k at webmasterworld.com php forum
$emailpattern = '^([._a-zA-Z0-9-]){2,255}@([._a-zA-Z0-9-]){2,255}\.([.a-zA-Z]){2,7}$';

if (!ereg($emailpattern, $_POST['email']))
{
echo 'Is it so hard to proviude a proper address....?';
exit();
}

else
{
$name = $_POST['name'];
$email = $_POST['email'];
$messege = $_POST['messege'];
$subject = $_POST['subject'];

//send mail
$mail = mail('kumsi1980@yahoo.co.uk', $subject, $messege, "From: $name, $email");

if($mail)
{
echo 'Your messege has been sent';
}

else
{
echo 'An error occured within the sendmail program. Please go back and try again';
}

}
}
?>

sonjay

1:01 am on Oct 18, 2004 (gmt 0)

10+ Year Member



I don't see a closing </form> tag at the end of your first form. This would cause the problem you describe.

dreamcatcher

9:11 am on Oct 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, well spotted sonjay, that will indeed cause the problem. The first form action will close with the same tag as the second.

kumarsena

1:07 pm on Oct 18, 2004 (gmt 0)

10+ Year Member



i love u guys....great, works fine...

thanks alot!
kumar