0

I've spent some time trying to figure out a way to allow users to contact me via my landing page. Being fairly new to programming and having used snippets of code from multiple sources I am at my wits end and would love some help. My troubleshooting has centered around:

I. Did I setup my local server correctly?

And if so, am I missing a package on WAMP and/or mail server? I referenced php mail setup in xampp this post.

Wamp.NET Manager

Browser URL

II. Is my HTML code faulty?

      <div class="container-contact100-form-btn">
        <button type="submit" value="Send" class="contact100-form-btn">
           Send Message
        </button>
      </div>

III. Am I needing to edit/adjust my JS file to accommodate the additional functionality?

function showValidate(input) {
    var thisAlert = $(input).parent();

    $(thisAlert).addClass('alert-validate');

    $(thisAlert).append('<span class="btn-hide-validate">&#xf136;</span>')
    $('.btn-hide-validate').each(function(){
        $(this).on('click',function(){
           hideValidate(this);
        });
    });
}

function hideValidate(input) {
    var thisAlert = $(input).parent();
    $(thisAlert).removeClass('alert-validate');
    $(thisAlert).find('.btn-hide-validate').remove();
}

IV. Is something missing from the PHP code?

<?php
if( isset($_POST['Send Message'])) 

$name = $_POST['name'];
$email = $_POST['email'];
$bar = $_POST['bar'];
$message = $_POST['message'];

$email_from = $email;
$email_subject = "New Contact Us Email";
$email_body = "You have received a new message from the user $name.\n".
    "Here's the message: \n $message".

$to = 'I had my email here';

mail($to, $email_subject, $email_body)

?>

I really would appreciate any help and/or links that might lead me down the right path. Thank you!

ibredfish
  • 131
  • 1
  • 6
  • 2
    I don't see any mailing function. – Funk Forty Niner Jul 21 '18 at 02:53
  • 2
    I also see that you're not using the right protocol neither. – Funk Forty Niner Jul 21 '18 at 02:53
  • @FunkFortyNiner this also might be a cause of the error: `if(!isset($_POST['Send Message']))`. What is 'Send message' referring to? I don't see a field with that `name`. Also it should be `if( isset( ) )` and not `!isset()`. – Ivan86 Jul 21 '18 at 02:56
  • @Ivan86 If the OP is accessing it using the `file:///` protocol it doesn't matter what PHP you have. It's not going to be executed. – Mike Jul 21 '18 at 02:58
  • @Mike I agree. When he fixes that, he still faces the problem of why `if(!isset($_POST['Send Message']))`. There are no curly braces to that either so the `if` only applies to setting `$name = $_POST['name'];`. – Ivan86 Jul 21 '18 at 03:00
  • @FunkFortyNiner I meant to say: in addition to the problems you outlined, there are also other problems with the code. – Ivan86 Jul 21 '18 at 03:07
  • @FunkFortyNiner thank you! I added the mailing function and am looking up 'protocols' now on http://php.net/manual/en/function.mail.php. – ibredfish Jul 21 '18 at 04:13
  • @Mike thank you. I'm not sure what you mean by OP using file:///. Should it be pointed at C:/Wamp or /Wamp.Net alone? – ibredfish Jul 21 '18 at 04:22
  • 1
    @Jason Websites need to be accessed by http or https protocols and their hostnames, not by the path to the files on your file system. For a locally installed web server that would mean `http://localhost` or `https://localhost` if you have SSL enabled. – Mike Jul 21 '18 at 04:58

0 Answers0