-1

I made a website recently for a friend. They needed a form or something so I coded the page for them. today another friend asked me to make a similar website with a form. So i just copied and pasted the code from one website to the other. But as soon as I did, the form stopped sending to the email. This is the code I am using:

<?php
$to = 'commodorePicmin@gmail.com';
$subject = 'JOB REQUEST';

$name = $_POST['name'];
$address = $_POST['address'];
$job = $_POST['job'];

$message = <<<EMAIL
Hi, my ign is $name. I want the rank $address and I would be good at this because: $job

EMAIL;
$header = '$name';

if($_POST){
mail($to, $subject, $message, $header);
}
?>

<html>
 <head>
  <link rel="stylesheet" href="style.css">
 </head>
  <body>
   <div class="wrapper">
    <div class="header">
     <center> 
      Apply for staff
     </center>
   </div>
<div id="menu">
 <ul>
  <center>
  <li><a href="index.html">HOME</a></li>
  <li><a href="stafflist.html">STAFF</a></li>
  <li><a href="contact.html">CONTACT</a></li>
  <li><a href="apply.php">APPLY</a></li>
  <li><a href="donate.html">DONATE</a></li>
  </center>
 </ul>
</div><br>
<div class="info">
<center>Want a way to get a fast in game $1,000 Click <a href="info.php">Here</a></center>

   <center><form action="?" method="post">
    <ul>
     <li>
      <label for="name">In game name</label><br>
      <input type="text" name="name" id="name" /><br>
     </li>
     <li>
      <label for="name">Rank that I am Applying for</label><br>
      <select>
       <option value="Admin">Admin</option>
       <option value="HeadMod">Head Mod</option>
       <option value="HeadAdmin">Head Admin</option>
       <option value="Builder">Builder</option>
       <option value="Mod">Mod</option>
       <option value="helper">Helper</option>
       <option value="coowner">Co-Owner</option>
      </select><br>
     </li>
     <li>
      <label for="name">Why Would you be a good fit?</label><br>
      <textarea rows="9" cols="50" name="job" id="job"></textarea>
      </li>
     <li>
      <input type="submit" name="Submit" id="submit" value="submit">
     </li>
    </ul>
   </form></center>
   </div>
  </div>
  </body>
</html>
If you need anything else to answer this question feel free to ask
blurfus
  • 13,485
  • 8
  • 55
  • 61
Can Colsto
  • 11
  • 4
  • Possible duplicate of [PHP mail form doesn't complete sending e-mail](http://stackoverflow.com/questions/24644436/php-mail-form-doesnt-complete-sending-e-mail) – Christian Gollhardt Jun 02 '16 at 03:33

2 Answers2

0

try putting a

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">

inside the action of your form. This will ensure that the form posts back to itself.

Nebri
  • 773
  • 2
  • 8
  • 21
  • Where exactly are you telling me to put this? Like in the place where i currently have action="?" – Can Colsto Jun 02 '16 at 02:29
  • have you verified that a mailer is available on the web server you are running this code on? you may need additional code in order to send out an email. I'd recommend utilizing PHPMailer, instantiate it against a remote SMTP server to accomplish the same thing. https://github.com/PHPMailer/PHPMailer – Nebri Jun 02 '16 at 02:55
0

Some server will not accept the default mail from their server. You just try mail with SMTP settings.

Mani
  • 2,675
  • 2
  • 20
  • 42