tags:

views:

35

answers:

1

hi,

I created a page in Wordpress (http://www.exam-vision.com/testmail) that sends POST data to itself in order to send an email. The code is shown below. While it seems that data are sent properly, it seems that they are not received since isset($_REQUEST['email']) is always false. Anybody could help?

UPDATE: it seems it has something to do with wordpress url management, because it works properly when I try it on the direct link of the php file:

http://www.exam-vision.com/wp-content/themes/sandbox/test.php

Thanks

Jul

<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  echo "isset email is true";
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail( "[email protected]", "Subject: $subject",
  $message, "From: $email" );
  echo "Thank you for using our mail form";
  }
else
//if "email" is not filled out, display the form
  {
  echo "<form method='post' action=''>
  Email: <input name='email' type='text' /><br />
  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>
A: 

Action should be action="<?php echo $_SERVER['PHP_SELF']; ?>, then on the beginning of the script run a test like:

 if(!empty($_POST)){/*run code*/}
Babiker
<?php echo $_SERVER['PHP_SELF']; ?> returns "/wp-404-handler.php"...
jul