Please can you help me to get my form to work.

A

Anonymous

Guest
Hello, I am trying to create a catch return form for my fishing club. I am going round in circles. I have read lots of articles and referred to various books but I am struggling. I think I am on the right track but I need some expert advice please. The html form seems to work but I can't get it to send the email. Can't see what I am doing wrong. Can anyone help me? Thank you.
Here is the code I have come up with so far:

<?php
session_start();
if (!isset($_POST['submit']))
{
echo "error, you need to submit the form!";
}
$headers = "From: adminteam@romaldkirkanglers.org.uk";
$recipient="ronwoodtd@gmail.com";
$subject="Catch Report";
$angler_name=$_POST['angler_name'];
$wkday=$_POST['wkday'];
$day=$_POST['day'];
$month=$_POST['month'];
$year=$_POST['year'];
$troutcaught=$_POST['troutcaught'];
$graylingcaught=$_POST['graylingcaught'];
$seatroutcaught=$_POST['seatroutcaught'];
$salmoncaught=$_POST['salmoncaught'];
$totalfishcaught=$_POST['totalfishcaught'];
$message = "Angler: $angler_name\n";
$message .= "Weekday: $wkday";
$message .= "Day: $day";
$message .= "Month: $month";
$message .= "Year: $year\n";
$message .= "Trout: $troutcaught\n";
$message .= "Grayling: $graylingcaught\n";
$message .= "Seatrout: $seatroutcaught\n";
$message .= "Salmon: $salmoncaught\n";
$message .= "Total fish caught: $totalfishcaught";

/* limit line length to 70 characters */
$message =wordwrap($message, 70);

$mailSent = mail($recipient, $subject, $message, "From: $headers");
if ($mailSent) {
// redirect the page
header('Location: http://www.romaldkirkanglers.org.uk/index.php');
exit;
}
?>

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Catch Report</title>
<meta name="description" content="Anglers catch report">
<meta name="viewport" content="width=device-width">
<?php
require('inc/stylesheets.html');
?>

</head>
<body>
<div class="FlexWrapper">
<?php
require('inc/FlexHeader.html');
?>
<div class="FlexItems FlexContent">
<div class="ContentWrapper">

<h1>Catch Report</h1>
<p>Today is: <?php echo date('l \, jS F Y ');?></p>

<form name="catches" action="catchreport.php" method="post">

<label for="angler_name"><strong>Angler name</strong></label>
<select name="angler_name" id="angler" input type="text">
<?php
$angler_name = array('', 'R Wood', 'F Smith', 'J Bloggs');
foreach($angler_name as $value) {
echo"<option>$value</option>";}
?></select>
<br>
<br>

<label for="wkday"><strong>Date fished</strong></label>
<select name="wkday" input type="text">
<option selected value=""></option>
<option value="Monday">Monday</option>
<option value="Tuesday">Tuesday</option>
<option value="Wednesday">Wednesday</option>
<option value="Thursday">Thursday</option>
<option value="Friday">Friday</option>
<option value="Saturday">Saturday</option>
<option value="Sunday">Sunday</option>
</select>

<label for="day"><strong>Day</strong></label>
<select name="day" input type="text"><?php
for ($i = 0; $i <= 31; $i++) {
echo "<option value=\"$i\">$i</option>\n";
}
?></select>

<label for="month"><strong>Month</strong></label>
<select name="month" input type="text">
<option selected value=""></option>
<option value="January">January</option>
<option value="February">February</option>
<option value="March">March</option>
<option value="April">April</option>
<option value="May">May</option>
<option value="June">June</option>
<option value="July">July</option>
<option value="August">August</option>
<option value="September">September</option>
<option value="October">October</option>
<option value="November">November</option>
<option value="December">December</option>
</select>

<label for="year"><strong>Year</strong></label>
<select name="year" input type="number"><?php
for ($i = 2021; $i <= 2032; $i++) {
echo "<option value=\"$i\">$i</option>";
}
?></select>
<br>
<br>
<label for="troutcaught"><strong>Trout caught</strong></label>
<select name="troutcaught" input type="number"><?php
for ($i = -1; $i <=35; $i++) {
echo "<option value=\"$i\">$i</option>";
}
?></select>
<br>
<br>
<label for="graylingcaught"><strong>Grayling caught</strong></label>
<select name="graylingcaught" input type="number"><?php
for ($i = -1; $i <=35; $i++) {
echo "<option value=\"$i\">$i</option>";
}
?></select>
<br>
<br>
<label for="seatroutcaught"><strong>Seatrout caught</strong></label>
<select name="seatroutcaught" input type="number"><?php
for ($i = -1; $i <=10; $i++) {
echo "<option value=\"$i\">$i</option>";
}
?></select>
<br>
<br>
<label for="salmoncaught"><strong>Salmon caught</strong></label>
<select name="salmoncaught" input type="number"><?php
for ($i = -1; $i <=5; $i++) {
echo "<option value=\"$i\">$i</option>";
}
?></select>
<br>
<br>
<label for="totalfishcaught"><strong>Total fish caught</strong></label>
<select name="totalfishcaught" input type="number"><?php
for ($i = -1; $i <=50; $i++) {
echo "<option value=\"$i\">$i</option>";
}
?></select>

<p><input type="submit" name="submit" value="submit" /></p>

</form>

</div>
</div>
<?php
require('inc/FlexSideOne.html');
?>
<?php
require('inc/FlexSideTwo.html');
?>
<?php require('inc/FlexFooter.html');
?>
</div>
</body>

</html>
 
I have managed to get my form to work now. Thanks for looking.
 
Back
Top