2

I have a simple form for users to sign up to e-mail updates. The HTML code on the page is as follows:

<form id='send.php' method='post'>
    <input type="email" name="emailaddress" placeholder="Your e-mail address"/>
    <input type="submit" name="submit" value="Submit">
</form>

The contents of send.php is as follows:

<?php

if($_POST["submit"]) {
    $recipient="[email protected]";
    $subject="Email address for updates";
    $sender=$_POST["emailaddress"];
    $senderEmail=$_POST["emailaddress"];
    $message=$_POST["emailaddress"];

    $mailBody="$message";

    mail($recipient, $subject, $mailBody,"From: $sender");
}

?>

If I test this, it does not work. The mailbox where these emails should be sent works fine and there are no emails in the spam folder, so I don't know what is wrong.

I am indeed a beginner with HTML and PHP.

Thanks for any help.

2
  • 2
    Sometimes mail() function do not work , check with your hosting website. Or if you want to be sure , echo those variable out and see if you have the correct value Commented Apr 27, 2014 at 9:37
  • @PoomrokcThe3years what you are saying is very true Commented Apr 27, 2014 at 9:40

1 Answer 1

3

I did not look much on your php but I sported some mistakes on the html code so First change this

<form id='send.php' method='post'>
    <input type="email" name="emailaddress" placeholder="Your e-mail address"/>
    <input type="submit" name="submit" value="Submit">
</form>

 To


<form id ="myform" action="send.php" method="post">
    <input type="email" name="emailaddress" placeholder="Your e-mail address"/>
    <input type="submit" name="submit" value="Submit">
</form>
Sign up to request clarification or add additional context in comments.

3 Comments

GENIUS!! how did I miss that . I award you "Eagle eye" Badge Xb
Am so glad that you appreciated but all of us junior and seniors we can be caught in such a situation where by you can forget simple things like that .
@humphrey Thank you so much! It was just that id/action mistake you picked up. It woks perfectly now, thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.