Jump to content

Juan

New Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by Juan

  1. I'm so sorry guys! 
    I'm having a very hard time on this.

    I saw another code from the internet, tried it out. It's also not sending but it has an error message

    array(5) { ["name"]=> string(6) "qwerty" ["email"]=> string(16) "fordix@gmail.com" ["phone"]=> string(7) "1234567" ["message"]=> string(10) "sadfsdasdf" ["submit"]=> string(0) "" }


    My new code looks like these:
     

    <?php
    var_dump($_POST);
    // Check for empty fields
    if(empty($_POST['name'])  || 
        empty($_POST['phone'])  ||
        empty($_POST['email']))
    {
        $errors .= "\n Error: all fields are required";
    }

    $name = strip_tags(htmlspecialchars($_POST['name']));
    $email = strip_tags(htmlspecialchars($_POST['email']));
    $phone = strip_tags(htmlspecialchars($_POST['phone']));
    $message = strip_tags(htmlspecialchars($_POST['message']));

    // Create the email and send the message
    $to = 'juan@gmail.com'; // Add your email address inbetween the '' replacing yourname@yourdomain.com - This is where the form will send a message to.
    $subject = "Website Contact Form:  $name";
    $text = "You have received a new message from your website contact form.\n\n"."Here are the details:\n\nName: $name\n\nEmail: $email\n\nPhone: $phone\n\nMessage:\n$message";
    $header = "From: info@storgeweddings.com\n"; // This is the email address the generated message will be from. We recommend using something like noreply@yourdomain.com.
    mail($to,$subject,$text,$header);
    header('Location: thank-you');

    ?>

  2. Just from the internet.

    here is the form code:

    <form method="post" name="contactform" id="contact-form" action="contact-form-handler">
              <div class="error-container"></div>
              <div class="row">
                <div class="col-md-4">
                  <div class="form-group">
                    <input name="name" id="name" type="text" class="form-control required input_field" placeholder="Your Name" />
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <input name="email" id="email" type="text" class="form-control validate-email required input_field" placeholder="Email Address" />
                  </div>
                </div>
                <div class="col-md-4">
                  <div class="form-group">
                    <input name="phone" id="phone" type="text" class="form-control validate-phone required input_field" placeholder="Phone Number" />
                  </div>
                </div>
              </div>
              <div class="form-group">
                <label>Message</label>
                <textarea name="message" id="message" class="form-control required" rows="10" placeholder="Your Message"></textarea>
              </div>
              <div class="text-right"><br>
                <button class="btn btn-primary solid blank" name="submit" type="submit">Send Message</button>
              </div>
            </form>

     

  3. Hello everyone!
    Can someone help me regarding with php mail function. The code submits perfectly, but never sends an email. 
    Here is my code:

     

    <?php 
    $errors = '';
    $myemail = 'juandelacruz@gmail.com';//<-----Put Your email address here.
    if(empty($_POST['name'])  || 
        empty($_POST['email']) || 
        empty($_POST['phone']) ||
        empty($_POST['message']))
    {
        $errors .= "\n Error: all fields are required";
    }

    $name = $_POST['name']; 
    $email_address = $_POST['email']; 
    $phone = $_POST['phone'];
    $message = $_POST['message'];

    if (!preg_match(
    "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", 
    $email_address))
    {
        $errors .= "\n Error: Invalid email address";
    }

    if( empty($errors))
    {
        $to = $myemail; 
        $email_subject = "Message from: $name";
        $email_body = "Message from website contact form. ".
        " Here are the details:\n \n     NAME: $name \n 
        EMAIL ADD: $email_address \n 
        PHONE: $phone \n
        MESSAGE: $message";  
        
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html\r\n";
        $headers = "From: $email_address\n";
        //'Reply-To: reply@example.com' . "\r\n" .
        'X-Mailer: PHP/' . phpversion();

        mail($to,$email_subject,$email_body,$headers);
        //redirect to the 'thank you' page
        header('Location: thank-you');

    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html>
    <head>
        <title>Contact form handler</title>
    </head>

    <body>
    <!-- This page is displayed only if there is some error -->
    <?php
    echo nl2br($errors);
    ?>


    </body>
    </html>

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.