显示存储在变量上的输入文本值

时间:2015-06-21 02:58:49

标签: php

这个简单的代码有什么问题吗?我正在尝试将输入类型权重存储到php变量$ w ....尝试使用echo $ w检查它是否已存储但是它没有显示任何内容..:p

with IdMessage do
begin
  Clear;
  try
    Subject := edtAssunto.Text;
    if FileExists(edtAnexo.Text) then
    begin
      ContextType := 'multipart/mixed';
      IdBody := TIdText.Create(MessageParts);
      IdBody.ContentType := 'text/html';
      IdBody.Body.Text := mEngenharia.Text;
      TIdAttachmentFile.Create(MessageParts, edtAnexo.Text);
    end else
    begin
      ContentType := 'text/html';
      Body.Text := mEngenharia.Text;
    end;
    From.Address := ...;
    From.Name := ...;
    Sender.Address := ...; // if different than From.Address
    Recipients.EMailAddresses := edtDestinatario.Text;
    Send(IdMessage);
  finally
    Clear;
  end;
  ShowMessage('Email enviado com sucesso!');
end;

1 个答案:

答案 0 :(得分:0)

它应该按预期工作

您需要做的是在完成检查后分配

if (isset($_POST['weight']))
{ 
   $w=$_POST["weight"]; 
   echo $w; 
}

所以你的代码应该是

<html>
<head>
<title></title>
</head>
<body>
<form action='' method='POST'>
<label>Enter Weight: </label><input type='text' name="weight">
<input type="submit">
</form>
<?php 
if (isset($_POST['weight']))
{

   $w=$_POST["weight"]; 
   echo $w; 
}
?>

按下提交按钮后,它应显示您的输入。