PDA

View Full Version : email form problem


sedah
07-07-2009, 06:53 PM
hey guys, this is a problem im having with my form...when i tested it out, it all works out and sends to my email but Im receiving 2 of them, any reason why?

this is the form, any help please thanks

<?php

/* Subject and Email Variables */

$emailSubject = 'DeathNoteOnlineTv';
$webMaster = 'avmedia@deathnoteonlinetv.com';

/* Gathering Data Variables */

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$numberField = $_POST['number'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Addition answer: $number <br>
Comments: $comments
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);

?>

edbr
07-08-2009, 05:05 AM
no this is the mail sender, the form supplies the post fields . the code you quote will nly send 1 time but it is a possibilitie the info is being submitted twice, is the action to Server_[PHP_SELF] maybe?

sedah
07-08-2009, 05:23 AM
no this is the mail sender, the form supplies the post fields . the code you quote will nly send 1 time but it is a possibilitie the info is being submitted twice, is the action to Server_[PHP_SELF] maybe?

yea mail sender i meant. thnx for the correction hehe, <===noob

but yea, i tested it out all the time and its sendin me 2 forms, one thats actually filled out and another thats completely blank

edbr
07-08-2009, 05:34 AM
then 1 is fired (so to speak as you load the page , then again when you submit the form i would think
try this

<?php
if(isset($_POST['Submit'])) {
/* Subject and Email Variables */

$emailSubject = 'DeathNoteOnlineTv';
$webMaster = 'avmedia@deathnoteonlinetv.com';

/* Gathering Data Variables */

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$numberField = $_POST['number'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Addition answer: $number <br>
Comments: $comments
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
}
?>
that might do it

sedah
07-08-2009, 08:00 AM
then 1 is fired (so to speak as you load the page , then again when you submit the form i would think
try this

<?php
if(isset($_POST['Submit'])) {
/* Subject and Email Variables */

$emailSubject = 'DeathNoteOnlineTv';
$webMaster = 'avmedia@deathnoteonlinetv.com';

/* Gathering Data Variables */

$emailField = $_POST['email'];
$nameField = $_POST['name'];
$numberField = $_POST['number'];
$commentsField = $_POST['comments'];

$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Addition answer: $number <br>
Comments: $comments
EOD;

$headers = "From: $email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
}
?>that might do it


o man! thanks, ur awesome! :mrgreen: its works, only gettin 1 now :-D

gigiloumill
07-09-2009, 12:07 AM
I have a similar script that sends to my e-mail which works perfect. My question is, is there a similar script that would send to a database. I have a phpmyadmin db configured and a form but I am having the worst time trying to send to it. Any suggestions? thanks

DWcourse
07-09-2009, 12:24 AM
I use Forms to Go (http://www.bebosoft.com/products/formstogo/) from Bebosoft to generate my form scripts. Lots of customization and options (including write to database) but it costs $30.

edbr
07-09-2009, 12:41 AM
My question is, is there a similar script that would send to a database.
you are looking for a insert statement, i am not sure there is a script available but there could be its not such a difficult thing to do. be careful of these generic scripts as many have security problems so yahoogle for that before using any.
Best option is to follow a course it will be better and not so hard , check out the tutorials in the section on this forum there is a section on inserting into a database.

gigiloumill
07-09-2009, 01:08 AM
Ok, I got it. However, the text does not appear in the table. The form goes, the script works but it never gets to the table. The db is configured and so is the recordset. Any suggestions?

edbr
07-09-2009, 01:13 AM
only to test step by step. try setting up a submit form and an insert 'action ' page and see if that works on its own. if that inserts data then post back here

gigiloumill
07-09-2009, 01:33 AM
That's exactly what i did. I did an "Action" form which I see firing but no data in the text.

gigiloumill
07-09-2009, 01:34 AM
Table rather. sorry.

edbr
07-09-2009, 02:02 AM
post your code , for the form and the insert statement

gigiloumill
07-09-2009, 10:56 AM
form:
<form action="sendform.php" method="post" name="form1" id="form1">
<table width="240" border="0">
<tr>
<th width="86" scope="col">name</th>
<th width="144" scope="col"><input type="text" name="name" id="fname" /></th>
</tr>
<tr>
<th scope="col">e-mail</th>
<th scope="col"><input type="text" name="email" id="email" /></th>
</tr>
<tr>
<th scope="col">last name</th>
<th scope="col"><input type="text" name="lname" id="lname" /></th>
</tr>
<tr>
<th scope="col">&nbsp;</th>
<th scope="col"><input type="submit" name="submit" id="submit" value="Submit" /></th>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_free_result($db);
?>

insert:

<?php
$host="localhost";
$user="root";
$pass="password";
mysql_connect($host,$user,$pass);

if($submit)
{
mysql_select_db("db");
$result=MYSQL_QUERY("INSERT INTO new (name,email)" . "VALUES ('$name','$email')");
print "$name was added";
}
?>

edbr
07-10-2009, 12:52 AM
the values from your form will be $_POST['email'] and $_POST['lname'] $_POST['fname']
your insert is using $name and $email

try this

<?php
$host="localhost";
$user="root";
$pass="password";
mysql_connect($host,$user,$pass);

$name= $_POST['fname'].$_POST['lname'] ;
$email=$_POST['email'];

if($submit)
{
mysql_select_db("db");
$result=MYSQL_QUERY("INSERT INTO new (name,email) VALUES ('$name','$email')");
print "$name was added";
}
?>

gigiloumill
07-10-2009, 11:25 AM
Thanks e, but it still doesn't work.

edbr
07-11-2009, 04:29 AM
ok lets try this then to de-bug

<?php
$host="localhost";
$user="root";
$pass="password";
mysql_connect($host,$user,$pass);

$name=$_POST['fname'].$_POST['lname'] ;
$email=$_POST['email'];

echo $_POST['email'];

echo $_POST['fname'].$_POST['lname'];


if(isset($_POST['Submit'])) {
$query="INSERT INTO new (name,email) VALUES ('$name','$email')");
$result = mysql_query($query)or die (mysql_error());
}
?>