Forum Moderators: coopster
Can anyone please help as I am a complete PHP newbie.
I have been using a PHP form script which works fine, but I have now added a drop down menu to the form called 'location' and I do not know how to change the script so that it lists the selected option in the email. I presume I have to write some code after .$location. to handle <select> I have made various attemps and failed miserably :o( if anyone could help I would really appreciate it.
<?php
}
else // Try to upload
{
// Do rest
$origname=$file_name;
$time=time();
$fname=$time.".".$file_name;
$fname2=$uploads.$fname;
if (@copy($file,"$fname2"))
{
unlink($file);
//$headers="MIME-Version: 1.0\n";
//$headers.="Content-Type: text/html; charset=iso-8859-1\n";
//if (isset($email) && ($email <> "" ))
//{ $headers.="From: ".$email."\n"; }
//else
//{ $headers.="From: form@mydomain.com"; }
if (isset($email) && ($email <> "" ))
{ $from=$email; }
else
{ $from="form@mydomain.com"; }
$message="
<table><TR>
<TD align=right>
<B>Location:</B>
</TD><TD align=left>"
.$location.
</TD></TR></table>
";
$message2=$message."
Message id code: <B>".$time."</B><P>
";
sendmime($fname2,$origname,$to,$from,"website Submission",$message2);
?>
$message2 seems to be the variable that holds the massage for the email.
If the form is set up to post to this script then you would need to access it's value via the $_POST array. Inside that array you will be able to find the value by using the name from the <select> tag.
if our select had a name of mydrop then it would have an opening tag like so
<select name="mydrop">
we can then output it's value this after it is submitted like so
echo $_POST['mydrop'];
so you could then append it to your message
$message2 .= '<p>dropdown value: ' . $_POST['mydrop'];
play around with that and it should get you sorted.