june_c21 Posted December 17, 2007 Share Posted December 17, 2007 hi, i'm stuck in this error code : <?php session_start(); $host = 'localhost'; $user = 'root'; $password = 'admin'; $dbase = 'staff'; $dblink = mysql_connect($host,$user,$password); mysql_select_db($dbase,$dblink); $staff_no = $_POST['staff_no']; $position = $_POST['position']; $date = $_POST['date']; $app_letter = $_POST['app_letter']; $info_form = $_POST['info_form']; $handbook = $_POST['handbook']; $access_card = $_POST['access_card']; $vehicle_sticker = $_POST['vehicle_sticker']; $medical_check_up = $_POST['medical_check_up']; $safety_briefing = $_POST['safety_briefing']; $safety_helmet = $_POST['safety_helmet']; $safety_google = $_POST['safety_google']; $safety_boot = $_POST['safety_boot']; $computer = $_POST['computer']; $tel_ext = $_POST['tel_ext']; $room_no = $_POST['room_no']; $email = $_POST['email']; $stationary = $_POST['stationary']; $uniform = $_POST['uniform']; $tshirt = $_POST['tshirt']; $medical_card = $_POST['medical_card']; $induction_program = $_POST['induction_program']; $query= "INSERT INTO details(staff_no,position,date,app_letter,info_form,handbook,access_card,vehicle_sticker,medical_check_up,safety_briefing,safety_helmet,safety_google,safety_boot,computer,tel_ext,room_no,email,stationary,uniform,tshirt,medical_card,induction_program) VALUES ('$staff_no', '$position','$date','$app_letter','$info_form','$handbook','$access_card','$vehicle_sticker','$medical_check_up','$safety_briefing','$safety_helmet','$safety_google','$safety_boot','$computer','$tel_ext','$room_no','$email','$stationary','$uniform','$tshirt','$medical_card','$induction_program') "; $result = mysql_query($query,$dblink); ?> error : Notice: Undefined index: access_card in C:\Web\staff\add.php on line 17 Notice: Undefined index: medical_check_up in C:\Web\staff\add.php on line 19 Notice: Undefined index: safety_briefing in C:\Web\staff\add.php on line 20 Notice: Undefined index: safety_google in C:\Web\staff\add.php on line 22 Notice: Undefined index: tel_ext in C:\Web\staff\add.php on line 25 Notice: Undefined index: uniform in C:\Web\staff\add.php on line 29 Notice: Undefined index: tshirt in C:\Web\staff\add.php on line 30 Quote Link to comment Share on other sites More sharing options...
Zane Posted December 17, 2007 Share Posted December 17, 2007 Before you go and set a bunch of post variables like this. You need to make sure that each POST variable is set or else the variable you set for it....ie.....$date = $_POST['date'] will fail to be set $staff_no = $_POST['staff_no']; $position = $_POST['position']; $date = $_POST['date']; $app_letter = $_POST['app_letter']; $info_form = $_POST['info_form']; $handbook = $_POST['handbook']; $access_card = $_POST['access_card']; $vehicle_sticker = $_POST['vehicle_sticker']; $medical_check_up = $_POST['medical_check_up']; $safety_briefing = $_POST['safety_briefing']; $safety_helmet = $_POST['safety_helmet']; $safety_google = $_POST['safety_google']; $safety_boot = $_POST['safety_boot']; $computer = $_POST['computer']; $tel_ext = $_POST['tel_ext']; $room_no = $_POST['room_no']; $email = $_POST['email']; $stationary = $_POST['stationary']; $uniform = $_POST['uniform']; $tshirt = $_POST['tshirt']; $medical_card = $_POST['medical_card']; $induction_program = $_POST['induction_program']; to do this....use isset() an easy way to do these is extract($_POST, EXTR_IF_EXISTS); but it isn't the best of practice to use it all the time. just something to use real fast if you ever need it Quote Link to comment Share on other sites More sharing options...
june_c21 Posted December 17, 2007 Author Share Posted December 17, 2007 i re-checked my code and there is no error... can you brieftly explain the details sorry, i'm new in this Quote Link to comment Share on other sites More sharing options...
Zane Posted December 17, 2007 Share Posted December 17, 2007 nevermind....I misread the error undefined index access_card medical_check_up safety_briefing safety_google tel_ext uniform tshirt the form you have.. doesn't contain fields with these names anywhere e.g medical_check_up might be medicalcheckup on your form page go back and check all your names and make sure they match Quote Link to comment Share on other sites More sharing options...
june_c21 Posted December 17, 2007 Author Share Posted December 17, 2007 thank you Quote Link to comment 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.