Jump to content

php form info submited to email


Kenny

Recommended Posts

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
Link to comment
Share on other sites

  • 4 weeks later...

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...