Jump to content

Recommended Posts

Posted (edited)

when submiting info from a php form I built, what would cause 2 emails to be sent one with info and one with out info.

Edited by Kenny
Posted (edited)

Here is my code.

 

 

name

 

 

email

 

 

 

 

 

<?php

$name = $_POST['name'];

$email = $_POST['email'];

$email_message = "name:{$name} with a email of:{$email}";

mail('kennyfeldman@juno.com','form response',$email_message);

?>

Edited by Kenny
  • 4 weeks later...
Posted

I called the hosting company and thay seid thair system is working with out any problems. So I did some more Testing and found that is happing in when ever some visits the page with the form on it, with out even touching the form. It shots me a blank email. Can any look at my code and see what is doing this? Thank you.

Posted (edited)

There is no conditional checking to see if the Form has been submitted, so as soon as the page is entered, it would send an Email (empty, of course) and then another completed one on Form submission.

Try this:

>
if ( isset($_POST['submitted']) ) { // conditional to check for form submission

$name = $_POST['name'];
$email = $_POST['email'];
$email_message = "name:{$name} with a email of:{$email}";
mail('kennyfeldman@juno.com','form response',$email_message);

}
?>

</pre>
<form id="form1" name="form2" method="post" action="form.php">


name





email










</form>

Added a hidden input that determines the form submission and the conditional for checking is to send the email only when the submit is made.

Next you should work on checking to confirm that proper data is submitted and Security code for 'bad input'. That will be the next step.

See if this code does what you want and then we can move forward.

Edited by jlhaslip

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...