0

Here is a PHP script i wrote just so i can get information sent to me from my portfolio. For some reason its not showing the end script echo's. displays a white page and no email is being sent? I looked around and didn't see anything.

    <?php
$name = $_POST['c_name'];
$email = $_POST['c_email'];
$ref = $_POST['c_ref'];
$message = $_POST['c_message'];
$submit = $POST['f_submit'];

$from = 'From: Portfolio';
$to = 'user@email.com';
$subject = 'Website Request';

$body = "Name: $name\n
         Email: $email\n
         Reference: $ref\n
         Message: $message\n";

if ($_POST['f_submit']) {
        if ($name != '' && $email != '') {
                if (mail ($to, $subject, $body, $from)) {
                    echo "Thank you for your quote we will be contacting you within 24 hours!";
                }else{
                    echo "Unfortunatley something went wrong try entering your information one more time.";
                }
        }
}


?>

The HTML:

<form id="job_request" action="assets/php/hire_me.php" method="post">
                            <div class="row">
                                <div class="col-md-6 ">
                                    <div class="form-group">
                                        <input name="c_name" type="text" class="form-control" required="required" placeholder="Name">
                                    </div>
                                </div>
                                <div class="col-md-6">
                                    <div class="form-group">
                                        <input name="c_email" type="text" class="form-control" required="required" placeholder="Email address">
                                    </div>
                                </div>
                            </div>
                              <div class="row">
                                <div class="col-md-6 ">
                                    <div class="form-group">
                                        <input name="c_subject" type="text" class="form-control" required="required" placeholder="Subject">
                                    </div>
                                </div>
                                <div class="col-md-6 ">
                                    <div class="form-group">
                                        <input nae="c_ref" type="text" class="form-control"  placeholder="Ref. (IF any)">
                                    </div>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-12 ">
                                    <div class="form-group">
                                        <textarea name="c_message" id="message" required class="form-control" rows="3"  placeholder="Message"></textarea>
                                    </div>
                                    <div class="form-group">
                                        <button name="f_submit" type="submit" class="btn btn-primary">Submit Request</button>
Ted Goas
  • 7,051
  • 1
  • 35
  • 42
Miessau
  • 21
  • 5
  • Unfortunately the error reporting is on. Not showing me anything. – Miessau Jun 22 '16 at 19:48
  • I would echo out $_POST['f_submit'] before the if statement to see what that is returning. Same with $name and $email just to be sure. Right now if any of those are blank, you would get a blank page. – cngodles Jun 22 '16 at 19:50

1 Answers1

0

I'm assuming you're getting a white page when hitting refresh on a webpage?

you're missing the underscore on line 6 for

$submit = $POST['f_submit'];

it should be

$submit = $_POST['f_submit'];

Secondly, that line will only print if something goes wrong with mail, not if name/email is blank. That doesn't seem like the right behavior; it should be if basic requirements to send an email don't work, right? So perhaps something more like this:

if ($_POST['f_submit']) {
    if ($name != '' && $email != '') {
        if (mail ($to, $subject, $body, $from)) {
            echo "Thank you for your quote we will be contacting you within 24 hours!";
        else { 
            //DECIDE IF YOU WANT TO DO ANYTHING HERE
        }
    } 
    else {
        echo "Unfortunatley something went wrong try entering your information one more time.";
    }
}
Charlene Barina
  • 187
  • 1
  • 11
  • Im actually getting the white page after submitting the form. And the database is still not having any inserts – Miessau Jun 22 '16 at 20:16
  • None of the code you provided references any inserts, so can't check that. If you want help with that, you need to edit your question and show that code. – Charlene Barina Jun 22 '16 at 20:21