• ming725

    (@ming725)


    Hi, Im working on a html form n trying to put a php action which will send me the result to my email n auto reload. Luckly, the form action work but the action php dun send me any result to my email. I’m wondering the php is different with wp php. Ive been through many forums n tutorials which get me even confused. This is the last bit of my first wp site. heres the form action php code below, please help. many thanks.

    <?php
    
    /* Subject and Email Variables */
    
    	$emailSubject = 'website_message';
    	$webMaster = 'mymail@hotmail.com';
    
    /* Gathering Data Variables */
    
    	$namefield = $_POST['name'];
    	$emailfield = $_POST['email'];
    	$telfield = $_POST['phone'];
    	$bookingfield = $_POST['checkbox'];
    	$datefield = $_POST['date'];
    	$monthfield = $_POST['month'];
    	$hourfield = $_POST['hour'];
    	$minfield = $_POST['mins'];
    	$ampmfield = $_POST['ampm'];
    	$headfield = $_POST['people'];
    	$commentfield = $_POST['comment'];
    
    	$body = <<<EOD
    <br><hr><br>
    Name: $namefield <br>
    Email: $emailfield <br>
    Phone: $telfield <br>
    Booking: $bookingfield <br>
    Date: $datefield <br>
    Month: $monthfield <br>
    Hour: $hourfield <br>
    mins: $minfield <br>
    Am/Pm: $ampmfield <br>
    Number of people: $headfield <br>
    Message: $commentfield <br>
    EOD;
    
    	$headers = "From: $email\r\n";
    	$headers .= "Content-type: text/html\r\n";
    	$success = mail($webMaster, $emailSubject, $body, $headers);
    
    /* Results rendered as HTML */
    
    	$theResults = <<<EOD
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <META HTTP-EQUIV="Refresh" CONTENT="10; URL=http://localhost:8888/">
    <style type="text/css">
    <!--
    * {
    	margin-top: 20px;
    	margin-right: 0px;
    	margin-bottom: 0px;
    	margin-left: 0px;
    }
    body {
    	background-color: #000000;
    
    }
    -->
    </style>
    </head>
    
    <body>
    <div align="center">
      <p><img src="<?php bloginfo('template_directory'); ?>/images/back.jpg" width="433" height="330" /></p>
    </div>
    </body>
    </html>
    
    EOD;
    echo "$theResults";

The topic ‘php Form action not work properly. T_T’ is closed to new replies.