如何将表单属性_POST $另一个文件


how to $_POST form attributes to another file

这是感谢页面,我试图让某人的名字显示为"谢谢约翰,..."但我似乎不能让它发布这个名字。我的 $first_name 在另一个 PHP 文件中

<?php include("email.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN""http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>
<base target="_blank">
<title>Mid-Night Designs</title>
<style type="text/css">
body *{font-family: 'Open Sans', Arial, sans-serif !important}
div, p, a, li, td { -webkit-text-size-adjust:none; }
*{-webkit-font-smoothing: antialiased;-moz-osx-font-smoothing: grayscale;}
td{word-break: break-word;}
a{word-break: break-word; text-decoration: none; color: inherit;}
body .ReadMsgBody
{width: 100%; background-color: #ffffff;}
body .ExternalClass
{width: 100%; background-color: #ffffff;}
body{width: 100%; height: 100%; background-color: #ffffff; margin:0; padding:0; -webkit-font-smoothing: antialiased;}
html{ background-color:#ffffff; width: 100%;}
body p {padding: 0!important; margin-top: 0!important; margin-right: 0!important; margin-bottom: 0!important; margin-left: 0!important; }
body img {user-drag: none; -moz-user-select: none; -webkit-user-drag: none;}
body a.rotator img {-webkit-transition: all 1s ease-in-out;-moz-transition: all 1s ease-in-out; -o-transition: all 1s ease-in-out; -ms-transition: all 1s ease-in-out; }
body a.rotator img:hover {-webkit-transform: rotate(360deg); -moz-transform: rotate(360deg); -o-transform: rotate(360deg);-ms-transform: rotate(360deg); }
body .hover:hover {opacity:0.85;filter:alpha(opacity=85);}
body .jump:hover {opacity:0.75; filter:alpha(opacity=75); padding-top: 10px!important;}
body .logo img {width: 150px; height: auto;}
body .icon25 img {width: 25px; height: auto;}
body .icon18 img {width: 18px; height: auto;}
</style>
<style type="text/css">@media only screen and (max-width: 640px){
		body body{width:auto!important;}
		body table[class=full] {width: 100%!important; clear: both; }
		body table[class=mobile] {width: 100%!important; padding-left: 30px; padding-right: 30px; clear: both; }
		body table[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
		body td[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
		body .erase {display: none;}
		body .buttonScale {float: none!important; text-align: center!important; display: inline-block!important; clear: both;}
		body td[class=pad20] {padding-left: 20px!important; padding-right: 20px!important; text-align: center!important; clear: both; }
}</style>
<style type="text/css">@media only screen and (max-width: 479px){ 
		body body{width:auto!important;}
		body table[class=full] {width: 100%!important; clear: both; }
		body table[class=mobile] {width: 100%!important; padding-left: 20px; padding-right: 20px; clear: both; }
		body table[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
		body td[class=fullCenter] {width: 100%!important; text-align: center!important; clear: both; }
		body .erase {display: none;}
		body .buttonScale {float: none!important; text-align: center!important; display: inline-block!important; clear: both;}
		body td[class=pad20] {padding-left: 20px!important; padding-right: 20px!important; text-align: center!important; clear: both; }
		
}</style>
</head>
<body style='margin: 0; padding: 0;'>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
	<tbody><tr>
		<td align="center">
		
			<table class="full" align="center" border="0" width="100%" cellpadding="0" cellspacing="0">
				<tbody><tr>
					<td align="center" class="pad20">
					
						<table width="500" border="0" cellpadding="0" cellspacing="0" align="center" class="full">
							<tbody><tr>
								<td width="100%" height="15" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
							<tr>
								<td valign="middle" width="100%" style="font-family: Helvetica, Arial, sans-serif, 'Open Sans'; color: #929292; font-weight: 400; font-size: 12px; line-height: 20px; text-align: center;">
									<br>
								</td>
							</tr>
							<tr>
								<td width="100%" height="40" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
							<tr>
								<td valign="middle" align="center" width="100%" class="logo" style="line-height: 1px; text-align: center;"></td>
							</tr>
							<tr>
								<td width="100%" height="30" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
						</tbody></table>
						
					</td>
				</tr>
			</tbody></table>
			
		</td>
	</tr>
</table><table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
	<tbody><tr>
		<td align="center" class="pad20">
		
			<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff; border-top-left-radius: 5px; border-top-right-radius: 5px;">
				<tbody><tr>
					<td width="100%" height="30" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
				</tr>
			</tbody></table>
			
		</td>
	</tr>
</tbody></table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
	<tbody><tr>
		<td align="center" class="pad20">
		
			<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff;">
				<tbody><tr>
					<td align="center" class="pad20">
					
						<table width="450" border="0" cellpadding="0" cellspacing="0" align="center" class="full">
							<tbody><tr>
								<td width="100%" height="10" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
							<tr>
								<td valign="middle" width="100%" style="font-family: Helvetica, Arial, sans-serif, 'Open Sans'; color: #111111; font-weight: 800; font-size: 30px; line-height: 36px; text-align: center; text-transform: uppercase;">
									Thank you!
								</td>
							</tr>
							<tr>
								<td width="100%" height="20" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
							<tr>
								<td width="100%" style="color: #929292; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 14px; text-align: center; line-height: 22px;" class="fullCenter">
									<span style="color:#000000;"><span style="font-size:14px;"><strong>Thank you<?php echo $_POST['first_name'];?>
, for using our quote calculator. If you have any further questions feel free to contact us!</strong></span></span>
								</td>
							</tr>
							<tr>
								<td width="100%" height="20" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
						</tbody></table>
						
					</td>
				</tr>
			</tbody></table>
			
		</td>
	</tr>
</table>



<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
	<tbody><tr>
		<td align="center" class="pad20">
		
			<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff;">
				<tbody><tr>
					<td width="100%" height="30" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
				</tr>
				<tr>
					<td align="center" class="pad20">
											
						<table width="450" border="0" cellpadding="0" cellspacing="0" align="center" class="full">
							<tbody><tr>
								<td valign="top" width="100%">
								
									<table width="75" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="fullCenter">
										<tbody><tr>
											<td valign="middle" align="center" width="30" class="fullCenter" style="line-height: 1px;"></td>
										</tr>
									</tbody></table>
									
									<table width="15" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="full">
										<tbody><tr>
											<td width="100%" height="10" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
										</tr>
									</tbody></table>
									
									<table width="350" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="fullCenter">
										<tbody><tr>
											<td width="100%" style="color: #111111; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 700; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px;" class="fullCenter">
												Lorenzo Preciado
											</td>
										</tr>
										<tr>
											<td width="100%" style="color: #61b94d; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 600; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px text-transform: uppercase;" class="fullCenter">
												<span style="color:#000000;">Web Designer &amp; Developer&nbsp;</span>
											</td>
										</tr>
										<tr>
											<td width="100%" style="color: #929292; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px;" class="fullCenter">
												Owner of Mid-Night Designs
											</td>
										</tr>
										<tr>
											<td width="100%" style="color: #929292; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 13px; text-align: left; line-height: 24px;" class="fullCenter">
												+81 080-6499-4974 &nbsp; |&nbsp;&nbsp; <a  href="#" style="text-decoration: none; color: #929292;">h</a>elp@mid-nightdesigns.com
											</td>
										</tr>
										<tr>
											<td width="100%" height="5" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
										</tr>
										<tr>
											<td width="100%" align="center" class="icon18">
											
												<!-- Social Icons -->
												<table width="120" border="0" cellpadding="0" cellspacing="0" align="left" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt;" class="buttonScale">
													<tbody><tr>
														<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
														<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
														<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
														<td valign="middle" align="left" width="30" class="buttonScale" style="line-height: 1px;"></td>
													</tr>
												</tbody></table>
												
											</td>
										</tr>
									</tbody></table>
									
								</td>
							</tr>
							<tr>
								<td width="100%" height="10" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
						</tbody></table>
						
					</td>
				</tr>
			</tbody></table>
			
		</td>
	</tr>
</table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
	<tbody><tr>
		<td align="center" class="pad20">
		
			<table class="full" align="center" border="0" width="500" cellpadding="0" cellspacing="0" bgcolor="#ffffff" style="background-color: #ffffff; border-bottom-left-radius: 5px; border-bottom-right-radius: 5px;">
				<tbody><tr>
					<td width="100%" height="30" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
				</tr>
			</tbody></table>
			
		</td>
	</tr>
</tbody></table>
<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="full" bgcolor="#1e1e1e" style="background-color: #1e1e1e;">
	<tbody><tr>
		<td width="100%" valign="top" align="center">
			
			<table width="100%" border="0" cellpadding="0" cellspacing="0" align="center" class="mobile">
				<tbody><tr>
					<td align="center">
						
						<table width="450" border="0" cellpadding="0" cellspacing="0" align="center" style="border-collapse:collapse; mso-table-lspace:0pt; mso-table-rspace:0pt; text-align: center;" class="fullCenter">
							<tbody><tr>
								<td width="100%" height="30" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
							<tr>
								<td width="100%" style="color: #d2d2d2; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 12px; text-align: center; line-height: 24px;" class="fullCenter">
									© Copyright - <a  href="http://mid-nightdesigns.com" style="text-decoration: none;">Mid-Nightd<span style="color:#FFFFFF;"></span>esigns.com</a>
								</td>
							</tr>
							<tr>
								<td width="100%" style="color: #61b94d; font-family: Helvetica, Arial, sans-serif, 'Open Sans'; font-weight: 400; vertical-align: top; font-size: 12px; text-align: center; line-height: 24px;" class="fullCenter">
									<a href="#" style="text-decoration: none; color: #61b94d;"><br></a>
								</td>
							</tr>
							<tr>
								<td width="100%" height="50" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
							<tr>
								<td width="100%" height="1" style="font-size: 1px; line-height: 1px;">&nbsp;</td>
							</tr>
						</tbody></table>
						
					</td>
				</tr>
			</tbody></table>
		
		</td>
	</tr>
</tbody></table>
</body>
</html>

这是表单的一部分

 <label>
                First Name   
                <input NAME="first_name" type="text" required="required" class="SV_validate" placeholder="First Name">
              </label>
这是我电子邮件的一部分.php它可以工作,在发送的电子邮件中显示名称,但在谢谢中不起作用。
 $first_name = $_POST['first_name'];

接收

POST 的 PHP 文件将类似于

<?php
session_start();
$_SESSION['Name'] = $_POST['first_name'];
?>

第二个文件将是

<?php
session_start();
echo $_SESSION['Name'];
?>

不建议完全这样做,但这是基础。您也不能在同一页面上设置会话并在同一页面上调用它。

请检查为您创建的简单场景,将表单操作更改为谢谢.php文件。

索引.php

<form action="thank-you.php" method="post">
<input type="text" name="firstname">
<input type="text" name="email">
<input type="submit" name="contact" value="Contact">
</form>

谢谢.php

<?php
    include_once('email.php');
    $firstname = '';
    if(isset($_POST['firstname'])) {
        $firstname = $_POST['firstname'];
    }
?>
<div class="message">Thank you for contacting - <?php echo $firstname;?></div>

电子邮件.php

<?php
if(isset($_POST['contact'])) {
    $to = 'email@example.com';
    $subject = 'Contact';
    $message = 'Message';
    if(mail($to,$subject,$message)) {
        echo "mail sent";
    }
}
?>