Send email using PHP

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 = "[email protected]";
      $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.

Define “Doesn’t work”

Hi,

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

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.

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

Sponsor our Newsletter | Privacy Policy | Terms of Service