我的发送邮件的php脚本如下:

<?php
    if (isset($_POST['submit'])) {
        $to='[email protected]';
        $fname=stripslashes($_POST['fname']);
        $email=$_POST['email'];
        if (get_magic_quotes_gpc())
            $email = stripslashes($email);
        //$email=trim($email, '/');
        $msg=$_POST['msg'];
        $msg=stripslashes($msg);
        $message="Name: $fname\n" ."Message: $msg\n";
        mail($to,$subject,$message,'From:'.$email)  ;
    }
   ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="contact us">
  <label>Name:</label>
  &nbsp;&nbsp;&nbsp;
  <input type="text" name="fname" value=<?php if(!empty($fname)) echo $fname; ?>  /><br />
  <label>Email:</label>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="email" value=<?php if (!empty($email)) echo $email; ?> /><br />
  <label>Message:</label>
  <textarea name="msg" rows="5"><?php if (!empty($msg)) echo $msg; ?></textarea>      <br />
  <input type="submit" name="submit" value="Post" />
</form>

但当表单出现时,每个字段中都会添加一个/
我试过使用trimrtim,获取魔法引号和stripslashes,但没有任何效果。

最佳答案

尝试在value属性周围添加
工业工程

<input type="text" name="email" value="<?php if (!empty($email)) echo $email; ?>" />

10-08 14:21