-1

I have googled and googled this and followed a dozen tutorials and trouble shooting guides and can still not ge the submit button to work. It just opens the php page with no code show. I have run the and it returns the info showing that PHP is installed on the server.

Please can someone help me out with the PHP code and let me know where I have messed up.

<form action="http://www.rexu.co.uk/email_submit.php" method="post">
          <input type="name" value="name" class="form-control" placeholder="Name">
          <input type="email" value="email" class="form-control" placeholder="Email">
          <input type="tel" value="tel" class="form-control" placeholder="Phone">
          <textarea type="message" value="message" class="form-control" placeholder="Message" rows="6"></textarea>
          <input type="submit" name="submit" class="form-control" value="SEND EMAIL">
        </form>



    <?php
if (isset($_POST['submit'])) {
     $to = 'myemail@mysite.com'; // changed for security reason. Have been using my acutal email address
     $subject = 'From Rexu Contact Form';
$message = 'name: ' . $_POST['name'] . "\r\n\r\n";
$message .= 'email: ' . $_POST['email'] . "\r\n\r\n";
$message .= 'tel: ' . $_POST['tel'] . "\r\n\r\n";
$message .= 'message: ' . $_POST['message'];
}
?>

Many Thanks

Rexu
  • 1

3 Answers3

0

You see a blank page, because you never echo any data.

Try echo $message at the end of your if-statement to see, if any data is sent. Or add an else and output an error-message, if isset($_POST['submit']) is false

FelixSFD
  • 6,052
  • 10
  • 43
  • 117
0

If your intention is to send an email, it seems you forgot to do it. You can use mail() function to achieve this.

http://php.net/manual/en/function.mail.php

CJ Nimes
  • 648
  • 7
  • 10
0
    <?php
if (isset($_POST['submit'])) {
     $to = 'myemail@mysite.com'; // changed for security reason. Have been using my acutal email address
     $subject = 'From Rexu Contact Form';
$echo 'name: ' . $_POST['name'] . "\r\n\r\n";
$echo 'email: ' . $_POST['email'] . "\r\n\r\n";
$echo 'tel: ' . $_POST['tel'] . "\r\n\r\n";
$echo 'message: ' . $_POST['message'];
}
?>

try this! Also in our HTML code, the form action... Is it pointing to the correct address check that as well.

prats1411
  • 162
  • 12
  • Thank you all for your help on this. I manged to get the form sending by adding the $to, changing the contact page into a .php and have the success message show about the contact form. – Rexu Dec 24 '15 at 10:02