I created a form, where one can add or remove entries and save all entries at once.
Now the form only saves the last entry. Scripts to add and remove record, works pretty well.
How can i make sure all the entries are saved to the db. I have been looking for a solution but can't find any.
Controller
`public function saveGroupDelegateData(Request $request ){
foreach ($request -> (*.lastIndex) as $key => $lastIndex) {
$SaveAttendees = Attendees::create([
'title' => $request->title[$lastIndex],
'name' => $request->name[$lastIndex],
'email' => $request->email[$lastIndex],
'company' => $request->company[$lastIndex],
'phone_number' => $request->phone_number[$lastIndex],
'job_title' => $request->job_title[$lastIndex],
'event_role' => $request->event_role[$lastIndex],
'tour' => $request->tour[$lastIndex],
'tour_location' => $request->tour_location[$lastIndex]
]);
}}`
Viewblade
`<form action="/SaveGroupAttendees" method="POST" enctype="multipart/form-data">
#csrf
<div id="inputFormRow" >
<p style="background-color:DodgerBlue;">Attendee [1]</p>
<label>Email to share Invoice to</label><input type="text" name="desired_mail" placeholder="Email to Share Invoice To" />
<br> <br>
<div class="input-group mb-3">
<input type="hidden" name="Users.Index" value="1" />
<input type="text" required="required" placeholder="title" name="title[1]">
<input type="text" required="required" placeholder="Full name" name="name[1]">
<input type="text" required="required" placeholder="email" name="email[1]">
<input type="text" required="required" placeholder="company" name="company[1]">
<input type="text" required="required" placeholder="phone_number" name="phone_number[1]">
<input type="text" required="required" placeholder="job_title" name="job_title[1]">
<input type="hidden" value="delegate" placeholder="event_role" name="event_role[1]">
<label for="tour[1]" >Attend Excursion</label>
<select name="tour[1]" class="form-control round" id="tour" >
<option value="yes">Yes</option>
<option active value="no">No</option>
</select>
<label id="tour_location" for="tour_location[1]" >Exursion Location</label>
<select class="form-control round" id="tours" name="tour_location[1]">
<option value="None">Choose Location</option>
<option value="kenya">Kenya</option>
<option value="uganda">Uganda</option>
</select>
<div class="input-group-append">
<!-- <button id="removeRow" type="button">
(-) Remove Attendee
</button> -->
</div>
</div>
</div>
<div id="newRow"></div>
<p>
<button id="addRow" type="button">
(+) Add Attendee
</button>
</p>
<div class="text-center">
<input class="btn btn-danger" type="submit" value="{{ trans('global.save') }}">
</div>
</form>
</div>
</div>
</d iv>
<i class="fa fa-angle-up"></i>
<script type="text/javascript">
// add row
let lastIndex= 2 ;
// add row
$("#addRow").click(function () {
var html = '';
html += '<div id="inputFormRow" class="table table-condensed table-striped">';
html += ' <p style="background-color:DodgerBlue;">Attendee['+lastIndex+']</p>';
html += ' <div class="input-group mb-3">';
html += ' <input type="text"required="required" placeholder="title" name="title['+lastIndex+']">';
html += ' <input type="text" required="required" placeholder="Full Name" name="name['+lastIndex+']">';
html += ' <input type="text" required="required" placeholder="Email" name="email['+lastIndex+']">';
html += ' <input type="text" required="required" placeholder="Company" name="company['+lastIndex+']">';
html += ' <input type="text" required="required" placeholder="Phone Number" name="phone_number['+lastIndex+']">';
html += ' <input type="text" required="required" placeholder="Job title" name="job_title['+lastIndex+']"';
html += ' <input type="hidden" value="delegate" placeholder="event_role" name="event_role['+lastIndex+']">';
html += ' <label for="tour['+lastIndex+']">Attend Excursion?</label> <select class="form-control round" id="tour" name="tour['+lastIndex+']"><option value="yes">Yes</option><option active value="no">No</option></select>';
html += ' <label for="tour_location['+lastIndex+']">Excursion Location</label><select class="form-control round" name="tour_location['+lastIndex+']" id="tours"><option active value="None" >Choose Location</option><option value="KE">Kenya</option><option value="Uganda">Uganda</option></select>';
html += ' <div class="input-group-append">';
html += ' <button id="removeRow" type="button">';
html += ' (-) Remove Attendee';
html += ' </button>';
html += ' </div>';
html += ' </div>';
html += '</div>';
lastIndex=lastIndex+1;
$('#newRow').append(html);
});`
// remove row
$(document).on('click', '#removeRow', function () {
lastIndex=lastIndex-1;
$(this).closest('#inputFormRow').remove();
});
i think you can change the name of the input element. you can change it to this:
<input type="text" required="required" placeholder="title" name="data[lastIndex][title]">
and in controller you can looping the data.
foreach($request->data as $value) {
Attendees::create([
'title' => $value['title']
]);
}
Related
I am using laravel, I want to dynamically add fields for product properties. The product is added via submit, so if an error occurs, all additional fields disappear. Also, when editing, I need to display them somehow. What is the best way to save them? Via localStorage or does Laravel/PHP have other methods?
P.S. Here the snippet gives an error for some reason. Possibly due to localStorage.
$(document).ready(function(){
if(localStorage.getItem("all")){
$('#newRow').append(localStorage.getItem("all"));
}
$("#addRow").click(function () {
var html = '';
html += '<div id="inputFormRow">';
html += '<div class="input-group mb-3">';
html += '<input type="text" name="properties[key]" class="form-control m-input" placeholder="Key" autocomplete="off">';
html += '<input type="text" name="properties[value]" class="form-control m-input ml-3" placeholder="Value" autocomplete="off">';
html += '<div class="input-group-append ml-3">';
html += '<button id="removeRow" type="button" class="btn btn-danger">Delete</button>';
html += '</div>';
html += '</div>';
$('#newRow').append(html);
var allfields = [];
allfields.push(html);
localStorage.setItem("all", allfields);
});
// remove row
$('#removeRow').on('click', function () {
$(this).closest('#inputFormRow').remove();
});
});
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.5.3/dist/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="input-group row">
<label for="category_id" class="col-sm-2 col-form-label">Product properties: </label>
<div class="row">
<div class="col-lg-12">
<div id="inputFormRow">
<div class="input-group mb-3">
<input type="text" name="properties[key]" class="form-control m-input" placeholder="Key" autocomplete="off">
<input type="text" name="properties[value]" class="form-control m-input ml-3" placeholder="Value" autocomplete="off">
<div class="input-group-append ml-3">
<button id="removeRow" type="button" class="btn btn-danger">Delete</button>
</div>
</div>
</div>
<div id="newRow"></div>
<button id="addRow" type="button" class="btn btn-info">Add</button>
</div>
</div>
</div>
It's possible, firstly, you have to use array of array, or it just make more sense.
Your input:
<input type="text" name="properties[][key]" class="form-control m-input" placeholder="Key" autocomplete="off">
<input type="text" name="properties[][value]" class="form-control m-input ml-3" placeholder="Value" autocomplete="off">
now you will have array, which contains arrays with two keys, "key" and "value".
So after submit in your controller you can simply store your $request->properties in session before validation!
$request->session()->flash('properties', $request->properties)
or just global helper
session()->flash('properties', $request->properties)
after flash() method data will be available only next request, after that, they will be automatically deleted
then if you have error, you can do in view something like that:
#if(session->has('properties'))
#foreach (session('properties') as $prop)
<input type="text" name="properties[][key]" value="{{$prop['key']}}" class="form-control m-input" placeholder="Key" autocomplete="off">
<input type="text" name="properties[][value]" value="{{$prop['value']}}" class="form-control m-input ml-3" placeholder="Value" autocomplete="off">
#endforech
#endif
I'm trying to build a simple addition calculator in CodeIgniter. I am trying to get value from the post method into my controller. While executing the code, I'm getting an error saying
undefined index: number1
My controller file:
public function addQuote(){
if(isset($_POST['adds'])){
$ans=$_POST['number1'] + $_POST['number2'];
$data= array(
'number1'=> $_POST['number1'],
'number2'=> $_POST['number2'],
'ans'=> $ans
);
} else{
$data = array(
'number1'=> "0",
'number2'=> "0",
'ans'=> '0'
);
}
$this->load->view('addQuote',$data);
My view file is here:
<div class="col-md-3 col-md-offset-4 well">
<h2> Addition of two numbers</h2>
<form action="<?php echo base_url(''); ?>welcome/addQuote" method="post">
<div class="form-group">
<label for="number1"> Enter number 1</label>
<input type="number" class="form-control" id="number1" placeholder="Enter number 1" value="<?php $number1;?>">
</div>
<div class="form-group">
<label for="number2"> Enter Number</label>
<input typle="number" class="form-control" id="number2" placeholder="Enter number 2" value="<?php $number2;?>">
</div>
<div class="form-group">
<label for="ans"> Answer</label>
<p class="text-success"><?= $ans; ?> </p>
</div>
<button type="submit" class="btn btn-default" name="adds" > submit</button>
You need to add name attribute to your elements.
As only elements are submitted with name attribute added.
id and class are mainly for CSS and JS purposes.
So,
<input type="number" class="form-control" id="number1" placeholder="Enter number 1" value="<?php $number1;?>">
Should be:
<input type="number" class="form-control" id="number1" placeholder="Enter number 1" value="<?php $number1;?>" name="number1">
Observe the added name attribute.
Same for number2
<input type="number" class="form-control" id="number1" placeholder="Enter number 1" value="<?php $number1;?>" name="number1">
<input type="number" class="form-control" id="number2" placeholder="Enter number 1" value="<?php $number2;?>" name="number2">
<button type="submit" class="btn btn-default" name="adds" > submit</button>
I want only 4 columns from database in below
I have to get only 4 column from database for displaying in textfield please give suggestion for that. The table is shown below thank you
$sql_getnm = "SELECT * FROM util WHERE util_head IN ('wc_email', 'wc_contact_us', 'wc_mobile', 'wc_google_map');";
$result_getnm = $connect->query($sql_getnm);
while($row_getnm = $result_getnm->fetch_array())
$util_value_email_data=?
$util_value_mobile_data=?;
$util_value_map_data=?;
$util_value_data=?;
html form
<form id="submitForm" method="post" role="form" name="hl_form" method="post" enctype="multipart/form-data">
<div class="box-body">
<div class="form-group">
<label for="mobile_number">Email*</label>
<input class="form-control" id="util_value_email" name="util_value_email" value="<?Php echo $util_value_email_data; ?>" maxlength="250" placeholder="Enter Email Address" type="text">
</div>
<div class="form-group">
<label for="mobile_number">Mobile*</label>
<input class="form-control" id="util_value_mobile" name="util_value_mobile" value="<?Php echo $util_value_mobile_data; ?>" maxlength="250" placeholder="Enter Mobile Number" type="text">
</div>
<div class="form-group">
<label for="mobile_number">Map*</label>
<input class="form-control" id="util_value_map" name="util_value_map" value="<?Php echo $util_value_map_data; ?>" maxlength="250" placeholder="Enter Map Address" type="text">
</div>
<div class="form-group">
<label for="description" class="required">Description*</label>
<textarea class="form-control" style="resize: none;" id="util_value" name="util_value" rows="3" placeholder="Enter Description"><?Php echo $util_value_data; ?></textarea>
</div>
<div class="box-footer">
<button type="submit" name="submit" class="btn btn-primary">Submit</button>
</div>
</form>
Below is the code from which you can get all the four data that you want.
$sql_getnm = "SELECT * FROM util WHERE util_head IN ('wc_email', 'wc_contact_us', 'wc_mobile', 'wc_google_map');";
$result_getnm = $connect->query($sql_getnm);
while($row_getnm = $result_getnm->fetch_array()) {
if($row_getnm['util_head'] == 'wc_email'){
$util_value_email_data = $row_getnm['util_value'];
}
if($row_getnm['util_head'] == 'wc_contact_us'){
$util_value_contact_data = $row_getnm['util_value'];
}
if($row_getnm['util_head'] == 'wc_mobile'){
$util_value_mobile_data = $row_getnm['util_value'];
}
if($row_getnm['util_head'] == 'wc_google_map'){
$util_value_map_data = $row_getnm['util_value'];
}
}
You need to replace * with columns name with comma separation.
$sql_getnm = "SELECT Columname1,Columname2,Columname3,Columname4 FROM util WHERE util_head IN ('wc_email', 'wc_contact_us', 'wc_mobile', 'wc_google_map');";
$result_getnm = $connect->query($sql_getnm);
while($row = mysql_fetch_array($result_getnm, MYSQL_ASSOC)
$util_value_email_data= $row['Columname1'];
$util_value_mobile_data= $row['Columname2'];
$util_value_map_data= $row['Columname3'];
$util_value_data= $row['Columname4'];
I'm developing a script for online admission in a website. Below is php code of the page. The problem is that it's not submitting.
<?php
include ("include/header.php"), include ("include/config.php");
if(isset($_POST['applyAdmission'])) {
$admission_no = $_POST['admission_no'];
$f_name = $_POST['f_name'];
$l_name = $_POST['l_name'];
$p_add = $_POST['p_add'];
$c_add = $_POST['c_add'];
$dob = $_POST['dob'];
$education = $_POST['education'];
$mobile = $_POST['mobile_no'];
$course = $_POST['course'];
$subjects = $_POST['subjects'];
$timing = $_POST['timing'];
$filepath_pic = $_FILES['picture']['name'];
$res_move_pic = move_uploaded_file($_FILES['picture']['tmp_name'], "/admission/".$filepath_pic);
$filepath_sign = $_FILES['sign']['name'];
$res_move_sign = move_uploaded_file($_FILES['sign']['tmp_name'], "/admission/".$filepath_sign);
$agree_terms = $_POST['agree_terms'];
$agree_cond = $_POST['agree_cond'];
if ($res_move_pic == 1 && $res_move_sign == 1 ) {
$query = "INSERT into online_admission (f_name, l_name, p_add, c_add, dob, degree, mobile_no, course, subjects, timing, pic, sign, agree_terms, agree_cond, applied_on)
values ('$f_name','$l_name','$p_add','$c_add','$dob','$education','$mobile','$course','$subjects','$timing','$filepath_pic','$filepath_sign','$agree_terms','$agree_cond','now()')";
$res = mysql_query($query) or die("ERROR: Unable to insert into database.");
if ($res == 1) {
header('Location:http://adarshclasses.in/admission_success.php/');
exit();
} else {
header('Location:http://adarshclasses.in/admission_failed.php/');
exit();
}
} else {
echo "Error in updateing profile pic and sign";
}
} else {
//echo "Please submit the form, thanks!";
}
;?>
Everything in form is correct like I added same name in form which i used in $_POST but still it's not working, please help me to fix this issue.
Here is html codes of form:
<form class="form-horizontal" id="admission_form" method="post" action="" enctype="multipart/form-data">
<!--div class="row">
<div class="col-lg-6">
<label for="admission_no"> Admission No. </label>
<input type="hidden" class="form-control" name="admission_no" value="<?php echo $admission_no ;?>" readonly disabled>
</div>
</div--><br>
<div class="row">
<div class="col-lg-6">
<label for="f_name"> First Name <span class="required">*</span> </label>
<input type="text" class="form-control" name="f_name" placeholder="Your first name" value="<?php echo $f_name ;?>" required>
</div>
<div class="col-lg-6">
<label for="l_name"> Last Name <span class="required">*</span></label>
<input type="text" class="form-control" name="l_name" placeholder="Your last name" value="<?php echo $l_name ;?>" required>
</div>
</div><br>
<div class="row">
<div class="col-lg-12">
<label for="p_add"> Permanent Address <span class="required">*</span></label>
<textarea class="form-control" name="p_add" placeholder="Please write your permanent address" value="<?php echo $p_add ;?>" required></textarea>
</div>
</div><br>
<div class="row">
<div class="col-lg-12">
<label for="c_add"> Current Address in Jodhpur <span class="required">*</span></label>
<textarea class="form-control" name="c_add" placeholder="Please write your address where you currently living" value="<?php echo $c_add ;?>" required></textarea>
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="dob"> Date of birth <span class="required">*</span></label>
<input type="date" class="form-control" name="dob" placeholder="Your date of birth eg:- 25/11/1996" value="<?php echo $dob ;?>" required>
</div>
<div class="col-lg-6">
<label for="education"> Recent passed degree/exam - </label>
<input type="text" class="form-control" name="education" placeholder="for example - BA/ B.Sc etc." value="<?php echo $education ;?>" >
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="mobile_no"> Mobile Number <span class="required">*</span></label>
<input type="number" class="form-control" name="mobile_no" placeholder="Enter your mobile number, eg - 8384991980" value="<?php echo $mobile_no ;?>" required>
</div>
<div class="col-lg-6">
<label for="course"> Select course <span class="required">*</span> </label>
<select class="form-control" name="course" required>
<option value="none"> --- Select one course --- </option>
<option value="IAS"> IAS </option>
<option value="RAS"> RAS </option>
<option value="Police constable"> Police constable </option>
<option value="SI"> SI </option>
<option value="Railway"> Railway </option>
<option value="REET"> REET </option>
<option value="Teacher"> Teacher </option>
<option value="Patwar"> Patwar </option>
<option value="Bank PO"> Bank PO </option>
<option value="Jr Accountant"> Jr Accountant </option>
<option value="Rajasthan police"> Rajasthan police </option>
<option value="SSC (10+2)"> SSC (10+2) </option>
</select>
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="subjects"> Subjects - </label>
<input type="text" class="form-control" name="subjects" placeholder="Enter your subject you want to read" value="<?php echo $subjects ;?>" required>
</div>
<div class="col-lg-6">
<label for="timing"> Classes Timing - </label>
<input type="text" class="form-control" name="timing" placeholder="Your preferred time for coaching" value="<?php echo $timing ;?>" required>
</div>
</div><br>
<div class="row">
<div class="col-lg-6">
<label for="picture"> Upload your picture <span class="required">*</span></label>
<input type="file" class="form-control" name="picture" required>
</div>
<div class="col-lg-6">
<label for="sign"> Upload your signature <span class="required">*</span></label>
<input type="file" class="form-control" name="sign" required>
</div>
</div><br>
<div class="row">
<div class="col-md-12">
<input type="checkbox" aria-label="..." name="agree_terms" value="1"> I agree with Rules and Regulations mentioned below.<br>
<input type="checkbox" aria-label="..." name="agree_cond" value="1"> I hearbly declare that Adarsh Classes can use my pictures after my selection for advertising purpose.
</div><!-- /.col-lg-6 -->
</div><!-- /.row -->
<div class="row">
<div class="col-lg-6">
<div class="form-group">
<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
</div>
</div>
</div>
</form>
The reason behind that in the input type of the HTML Page for the submit you are using <input type="button"
instead of <input type="submit". Use <input type="submit" that's work.
Example:
<input type="submit" name="" value="Submit">
Changed
<button type="text">
to
<button type="submit">
Change
button type="text" to type="button" Or input type ="submit/button"
You need to change this code:
<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
with below code :
<input type="submit" name="applyAdmission" value="Submit my application form" class="btn btn-success btn-lg btn-block" />
You also need to make sure that your wrote PHP code in same file, otherwise you have to add PHP file name in action tag in below line:
<form class="form-horizontal" id="admission_form" method="post" action="" enctype="multipart/form-data">
You also have some PHP error in your code, so you have to add first line in your PHP code and then fix your PHP Fatal error.
ini_set('display_errors', '1');
I see a little syntax error and I think fixing this will fix your issue.
Change
include ("include/header.php"), include ("include/config.php");
to
include ("include/header.php");
include ("include/config.php");
To show you the syntax error, here is an example:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 'On');
include("test.php"), include("someother.php");
The response:
Parse error: syntax error, unexpected ',' in ...\tests\includeTest.php on line 6
Incorrect input type
You should also change your button type.
Change
<button type="text"...
to
<button type="submit"...
Change <button> to <input>. Buttons can work with javascript but with only php button cant work with post data. You can not get POST data by <button>. For this you have to use <input>
Change this
<button type="text" name="submit" class="btn btn-success btn-lg btn-block" name="applyAdmission"> Submit my application form </button>
to
<input type="submit" name="applyAdmission">
Second:
Here is looking syntax error include ("include/header.php"), include ("include/config.php");
PHP requires instructions to be terminated with a semicolon at the end of each statement. Make them seperate by ; not by ,.
include ("include/header.php");
include ("include/config.php");
You can see documentation for more deep information
I am seeking some more advice on the way to handle this.
I have got one page with links to each admin member which when clicked takes their display name over. On the second page which is a form it takes that display names and populates the subject field with their display name. I need to grab the email address that is associated to that user too but use that as the email address the form on the second page gets sent to as currently my script can only send it to an email address I hard code into it.
So page one is:
<?php
$args1 = array(
'role' => 'committee',
'orderby' => 'user_nicename',
'order' => 'ASC'
);
$committee = get_users($args1);
foreach ($committee as $user) {
echo '
<a href="../contact-form?displayname=' . $user->display_name . '"><b style="font-size:18px;">
<tr>
<td style="padding: 10px;">' .$user->job_title .' - </td>
<td style="padding: 10px;">' .$user->display_name .'</td>
</tr></b></a><br><br>';
}
?>
Page two is:
<?php $displayname = $_GET['displayname'];?>
<form role="form" method="post" action="../mailuser.php">
<div class="form-group">
<input type="hidden" name="displayname" value="<?php echo $displayname ?>">
<input type="text" name="hp" class="hp" value="" alt="if you fill this field out then your email will not be sent">
</div>
<div class="form-group">
<label for="InputName">Your name</label>
<input type="name" class="form-control" id="InputName" placeholder="Enter your name" name="username">
</div>
<div class="form-group">
<label for="InputEmail">Email address</label>
<input type="email" class="form-control" id="InputEmail" placeholder="you#example.com" name="emailFrom">
</div>
<div class="form-group">
<label for="InputMsg">Message</label>
<textarea class="form-control" rows="8" id="InputMsg" placeholder="Please begin typing your message..." name="emailMessage"></textarea>
</div>
<button type="submit" class="btn btn-primary pull-right">Send</button>
</form>
And my send script has my email hard coded in as:
$mail->From = 'myemail#dummy.com';
So I need that be variable depending on which person you clicked on in the first place. It needs to be sent to both my hard coded email and also the persons email that is associated to them in the Wordpress user database.
Based on our comment discussion, you should be able to do something along the lines of the following on page two. Be sure to correct my email_address, I'm not sure if that's how get_users returns the email address or not.
<?php
$displayname = $_GET['displayname'];
$args1 = array(
'role' => 'committee',
'orderby' => 'user_nicename',
'order' => 'ASC'
);
$committee = get_users($args1);
$matchingEmail = false;
foreach ($committee as $user) {
if ( !$matchingEmail && $user->display_name == $displayname ) {
// great, we found our match
$matchingEmail = $user->email_address; // I don't know if email_address is right, double check this and modify if necessary
}
}
if ( $matchingEmail ) {
// only proceed if a matching email address is found
?>
<form role="form" method="post" action="../mailuser.php">
<div class="form-group">
<input type="hidden" name="displayname" value="<?php echo $displayname; ?>">
<input type="hidden" name="matchingEmail" value="<?php echo $matchingEmail; ?>">
<input type="text" name="hp" class="hp" value="" alt="if you fill this field out then your email will not be sent">
</div>
<div class="form-group">
<label for="InputName">Your name</label>
<input type="name" class="form-control" id="InputName" placeholder="Enter your name" name="username">
</div>
<div class="form-group">
<label for="InputEmail">Email address</label>
<input type="email" class="form-control" id="InputEmail" placeholder="you#example.com" name="emailFrom">
</div>
<div class="form-group">
<label for="InputMsg">Message</label>
<textarea class="form-control" rows="8" id="InputMsg" placeholder="Please begin typing your message..." name="emailMessage"></textarea>
</div>
<button type="submit" class="btn btn-primary pull-right">Send</button>
</form>
<?php
} else {
?>
<p>Something is wrong, I can't find your email address! Please try again.</p>
<?php
}
?>
Finally on page three, where you send the email, you can do something like:
<?php $mail->addAddress(stripslashes( $_POST["matchingEmail"] ) ); ?>