PHP 表单处理错误
PHP Form Handling Error
my action.php site does not keep the input (form handling). here is my
acion.php.
<?php>
echo $_GET['fn'];?><br>
<?php>
echo $_GET["ln"];?>
<?php>
echo $_GET["e-mail"];?>
<?php>
echo $_GET["message"];?>
this is the form in main html site
<form action="action.php" method="get">
<input type="text" name="fn" placeholder="Ad"></input>
<br>
<input type="text" name="ln" placeholder="Soy Ad"></input><br>
<input type="text" name="e-mail" placeholder="e-Mail"></input><br>
<textarea name="message" rows="10" cols="30">Yorumunuz.</textarea><br>
<input type="submit" name="gonder" value="Gönder"></input>
</form>
secondary do i have to put " or ' ----> $_GET["fn"] or $_GET['fn']
您有语法错误:
<?php>
echo $_GET['fn'];?><br>
<?php>
echo $_GET["ln"];?>
<?php>
echo $_GET["e-mail"];?>
<?php>
echo $_GET["message"];?>
应该是
<?php
echo $_GET["fn"];?><br>
<?php
echo $_GET["ln"];?>
<?php
echo $_GET["e-mail"];?>
<?php
echo $_GET["message"];?>
在这种情况下,如果您使用 ' 或 " 它是 metter
如果您想回显字符串的值:
$str = "test";
echo "test is $str"; // will echo test is test
echo 'test is $str'; // will echo test is $str
可能您正在寻找这个:
<form action="action.php" method="get">
<input type="text" name="fn" value="<?php if(isset($_GET['fn']) && $_GET['fn']!=""){echo $_GET['fn'];} ?>" placeholder="Ad">
</input>
<br>
<input type="text" name="ln" value="<?php if(isset($_GET['ln']) && $_GET['ln']!=""){echo $_GET['ln'];} ?>" placeholder="Soy Ad">
</input>
<br>
<input type="text" name="e-mail" value="<?php if(isset($_GET['e-mail']) && $_GET['e-mail']!=""){echo $_GET['e-mail'];} ?>" placeholder="e-Mail">
</input>
<br>
<textarea name="message" rows="10" value="<?php if(isset($_GET['message']) && $_GET['message']!=""){echo $_GET['message'];} ?>" cols="30">Yorumunuz.</textarea>
<br>
<input type="submit" name="gonder" value="Gönder">
</input>
</form>
<?php
echo $_GET["fn"]."<br />";
echo $_GET["ln"]."<br />";
echo $_GET["e-mail"]."<br />";
echo $_GET["message"]."<br />";
?>
my action.php site does not keep the input (form handling). here is my acion.php.
<?php>
echo $_GET['fn'];?><br>
<?php>
echo $_GET["ln"];?>
<?php>
echo $_GET["e-mail"];?>
<?php>
echo $_GET["message"];?>
this is the form in main html site
<form action="action.php" method="get">
<input type="text" name="fn" placeholder="Ad"></input>
<br>
<input type="text" name="ln" placeholder="Soy Ad"></input><br>
<input type="text" name="e-mail" placeholder="e-Mail"></input><br>
<textarea name="message" rows="10" cols="30">Yorumunuz.</textarea><br>
<input type="submit" name="gonder" value="Gönder"></input>
</form>
secondary do i have to put " or ' ----> $_GET["fn"] or $_GET['fn']
您有语法错误:
<?php>
echo $_GET['fn'];?><br>
<?php>
echo $_GET["ln"];?>
<?php>
echo $_GET["e-mail"];?>
<?php>
echo $_GET["message"];?>
应该是
<?php
echo $_GET["fn"];?><br>
<?php
echo $_GET["ln"];?>
<?php
echo $_GET["e-mail"];?>
<?php
echo $_GET["message"];?>
在这种情况下,如果您使用 ' 或 " 它是 metter 如果您想回显字符串的值:
$str = "test";
echo "test is $str"; // will echo test is test
echo 'test is $str'; // will echo test is $str
可能您正在寻找这个:
<form action="action.php" method="get">
<input type="text" name="fn" value="<?php if(isset($_GET['fn']) && $_GET['fn']!=""){echo $_GET['fn'];} ?>" placeholder="Ad">
</input>
<br>
<input type="text" name="ln" value="<?php if(isset($_GET['ln']) && $_GET['ln']!=""){echo $_GET['ln'];} ?>" placeholder="Soy Ad">
</input>
<br>
<input type="text" name="e-mail" value="<?php if(isset($_GET['e-mail']) && $_GET['e-mail']!=""){echo $_GET['e-mail'];} ?>" placeholder="e-Mail">
</input>
<br>
<textarea name="message" rows="10" value="<?php if(isset($_GET['message']) && $_GET['message']!=""){echo $_GET['message'];} ?>" cols="30">Yorumunuz.</textarea>
<br>
<input type="submit" name="gonder" value="Gönder">
</input>
</form>
<?php
echo $_GET["fn"]."<br />";
echo $_GET["ln"]."<br />";
echo $_GET["e-mail"]."<br />";
echo $_GET["message"]."<br />";
?>