maplins Posted February 12, 2010 Share Posted February 12, 2010 Hi, I'm a php newbie and I'm stuck. I have a form with a dynamic field (a list of available training courses, pulled from mysql, in a <select> dropdown menu). How do I deal with this in the handling script? I want the form data to go into a different database along with the applicant's details etc, email the applicant with confirmation of receipt etc and when setting the variables, $_POST[$variable] doesn't work. Here is the code from the form $results=mysql_query("select courses_available from courses_database") or die(mysql_error()); echo "<select name=\"course applied for\">\n"; while($row=mysql_fetch_array($results)){ $course=$row[course]; echo "<option value=\"$course\">$course"; echo "</option>\n"; } echo "</select>\n"; Here is the list of variables in the handling script so you can see what I'm getting at $name=$_POST['name']; $address1=$_POST['address1']; $address2=$_POST['address2']; $address3=$_POST['address3']; $email=$_POST['email']; $phone=$_POST['phone']; $dob=$_POST['dob']; $experience=$_POST['experience']; $course_name=$_POST['$course']; Can anyone help? Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/191899-_postvariable/ Share on other sites More sharing options...
premiso Posted February 12, 2010 Share Posted February 12, 2010 echo "<select name=\"course applied for\">\n"; Should be: echo "<select name=\"course_applied\">\n"; As spaces cause some funky issues. Then to call that: $course_applied = $_POST['course_applied']; A side note, you use "$course" inside of single quotes, that is taken literally and not evaluated to the value. Either encase it in double quotes or remove the quotes all together. Hope that helps. Quote Link to comment https://forums.phpfreaks.com/topic/191899-_postvariable/#findComment-1011477 Share on other sites More sharing options...
maplins Posted February 12, 2010 Author Share Posted February 12, 2010 Thanks! I must've been staring at the screen too long and couldn't see where I was going wrong... Quote Link to comment https://forums.phpfreaks.com/topic/191899-_postvariable/#findComment-1011481 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.