The following three pages plocation.php, presults.php and psubmit.php provide a means by which a 'searcher' can choose a location. presults.php then displays the details associated with the location then on approval passes them to psubmit which on submit passes the searchers details to the locations whilst at the same time presults will pass a message back to the searcher confirming the searchers details to the searcher.
Most of this works ok but I can't seem to work out how to pass the searchers details to the matching locations email addresses in psubmit.
I guess I need to pass the loaction choice from presults to psubmit.
I wouls like to do away with psubmit and have the whole process contained on presults.
In essence I want to send searchers details to multiple locations following approval by the searcher for this.
I would apreciate any advice on this.
I am very new to php/mysql but have made good progress over the past three months that I have spent 'fiddling about'. I know nothing about classes, oops or other sophistications. help, Thanks.
The programs:
1.
/ Program: plocation.php.
Desc: presents locations to choose from.
*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title> location</title>
</head>
<body background="images/bk.jpg">
<table width="200" border="0" align="center">
<tr>
<th height="102" scope="row"><div align="left"><font color="white" size="5"><b><font color="#A6FFA6"><img src="images/header6.jpg" width="864" height="102" /><strong><font color="#FFFFFF" size="3" face="Trebuchet MS"><br />
Choose the location</font></strong></font></b></font></div></th>
</tr>
</table>
<p align="center"><font face="Trebuchet MS">Here you can choose from towns and counties of England, Ireland, Wales
and Scotland.
</font></p>
<form action='presults.php' method='POST'>
<div align="center">
<p><font size="1" face="Trebuchet MS">If you cannot find the town that you
want on the list, then please choose the nearest location to it </font><font face="Trebuchet MS"><br />
UK
counties and towns
<select name="location">
<option value="">
<option value="">BEDFORDSHIRE
<option value="Bedford">Bedford
<option value="Westmeath">Westmeath
<option value="Wexford">Wexford
<option value="Wicklow">Wicklow</option>
</select>
</font></p>
<p>
<input type='submit' value='Click here'>
</p>
<p><font face="Trebuchet MS">Other countries,<br />
</font><font face="Trebuchet MS"><a href="pintloc.php">click here</a> to
go to international section. </font></p>
</div>
</form>
</body>
</html>
2.
<?php
/ Program: presults.php
Desc: Displays results.
*/
session_start();
if (@$_SESSION['auth'] != "yes")
?>
<html>
<head><title>results</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body background="images/bk.jpg">
<table width="200" border="0" align="center">
<tr>
<th height="102" scope="row"><div align="left"><font color="white" size="5"><b><font color="#A6FFA6"><img src="images/header6.jpg" width="864" height="102" /><strong><font color="#FFFFFF" size="3" face="Trebuchet MS"><br />
choose the location </font></strong></font></b></font></div></th>
</tr>
</table>
<p align="center">
<?php
session_start();
$connection = mysql_connect('host', 'username', 'password')
or die ("couldn't connect to server");
$db = mysql_select_db('dbname',$connection)
or die ("Couldn't select database");
/ Table1 contains details of searchers/
$query = "SELECT email FROM table1
WHERE username =\"{$POST['username']}\"";
/ Table2 contains details of locations/
$query = "SELECT lname, fname, city, location, email, street, phone, FROM table2
WHERE location =\"{$POST['location']}\"";
$result = mysql_query($query)
or die ("Couldn't execute query.");
/ Display results in a table /
echo "<h1><center>You chose $location </center></h1>";
echo "<center>If no selection appears below, it means that there is no space available in your chosen area. <br>Try choosing somewhere close by or another area.</center>";
echo "<center>";
echo "<table border=1 width=600 cellspacing=5 cellpadding=5 bordercolor=#333333 bgcolor=#FFFFFF>";
echo "</center>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr>\n
<td><strong><font face=Arial, Helvetica, sans-serif size=2>Town:<br>$location</font></strong></td>\n
<td>Name of premises:<br>$city<br>$location<br>$country</td>\n
<td>Contact:<br>$fname <br>$lname</td>\n
<td>Address:<br>$street, $city</td>\n
<td>Phone:<br>$phone<br></td>\n
<td>Email:<br><a href=mailto:>$email</a><br></td>\n
</tr>\n";
}
echo "</table>\n";
/ send email to searcher / #153
$emess.= "\n\n\t$username\n\t$password\n\n";
$emess.= "We appreciate your interest";
$emess.= " look forward to a new location. \n\n";
$emess.= "If you have any questions or problems,";
$emess.= " email info@manley.omnia.co.uk";
$ehead="From: info@manley.omnia.co.uk\r\n"; #161
$subj = "location enquiry";
$mailsend=mail("$email","$subj","$emess","$ehead");
?>
<form action='psubmit.php' method='POST'>
<p><font size="1" face="Trebuchet MS">Click the 'submit' button to send your details to the locations of your choice.</font><br />
UK
counties and towns
<select name="location">
<option value="<?php echo $location;?>" SELECTED><?php echo $location;?></option>
</option>
</select>
<input type='submit' value='Click here'>
</form>
3.
<?php
/ Program: psubmit.php
Desc: Allows the searcher to approve the sending of their details to the chosen locations.
*/
session_start();
if (@$_SESSION['auth'] != "yes")
?>
<html>
<head><title>Submit</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body background="images/bk.jpg">
<table width="200" border="0" align="center">
<tr>
<th height="102" scope="row"><div align="left"><font color="white" size="5"><b><font color="#A6FFA6"><img src="images/header6.jpg" width="864" height="102" /><strong><font color="#FFFFFF" size="3" face="Trebuchet MS"><br />
Now choose the location </font></strong></font></b></font></div></th>
</tr>
</table>
<p align="center">
<?php
$connection = mysql_connect('host', 'username', 'password')
or die ("couldn't connect to server");
$db = mysql_select_db('dbname',$connection)
or die ("Couldn't select database");
$query = "SELECT email FROM table2
WHERE location =\"{$_POST['location']}\"";
$result = mysql_query($query)
or die ("Couldn't execute query.");
/ Display results in a table /
echo "<h1><center>You chose $location </center></h1>";
echo "<center>If no selection appears below, it means that there is no space available in your chosen area. <br>Try choosing somewhere close by or another area.</center>";
echo "<center>";
echo "<table border=1 width=600 cellspacing=5 cellpadding=5 bordercolor=#333333 bgcolor=#FFFFFF>";
echo "</center>";
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr>\n
<td><strong><font face=Arial, Helvetica, sans-serif size=2>Town:<br>$location</font></strong></td>\n
<td>Name of premises:<br>$city<br>$location<br>$country</td>\n
<td>Contact:<br>$fname <br>$lname</td>\n
<td>Address:<br>$street, $city</td>\n
<td>Phone:<br>$phone<br></td>\n
<td>Email:<br><a href=mailto:>$email</a><br></td>\n
</tr>\n";
}
echo "</table>\n";
//connect to database
$connection = mysql_connect('host', 'root', 'password')
or die ("couldn't connect to server");
$db = mysql_select_db('dbname',$connection)
or die ("Couldn't select database");
//get emails from locations//
$query = "SELECT email FROM table2";
$result = mysql_query($sql,$conn) or die(mysql_error());
//create a From: mailheader
$headers = "From: Your Mailing List <you@yourdomain.com>";
//loop through results and send mail
while ($row = mysql_fetch_array($result)) {
set_time_limit(0);
$email = $row['email'];
mail("$email", stripslashes($_POST[subject]), stripslashes($_POST[message]), $headers);
echo "newsletter sent to: $email<br>";
}
}
?>
</body></html>
End.
I hope that this lot is not too messy for you and that you can find the time to sort it for me.
I have tried to 'tailor' the coding for you, please forgive any mistakes I may have overlooked in this process.
Thanks to you all
Paul