Send email using PHP


#1

So basically I’ve done this so far and it worked one of the times but then I changed something maybe some quotations and for some reason it just doesn’t wok anymore… Here’s the code:

<?php
    //if "email" variable is filled out, send email
      if (isset($_REQUEST['email']))  {
      
      //Email information
      $admin_email = "nagukatk@naguka.tk";
      $email = $_REQUEST['email'];
      $name = $_REQUEST['name'];
      $message = $_REQUEST['message'];
      
      //send email
      mail($admin_email, "$name", $message, "From:" . $email);
      
      //Email response
      echo "<h2 style='text-align:center;'>Your message has just been sent!</h2>";
      }
      
      //if "email" variable is not filled out, display the form
      else  {
    ?>

    										<form method="post" action="#contact">
    											<div class="field half">
    												<label for="name">Name</label>
    												<input type="text" name="name" id="name" />
    											</div>
    											<div class="field half">
    												<label for="email">Email</label>
    												<input type="email" name="email" id="email" />
    											</div>
    											<div class="field">
    												<label for="message">Message</label>
    												<textarea name="message" id="message" rows="4"></textarea>
    											</div>
    											<ul class="actions">
    												<li><input type="submit" value="Send Message" class="button special" style="background:white;opacity:0.75;" /></li>
    											</ul>
    										</form>
    <?php
      }
    ?>

Can anyone tell me what I’m doing wrong?
PS.: I’m a newie/noob.


#2

Define “Doesn’t work”


#3

Hi,

You have a syntax error, you use “ instead of "
You can check your PHP code here: https://extendsclass.com/php-tester.html


#4

I don’t know that is the specific issue @cyrilfr. The new software on the forum has changed those types of characters based on formatting.


#5

Hi, thanks for the information, I did not know!