I am trying to setup a simple mail script from an html form that includes a dropdown list but on the line where I declare the selected variable I am getting an error message: Parse error: syntax error, unexpected '='........
My html form includes the dropdown list as follows:
<select name="buying-selling" id="buying-selling">
<option value="none_selected" selected="selected">Please Select</option>
<option value="buying_property">Buying a Property</option>
<option value="selling_property">Selling a Property</option>
<option value="sales_updates">Sales Updates</option>
</select>
And at the top of my email script I have:
<?php
if ($_POST['Submit']!="")
{
$name=$_POST['name'];
$emailaddr=$_POST['emailaddr'];
$buying-selling=$_POST['buying-selling'];
$message=$_POST['message'];
.......followed by all the mailheaders data
But when I try and process the form I am getting the "Parse error: syntax error, unexpected '='" for the line that contains the POST['buying-selling'] element.
Is there a different syntax for declaring items from a dropdown list?
I am new to coding for mail scripts so any advice would be very welcome.
Many thanks
$buying-selling
is not a valid variable name. Try $buying_selling
instead.