-1

Soi tried creating a php form and it seems not to be working, it is not sending and no action is occuring. the code below is that if the HTML

<form id="form" class="vbottom-desktop grid default-form no-spacing lined-form mb-xl" action="php\mail.php" method="post">
                <div class="col-2">
                  <input required type="text" placeholder="Name" name="name" class="form-control">
                </div>
                <div class="col-2">
                  <input required type="email" placeholder="Email address" name="email" class="form-control">
                </div>
                <div class="col-2">
                  <textarea required placeholder="Message" name="message" class="small form-control"></textarea>
                </div>
                <div class="col-2">
                  <input id="send" type="submit" value="Send" class="btn btn-primary">
                </div>
              </form>

and below this is that of the php

<?php
$subject    = 'You have received this businessmail from'; 
$to         = 'okonodestine99@gmail.com'; 
$headers    = 'MIME-Version: 1.0' . "\r\n" .
              'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message    = '';

if (!empty($_POST["name"])) {
  $message .= 'Name: ' . $_POST['name'] . ' <br/>';
}
if (!empty($_POST["email"])) {
  $message .= 'Email: ' . $_POST['email'] . ' <br/>';
}
if (!empty($_POST["phone"])) {
  $message .= 'Phone: ' . $_POST['phone'] . ' <br/>';
}
if (!empty($_POST["website"])) {
  $message .= 'Website: ' . $_POST['website'] . ' <br/>';
}
if (!empty($_POST["message"])) {
  $message .= 'Message: ' . $_POST['message'] . ' <br/>';
}

if (@mail($to, $subject, $message, $headers))
{
  echo 'sent';
}
else
{
  echo 'failed';
}
?>

any possible solution to this would be highly appreciated

1 Answers1

0

you should use slash not backslash in url! try this:

<form id="form" class="vbottom-desktop grid default-form no-spacing lined-form mb-xl" action="php/mail.php" method="post">
                <div class="col-2">
                  <input required type="text" placeholder="Name" name="name" class="form-control">
                </div>
                <div class="col-2">
                  <input required type="email" placeholder="Email address" name="email" class="form-control">
                </div>
                <div class="col-2">
                  <textarea required placeholder="Message" name="message" class="small form-control"></textarea>
                </div>
                <div class="col-2">
                  <input id="send" type="submit" value="Send" class="btn btn-primary">
                </div>
              </form>

and make sure you put files like this:

root
|-- yourform.html(or .php whatever is that you're using)
|-- php
    |-- mail.php