Grow your CSS skills. Land your dream job.

Whats is wrong?

  • # April 2, 2012 at 8:18 pm

    Can anyone tell me what is wrong with my coding?

    < ?php
    $errors = '';
    $myemail = 'xxxxxx@xxxx.com';
    }

    $campaign = $_POST;
    $page = $_POST;
    $line = $_POST;
    $quantity = $_POST;
    $price = $_POST;
    $email_address = $_POST;
    $tel = $_POST;
    $name = $POST;

    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 = "Order form submission for: $name";
    $email_body = "You have received a new message. ".
    " Here are the details:n Name: $name n Email: $email_address n Tel: $tell n Campaign: $campaign n Page: $page n Line:$line n Quantity: $quantity n Price: $price";

    $headers = "From: $myemailn";
    $headers .= "Reply-To: $email_address";

    mail($to,$email_subject,$email_body,$headers);
    //redirect to the 'thank you' page
    header('Location: contact-form-thank-you.html');
    }
    ?>
    < !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">







    < ?php
    echo nl2br($errors);
    ?>



    # April 2, 2012 at 9:08 pm

    Fourth line has a closing bracket but there’s no opening bracket……?
    $email_subject should have $name outside the quotes?
    $email_body should have various variables outside the qoutes?

    Same with $headers….?

    __
    # April 2, 2012 at 9:19 pm

    @Senff (edited):
    He’s using double-quotes. The variables will be parsed and expanded.


    @ricky122892 (original post):

    Do you really want a full assessment? Or do you have a specific problem that you’re asking about?

    < ?php
    $errors = '';
    $myemail = 'xxxxxx@xxxx.com';
    } // < ---extraneous curly brace

    $campaign = $_POST;
    $page = $_POST;
    $line = $_POST;
    $quantity = $_POST;
    $price = $_POST;
    $email_address = $_POST;
    $tel = $_POST;
    $name = $POST;

    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";
    }
    // your regex will reject some valid email addresses

    if( empty($errors))
    {
    $to = $myemail;
    $email_subject = "Order form submission for: $name";
    $email_body = "You have received a new message. ".
    " Here are the details:n Name: $name n Email: $email_address n Tel: $tell n Campaign: $campaign n Page: $page n Line:$line n Quantity: $quantity n Price: $price";
    // $tell is not defined (maybe you meant $tel ?)

    $headers = "From: $myemailn"; // < --- newline in email headers must be rn
    $headers .= "Reply-To: $email_address"; // < --- no newline at all

    mail($to,$email_subject,$email_body,$headers);

    header('Location: contact-form-thank-you.html');
    // not a valid HTTP header ("Location" headers must be a fully-qualified URL)
    // it's also a good idea to exit after redirecting,
    // so your script doesn't continue execution
    }
    ?>
    < !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">







    < ?php
    echo nl2br($errors);
    ?>



    # April 2, 2012 at 9:39 pm

    Doh, of course. I’m so used to single quotes now. :-/

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".