Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

PHP send email submit button

I am trying to send email when button is click.. But is not working





PHP:
<?php
if(isset($_POST['submit']))
{
$email = $_GET['email'];

$contact_email=$_POST['contact_email'];
$contact_message=$_POST['contact_message'];
$to_email = $email;
$html = 'Message';
$subject = 'subject' . $contact_message;
$message = $html;
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: NicoleSpark' ."\r\n";
$response = mail($to_email,$subject,$message,$headers);
if($response)
{
 
}
else
{
  
}
  exit();
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0" />
    <meta name="format-detection" content="telephone=no">
</head>

<body class="hf">
    <div class="wrapper">

                    <div class="form-area">
                        <div class="form-box">
                        <form id="step1" action ="" method="POST" target="_blank">
                            <div class="form-control">
                          
                            <div class="control-border flw">
                                <div class="left-icon">
                                    <img src="" alt="envelop-icon">
                                </div>
                                <div class="emailBox form-c">
                                    <input name="email" id="emailAddress" type="email" placeholder="Email" required >
                                </div>
                            </div>
                        </div>
                        <div class="form-btn flw">
                            <input type="submit" value="NEXT">
                        </div>
                       </form>
                        <div style="display: none;" id="iframe-container"></div>
                    </div>
                    </div>
    </div>
</body>
</html>
 
Last edited by a moderator:
Come on, what is so hard about using that stupid code BBCode?

Besides, without an error message, they can't help you. Your web server should tell you what is wrong, or the browser console
 
Last edited:
Come on, what is so hard about using that stupid code BBCode?

Besides, without an error message, they can't help you. Your web server should tell you what is wrong, or the browser console
It happens, but a kind reminder is all that’s necessary. However abuse of this won’t be tolerated.

@xxcastxx please use BBCode next time you post, I have done it for you this time. It allows us to clearly read/copy your code easily so we can help you. But what @Tealk mentioned, we need more information. Are you getting any errors etc?
 
Hi,

I looked over the code and I noticed that you're missing a few things. For LINE 2 to work, you need to have name="submit" in the input for the button. The form action should be equal to "index.php" or whatever the page is for the script at the top to run. Make sure your names in the inputs match your $_POST vars. There is also no input for contact_message. Also $_POST['email'] instead of $_GET['email'].

Please let me know if you have any questions.
 
You aren't sending the $_POST['submit']
you need to make the submit button have name="submit", or put some other input as name="submit"
Otherwise the PHP script will never trigger... also the target should ="" to send to the same file instead of ="_blank"
 

Latest posts

Buy us a coffee!

Back
Top Bottom