Hello new friends. Just getting into PHP so I'm sure to be browsing around here quite a bit. Ran into my first problem and was hoping for some help. Simple contact list with multiple EmailTo options. So far I'm getting notices for undefined offset on line 12 and undefined index on line 33, 185, 186 and 187. If at all possible please talk to me like I'm five... without replacing all R's with W's. Thanks.
Code Below
<form method="POST" action="contact_test.php">
<table width="90%" cellspacing="5">
<tr>
<td><div align="right">Email To: </div></td>
<td><select name="emailto">
<option value="test00" selected><b>General 00</b></option>
<option value="test01" style="background-color:darkgray;line-height:30px;color:white;"><strong>General 01</strong></option>
</select></td>
</tr>
<tr>
<td><div align="right">Name:</div></td>
<td><input id="Name" name="Name" type="text" tabindex="1" size="30" /></td>
</tr>
<tr>
<td><div align="right">Address:</div></td>
<td><input id="Name" name="Name" type="text" tabindex="2" size="30" /></td>
</tr>
<tr>
<td><div align="right">Address 2: </div></td>
<td><input id="Name" name="Name" type="text" tabindex="3" size="30" /></td>
</tr>
<tr>
<td><div align="right">Phone:</div></td>
<td><input id="Name" name="Name" type="text" tabindex="4" size="30" /></td>
</tr>
<tr>
<td><div align="right">Email:</div></td>
<td><input id="EmailFrom" name="EmailFrom" type="text" tabindex="5" size="30" /></td>
</tr>
<tr>
<td><div align="right">Best Time to Contact You: </div></td>
<td><input id="Name" name="Name" type="text" tabindex="6" size="30" /></td>
</tr>
<tr>
<td><div align="right">Products/Services of Interest: </div></td>
<td><input id="Name" name="Name" type="text" tabindex="7" size="30" /></td>
</tr>
<tr>
<td valign="top"><div align="right">Questions or Comments: </div></td>
<td><textarea name="Message" tabindex="8" rows="10" cols="24" style="width:300px;"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="post" id="post" value=" Send " />
<input type="reset" value=" Reset " /></td>
</tr>
</table>
</form>
PHP file-
<?php
session_start();
//Email Validation
function checkEmail($email)
{
if(eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $email))
{
return FALSE;
}
list($Username, $Domain) = split("@",$email);
if(@getmxrr($Domain, $MXHost))
{
return TRUE;
}
else
{
if(@fsockopen($Domain, 25, $errno, $errstr, 30))
{
return TRUE;
}
else
{
return FALSE;
}
}
}
// get posted data into local variables
switch ($_POST['emailto']){
case "test00":
$emailto = "test00@gmail.com";
break;
case "test01":
$emailto = "test01@gmail.com";
break;
}
$EmailFrom = Trim(stripslashes($_POST['EmailFrom']));
$Name = Trim(stripslashes($_POST['Name']));
$Message = Trim(stripslashes($_POST['Message']));
// validation
$validationOK=true;
if(checkEmail($EmailFrom) == FALSE){
$error_msg[] = "Please enter in a valid email address.";
}
if (Trim($Name)==""){
$error_msg[] = "Please enter in a name.";
}
if (Trim($Phone)=="") {
$error_msg[] = "Please enter in a phone number.";
}
if (Trim($Message)==""){
$error_msg[] = "Please enter in a message.";
}
//triggers error message
if ($error_msg) {
$_SESSION['error_msg'] = $error_msg;
header ('Location: default.asp');
exit();
}
//sends email
else {
$Body = "You have a new email from $Name.\n Address\n $Address2\n $Phone\n\n Reply to $EmailFrom.\n $BestTime\n $ProdServ\n\n $Name says,\n $Message";
$success = mail($emailto, $ProdServ, $Body);
}
//redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=../contact_success.asp\">";
}
else{
print "Nothing sent.";
}
?>
And no, I'm not getting an email. Yes, the emails have been changed for the purpose of posting. Originally there was close to 100 options so I've narrowed it to 2 for the sake of this post.
Thanks in advance for any help.