开发者

Issue with post data not received in a php page

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( "xxx@gmail.com", "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 />
开发者_StackOverflow中文版  Subject: <input name='subject' type='text' /><br />
  Message:<br />
  <textarea name='message' rows='15' cols='40'>
  </textarea><br />
  <input type='submit' />
  </form>";
  }
?>


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*/}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜