通过表单传递会话变量以使用 php 发送邮件
Passing session variables through a form to mail with php
我正在尝试 post 来自 3 页表单的会话变量并将它们邮寄给自己,
邮件功能正在运行(发送空电子邮件)但没有任何变量被传递到电子邮件中。
感谢任何帮助。
第 1 页
<?php
session_start();
include 'incs/header.php';
?>
<form id="" name="" method="POST"
action="page2.php" class="">
<div class=" row input-append addressWrapper" id="fieldWrapper ">
<input id="searchTextField" type="text" name="address"
class="form1 request-input values address search-query"
placeholder="Enter Your Home Address">
<input type="hidden" name="type" id="changetype-all" checked="checked">
<input type="hidden" name="city_image" id="city_image" value="">
<input type="hidden" name="lat" id="lat">
<input type="hidden" name="lng" id="lng">
<input type="hidden" name="submit" id="submit" class="">
</div>
<div class="row stats">
<div class="col-md-12">
<select name="bedrooms" class="form3">
<option selected value="">Bedrooms</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
<div class="col-md-12">
<select name="bathrooms" class="form3">
<option selected value="">Bathrooms</option>
<option value="1">1</option>
>
</select>
</div>
<div class="col-md-12 marl ">
<select name="squareFootage" class="form3">
<option selected value="">Square Footage</option>
<option value="0-800">0-800</option>
</select>
</div>
<button type="submit" name="next" class="btn form1 btn-success worth p1" id="next"
value="What's It Worth?">Submit
</button>
</div>
</form>
第 2 页
<?php
session_start();
include 'incs/header.php';
$_SESSION['address'] = $address;
$_SESSION['bedrooms'] = $bedrooms;
$_SESSION['bathrooms'] = $bathrooms;
$_SESSION['squareFootage'] = $sqft;
?>
<form id="optionsform" name="MSRequest" method="POST"
action="page3.php" class="">
<div class="row">
<div class="">
<input id="email" type="email" name="email"
placeholder="Enter Your Email">
</div>
<input type="hidden" name="submit" id="submit" class=" form3">
<button type="submit" name="next" class="btn btn-success worth "
id="next" value="What's It Worth?">Submit
</button>
</div>
</form>
第 3 页
<?php
session_start();
include 'incs/header.php';
$address = $_POST['address'];
$_SESSION['bedrooms'] = $_POST['bedroom'];
$_SESSION['bathrooms'] = $_POST['bathrooms'];
$_SESSION['squareFootage'] = $_POST['squareFootage'];
$_SESSION['email'] = $_POST['email'];
$to = 'example@gmail.com';
$subject = 'TESTING ';
$message = $_POST['address'] ."\r\n";
$message .= $_POST['bedrooms']."\r\n";
$message .= $_POST['bathrooms']."\r\n";
$message .= $_POST['squareFootage']."\r\n";
$message .= $_POST['address']."\r\n";
$headers = 'From: email@example.com' . "\r\n" .
mail($to, $subject, $message, $headers);
?>
试试这个
第 2 页:
<?php
session_start();
include 'incs/header.php';
$_SESSION['address'] = $_POST['address'];
$_SESSION['bedrooms'] = $_POST['bedroom'];
$_SESSION['bathrooms'] = $_POST['bathrooms'];
$_SESSION['squareFootage'] = $_POST['squareFootage'];
?>
<form id="optionsform" name="MSRequest" method="POST"
action="page3.php" class="">
<div class="row">
<div class="">
<input id="email" type="email" name="email"
placeholder="Enter Your Email">
</div>
<input type="hidden" name="submit" id="submit" class=" form3">
<button type="submit" name="next" class="btn btn-success worth "
id="next" value="What's It Worth?">Submit
</button>
</div>
</form>
第 3 页:
<?php
session_start();
include 'incs/header.php';
$to = 'example@gmail.com';
$subject = 'TESTING ';
$message = $_SESSION['address'] ."\r\n";
$message .= $_SESSION['bedrooms']."\r\n";
$message .= $_SESSION['bathrooms']."\r\n";
$message .= $_SESSION['squareFootage']."\r\n";
$headers = 'From: email@example.com' . "\r\n" .
mail($to, $subject, $message, $headers);
?>
我正在尝试 post 来自 3 页表单的会话变量并将它们邮寄给自己,
邮件功能正在运行(发送空电子邮件)但没有任何变量被传递到电子邮件中。
感谢任何帮助。
第 1 页
<?php
session_start();
include 'incs/header.php';
?>
<form id="" name="" method="POST"
action="page2.php" class="">
<div class=" row input-append addressWrapper" id="fieldWrapper ">
<input id="searchTextField" type="text" name="address"
class="form1 request-input values address search-query"
placeholder="Enter Your Home Address">
<input type="hidden" name="type" id="changetype-all" checked="checked">
<input type="hidden" name="city_image" id="city_image" value="">
<input type="hidden" name="lat" id="lat">
<input type="hidden" name="lng" id="lng">
<input type="hidden" name="submit" id="submit" class="">
</div>
<div class="row stats">
<div class="col-md-12">
<select name="bedrooms" class="form3">
<option selected value="">Bedrooms</option>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
</select>
</div>
<div class="col-md-12">
<select name="bathrooms" class="form3">
<option selected value="">Bathrooms</option>
<option value="1">1</option>
>
</select>
</div>
<div class="col-md-12 marl ">
<select name="squareFootage" class="form3">
<option selected value="">Square Footage</option>
<option value="0-800">0-800</option>
</select>
</div>
<button type="submit" name="next" class="btn form1 btn-success worth p1" id="next"
value="What's It Worth?">Submit
</button>
</div>
</form>
第 2 页
<?php
session_start();
include 'incs/header.php';
$_SESSION['address'] = $address;
$_SESSION['bedrooms'] = $bedrooms;
$_SESSION['bathrooms'] = $bathrooms;
$_SESSION['squareFootage'] = $sqft;
?>
<form id="optionsform" name="MSRequest" method="POST"
action="page3.php" class="">
<div class="row">
<div class="">
<input id="email" type="email" name="email"
placeholder="Enter Your Email">
</div>
<input type="hidden" name="submit" id="submit" class=" form3">
<button type="submit" name="next" class="btn btn-success worth "
id="next" value="What's It Worth?">Submit
</button>
</div>
</form>
第 3 页
<?php
session_start();
include 'incs/header.php';
$address = $_POST['address'];
$_SESSION['bedrooms'] = $_POST['bedroom'];
$_SESSION['bathrooms'] = $_POST['bathrooms'];
$_SESSION['squareFootage'] = $_POST['squareFootage'];
$_SESSION['email'] = $_POST['email'];
$to = 'example@gmail.com';
$subject = 'TESTING ';
$message = $_POST['address'] ."\r\n";
$message .= $_POST['bedrooms']."\r\n";
$message .= $_POST['bathrooms']."\r\n";
$message .= $_POST['squareFootage']."\r\n";
$message .= $_POST['address']."\r\n";
$headers = 'From: email@example.com' . "\r\n" .
mail($to, $subject, $message, $headers);
?>
试试这个 第 2 页:
<?php
session_start();
include 'incs/header.php';
$_SESSION['address'] = $_POST['address'];
$_SESSION['bedrooms'] = $_POST['bedroom'];
$_SESSION['bathrooms'] = $_POST['bathrooms'];
$_SESSION['squareFootage'] = $_POST['squareFootage'];
?>
<form id="optionsform" name="MSRequest" method="POST"
action="page3.php" class="">
<div class="row">
<div class="">
<input id="email" type="email" name="email"
placeholder="Enter Your Email">
</div>
<input type="hidden" name="submit" id="submit" class=" form3">
<button type="submit" name="next" class="btn btn-success worth "
id="next" value="What's It Worth?">Submit
</button>
</div>
</form>
第 3 页:
<?php
session_start();
include 'incs/header.php';
$to = 'example@gmail.com';
$subject = 'TESTING ';
$message = $_SESSION['address'] ."\r\n";
$message .= $_SESSION['bedrooms']."\r\n";
$message .= $_SESSION['bathrooms']."\r\n";
$message .= $_SESSION['squareFootage']."\r\n";
$headers = 'From: email@example.com' . "\r\n" .
mail($to, $subject, $message, $headers);
?>