0

Three files. A simple contact form. I am trying to get checkboxes & dropdowns to work, but so far, only (1) dropdown works, and after going at it for hours, have found no error in the <form> itself. Not a PHP genius, so maybe it has something to do with that..?

Thanks in advance! An answer ASAP would be most greatly appreciated!


contact.php

<form method="post" action="contactengine.php">
				<table>
					<tr>
						<td class="left"><label for="Name">Name:</label></td>
						<td><input type="text" name="Name" /></td>
					</tr>
					<tr>
						<td class="left"><label for="State">State:</label></td>
						<td><select name="State" size="1">
	<option value="AL">Alabama</option>
	<option value="AK">Alaska</option>
	<option value="AZ">Arizona</option>
	<option value="AR">Arkansas</option>
	<option value="CA">California</option>
	<option value="CO">Colorado</option>
	<option value="CT">Connecticut</option>
	<option value="DE">Delaware</option>
	<option value="DC">Dist of Columbia</option>
	<option value="FL">Florida</option>
	<option value="GA">Georgia</option>
	<option value="HI">Hawaii</option>
	<option value="ID">Idaho</option>
	<option value="IL">Illinois</option>
	<option value="IN">Indiana</option>
	<option value="IA">Iowa</option>
	<option value="KS">Kansas</option>
	<option value="KY">Kentucky</option>
	<option value="LA">Louisiana</option>
	<option value="ME">Maine</option>
	<option value="MD">Maryland</option>
	<option value="MA">Massachusetts</option>
	<option value="MI">Michigan</option>
	<option value="MN">Minnesota</option>
	<option value="MS">Mississippi</option>
	<option value="MO">Missouri</option>
	<option value="MT">Montana</option>
	<option value="NE">Nebraska</option>
	<option value="NV">Nevada</option>
	<option value="NH">New Hampshire</option>
	<option value="NJ">New Jersey</option>
	<option value="NM">New Mexico</option>
	<option value="NY">New York</option>
	<option value="NC">North Carolina</option>
	<option value="ND">North Dakota</option>
	<option value="OH">Ohio</option>
	<option value="OK">Oklahoma</option>
	<option value="OR">Oregon</option>
	<option value="PA">Pennsylvania</option>
	<option value="RI">Rhode Island</option>
	<option value="SC">South Carolina</option>
	<option value="SD">South Dakota</option>
	<option value="TN">Tennessee</option>
	<option value="TX">Texas</option>
	<option value="UT">Utah</option>
	<option value="VT">Vermont</option>
	<option value="VA">Virginia</option>
	<option value="WA">Washington</option>
	<option value="WV">West Virginia</option>
	<option value="WI">Wisconsin</option>
	<option value="WY">Wyoming</option>
</select></td>
					</tr>
					<tr>
						<td class="left"><label for="Email">Email:</label></td>
						<td><input type="text" name="Email" /></td>
					</tr>
					<tr>
						<td class="left"><label for="Tel">Phone:</label></td>
						<td><input type="text" name="Tel" /></td>
					</tr>
					<tr><td class="left"><label for="Skill1">Skill 1:</label></td>
					<td><select name="Skill1" size="1">
  <option value="Website Creation">Website Creation</option>
  <option value="Program Development">Program Development</option>
  <option value="Web Development">Web Development</option>
  <option value="Computer Assistance">Computer Assistance</option>
  <option value="Network Debugging">Network Debugging</option>
  <option value="System Fixes">System Fixes</option>
  <option value="Site Administration">Site Administration</option>
  <option value="Hardware Troubleshooting">Hardware Troubleshooting</option>
</select></td></tr>
<tr><td class="left"><label for="Skill2">Skill 2:</label></td>
					<td><select name="Skill2" size="1">
  <option  value="Website Creation">Website Creation</option>
  <option  value="Program Development">Program Development</option>
  <option  value="Web Development">Web Development</option>
  <option  value="Computer Assistance">Computer Assistance</option>
  <option  value="Network Debugging">Network Debugging</option>
  <option  value="System Fixes">System Fixes</option>
  <option  value="Site Administration">Site Administration</option>
  <option  value="Hardware Troubleshooting">Hardware Troubleshooting</option>
</select></td></tr>
<tr><td class="left"><label for="Skill3">Skill 3:</label></td>
					<td><select name="Skill3" size="1">
  <option value="Website Creation">Website Creation</option>
  <option value="Program Development">Program Development</option>
  <option value="Web Development">Web Development</option>
  <option value="Computer Assistance">Computer Assistance</option>
  <option value="Network Debugging">Network Debugging</option>
  <option value="System Fixes">System Fixes</option>
  <option value="Site Administration">Site Administration</option>
  <option value="Hardware Troubleshooting">Hardware Troubleshooting</option>
</select></td></tr>
<tr>
						<td class="left"><label for="Lang">Language Profficiencies:</label></td>
						<td>
						<input type="checkbox" name="Lang" value="html" />HTML
						<input type="checkbox" name="Lang" value="css" />CSS
						<input type="checkbox" name="Lang" value="ajax" />AJAX
						<input type="checkbox" name="Lang" value="dhtml" />DHTML<br>
						<input type="checkbox" name="Lang" value="xhtml" />XHTML
						<input type="checkbox" name="Lang" value="aspnet" />ASP.NET
						<input type="checkbox" name="Lang" value="javascript" />Javascript
						<input type="checkbox" name="Lang" value="xml" />XML<br>
						<input type="checkbox" name="Lang" value="java" />Java
						<input type="checkbox" name="Lang" value="c++" />C++
						<input type="checkbox" name="Lang" value="c#" />C#
						<input type="checkbox" name="Lang" value="python" />Python<br>
						<input type="checkbox" name="Lang" value="prolog" />Prolog
						<input type="checkbox" name="Lang" value="none" />None
						</td>
					</tr>
					<tr>
						<td class="left"><label for="Message">Message:</label></td>
						<td><textarea name="Message" rows="20" cols="60"></textarea></td>
					</tr>
				</table>
				
				
								
				<input type="submit" name="submit" value="Submit" class="link1" />
			</form>

contactengine.php

<?php
$EmailFrom = "****************"; //censored the email, incase you think I made a mistake
$EmailTo = "****************";   //in not putting an email address
$Subject = "ExperienceBoost Submission";
$Name = Trim(stripslashes($_POST['Name'])); 
$State = Trim(stripslashes($_POST['State'])); 
$Email = Trim(stripslashes($_POST['Email'])); 
$Tel = Trim(stripslashes($_POST['Tel'])); 
$Skill1 = Trim(stripslashes($_POST['Skill 1']));
$Skill2 = Trim(stripslashes($_POST['Skill 2']));
$Skill3 = Trim(stripslashes($_POST['Skill 3']));
$Lang = Trim(stripslashes($_POST['Lang']));
$Message = Trim(stripslashes($_POST['Message'])); 

// validation
$validationOK=true;
if (!$validationOK) {
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
  exit;
}

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "State: ";
$Body .= $State;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Phone: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Skill 1: ";
$Body .= $Skill1;
$Body .= "\n";
$Body .= "Skill 2: ";
$Body .= $Skill2;
$Body .= "\n";
$Body .= "Skill 3: ";
$Body .= $Skill3;
$Body .= "\n";
$Body .= "Languages: ";
$Body .= $Lang;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";

// send email 
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

// redirect to success page 
if ($success){
  print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.php\">";
}
else{
  print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
}
?>

Contactthanks.php is simply a file with 'thank you for submitting your information'. As mentioned, I need a response on what is exactly the problem as soon as possible. To summarize my predicament, I basically cannot have more than (1) working dropdown box (that being the states dropdown). I would like to have the Skill dropdowns working as well as the Languages checkbox. I am 99% sure that the code for these items is correct, at least the <form> code anyway. Again, not a PHP wiz, so will appreciate all the help I can get!

-Zjbarden

5
Contributors
6
Replies
7
Views
5 Years
Discussion Span
Last Post by ko ko
0

change line no. 9,10,11 in Contactthanks.php as below:

$Skill1 = Trim(stripslashes($_POST['Skill1']));
$Skill2 = Trim(stripslashes($_POST['Skill2']));
$Skill3 = Trim(stripslashes($_POST['Skill3']));

This will work for you.

0

Maybe because of this?

$Skill1 = Trim(stripslashes($_POST));

When the name of the select does not have space in it: Skill1

1

Skill 1, Skill 2 , Skill 3 are with space in POST and no space at your html code.
Other thing is about Trim, use not capitalized letters trim().
I know it will work in both ways but you should make it as its on standard.

0

Thank you so much!! It was late, though I can't believe I missed that; such a simple error. My only question remains....how to get the checkbox working in that it will POST multiple selections and not just the one closest to the end of the list. I've tried placing them into a Lang[] array but that just hasn't seemed to be working...

0

Nevermind! I've got it working! Thank you all who have helped--a giant kudos to you! Wish I could karma++ you more... :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.