bCourtney07 Posted October 24, 2007 Share Posted October 24, 2007 I can't figure out what i'm doing wrong. I have a form that is supposed to post information to an access database (yeah not my choice to create it in access) here are the files i have: The form: <html> <head> <title>Wellness Program</title> </head> <body> <form action="WellnessSubmit.php" method="post"> <table> <tr> <td>Employee ID:</td> <td><input type="text" name="employeeid"></td> </tr> <tr> <td>Date:</td> <td><input type="text" name="date"></td> </tr> <tr> <td>Activity:</td> <td> <select name="activity"> <option value="Aerobics">Aerobics</option> <option value="BackpackingHicking">Backpacking/Hicking</option> <option value="Basketball">Basketball</option> <option value="BikeRiding">Bike Riding</option> <option value="Bowling">Bowling</option> <option value="DanceClasses">Dance Classes</option> <option value="ExerciseClass">Exercise Class</option> <option value="Football">Football</option> <option value="Golfing">Golfing</option> <option value="IceSkating">Ice Skating</option> <option value="MountainClimbing">Mountain Climbing</option> <option value="Other">Other</option> <option value="Racquetball">Racquetball</option> <option value="RollerBladingRollerSkating">Roller Blading/Roller Skating</option> <option value="Rowing">Rowing</option> <option value="Shuffleboard">Shuffleboard</option> <option value="Softball">Softball</option> <option value="Swimming">Swimming</option> <option value="TaiChi">Tai Chi</option> <option value="Tennis">Tennis</option> <option value="Volleyball">Volleyball</option> <option value="WalkingRunningJogging">Walking/Running/Jogging</option> <option value="Yoga">Yoga</option> </select> </td> </tr> <tr> <td>Miles:</td> <td><input type="text" name="miles"></td> </tr> <tr> <td><input type=submit value=Submit></td> <td><input type=reset value=Reset></td> </tr> </table> </form> The WellnessSubmit.php file: <?php require("config.php"); if($_GET['action'] == 'post') { if($_POST['employeeid'] == '' || $_POST['date'] == '' || $_POST['activity'] == '' || $_POST['miles'] == '') { //if everything is not filled in than prints out error message echo error("blank"); exit; } $conn->Execute("INSERT INTO Activity_Log ('Employee_ID', 'Date', 'Activity', 'Miles') VALUES('$_employeeid', '$_date', '$_activity', '$_miles') ") or die(ADODB_error()); } function error($error) { //if error is equal to blank if($error == 'blank') { echo "<b>Please fill in all the required fields before submitting</b>"; } } ?> the config.php file: <?php $db_conn = new COM("ADODB.Connection"); $connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./Copy of HR Employee Wellness Program.mdb").";"; $db_conn->open($connstr); ?> Now. Here is the error i'm getting ??? Notice: Undefined index: action in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 7 Any help in figuring this out would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/ Share on other sites More sharing options...
The Little Guy Posted October 24, 2007 Share Posted October 24, 2007 try changing all of these: $_POST['employeeid'] == '' to if(empty($_POST['employeeid'])|| empty($_POST['date']) || empty($_POST['activity']) || empty($_POST['miles'])) Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377273 Share on other sites More sharing options...
bCourtney07 Posted October 24, 2007 Author Share Posted October 24, 2007 Thanks, I tried it but i still get the same error Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377278 Share on other sites More sharing options...
Zane Posted October 24, 2007 Share Posted October 24, 2007 your script will work if you change this line </pre> <form action="WellnessSubmit.php" method="post">< to </pre> <form action="WellnessSubmit.php?action=post" method="post">< Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377281 Share on other sites More sharing options...
bCourtney07 Posted October 24, 2007 Author Share Posted October 24, 2007 Okay that fixed that error! Thank you soo so much! Now i've got this one Fatal error: Call to a member function on a non-object in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 14 ??? this is just frustrating Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377293 Share on other sites More sharing options...
Zane Posted October 24, 2007 Share Posted October 24, 2007 $conn->Execute("INSERT INTO Activity_Log should be $db_conn->.....etc Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377300 Share on other sites More sharing options...
bCourtney07 Posted October 24, 2007 Author Share Posted October 24, 2007 well i noticed and changed that right after i posted. but now....i have a bunch more Notice: Undefined variable: _Employee_ID in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16 Notice: Undefined variable: _Date in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16 Notice: Undefined variable: _Activity in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16 Notice: Undefined variable: _Miles in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16 Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] The INSERT INTO statement contains the following unknown field name: ''Employee_ID''. Make sure you have typed the name correctly, and try the operation again. in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16 Fatal error: Call to undefined function: adodb_error() in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 17 Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377308 Share on other sites More sharing options...
Zane Posted October 24, 2007 Share Posted October 24, 2007 use backtics for the field name instead of quotes (`Employee_ID`, `Date`, `Activity`, `Miles`) and put curly braces around the variables VALUES ('{$_employeeid}', '{$_date}', '{$_activity}', '{$_miles}' Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377324 Share on other sites More sharing options...
bCourtney07 Posted October 25, 2007 Author Share Posted October 25, 2007 Okay so here is my php file again <?php require("config.php"); if($_GET['action'] == 'post') { if(empty($_POST['Employee_ID'])|| empty($_POST['Date']) || empty($_POST['Activity']) || empty($_POST['Miles'])) { //if everything is not filled in than prints out error message echo error("blank"); exit; } else { $db_conn->Execute("INSERT INTO Activity_Log (`Employee_ID`, `Date`, `Activity`, `Miles`) VALUES ('{$_Employee_ID}', '{$_Date}', '{$_Activity}', '{$_Miles}')" or die(ADODB_error()) } } function error($error) { //if error is equal to blank if($error == 'blank') { echo "Please fill in all the required fields before submitting"; } } ?> and this is the error it keeps giving me Parse error: parse error, unexpected '}' in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 16 First it was an unexpected semicolon so i deleted it, now i get this. i don't know ??? and i don't know what to do. i don't see any missing " ' s or anything :-\ Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377767 Share on other sites More sharing options...
Zane Posted October 25, 2007 Share Posted October 25, 2007 here at the end $_Miles}')" the parentheses goes after the double quote Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377774 Share on other sites More sharing options...
bCourtney07 Posted October 25, 2007 Author Share Posted October 25, 2007 <?php require("config.php"); if($_GET['action'] == 'post') { if(empty($_POST['Employee_ID'])|| empty($_POST['Date']) || empty($_POST['Activity']) || empty($_POST['Miles'])) { //if everything is not filled in than prints out error message echo error("blank"); exit; } else { $db_conn->Execute("INSERT INTO Activity_Log (`Employee_ID`, `Date`, `Activity`, `Miles`) VALUES ('{$_Employee_ID}', '{$_Date}', '{$_Activity}', $_Miles}')") or die(ADODB_error()); } } function error($error) { //if error is equal to blank if($error == 'blank') { echo "Please fill in all the required fields before submitting"; } } ?> Notice: Undefined variable: _Employee_ID in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15 Notice: Undefined variable: _Date in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15 Notice: Undefined variable: _Activity in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15 Notice: Undefined variable: _Miles in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15 Warning: (null)(): Invoke() failed: Exception occurred. Source: Microsoft OLE DB Provider for ODBC Drivers Description: [Microsoft][ODBC Microsoft Access Driver] Syntax error in query expression '}')'. in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15 Fatal error: Call to undefined function: adodb_error() in F:\InetPub\wwwroot\EmployeeWellnessProgram\WellnessSubmit.php on line 15 :'( this is beyond frustrating now. You have no idea how much i appreciate all of your help. Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377779 Share on other sites More sharing options...
Zane Posted October 25, 2007 Share Posted October 25, 2007 don't know why I didn't see this earlier $_Employee_ID}', '{$_Date}', '{$_Activity}', $_Miles.....don't exist according to your script you need to have '{$_POST['Employee_ID']}', '{$_POST['Date']}', '{$_POST['Activity']}', '{$_POST['Miles']}' and adodb_error() doesn't exist as the last error states just use a simple error statement $db_conn->Execute("INSERT INTO Activity_Log (`Employee_ID`, `Date`, `Activity`, `Miles`) VALUES ('{$_POST['Employee_ID']}', '{$_POST['Date']}', '{$_POST['Activity']}', '{$_POST['Miles']}')") or die("Error with your ... thing"); Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377782 Share on other sites More sharing options...
bCourtney07 Posted October 25, 2007 Author Share Posted October 25, 2007 I cannot thank you enough! You have saved my life!! Thank you!!!!!!! ;D Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377783 Share on other sites More sharing options...
bCourtney07 Posted October 25, 2007 Author Share Posted October 25, 2007 Okay i'm dumb and forgot something... i need to verify the employeeid before it submits. the employeeid's are stored in a table named analyzer_query. $db_conn->Execute("SELECT * FROM analyzer_query WHERE Employee_ID = ($_POST['Employee_ID'])") or die("Please enter correct EmployeeID"); is this correct? if it is where should i put it? Quote Link to comment https://forums.phpfreaks.com/topic/74641-solved-php-error-notice-undefined-index/#findComment-377843 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.