Ibshas25 Posted November 5, 2010 Share Posted November 5, 2010 this is the errors: Notice: Undefined index: data in /export/SOI-50/students/m2009/abhr428/web/WebIbs/teams.php on line 13 Notice: Undefined index: operation in /export/SOI-50/students/m2009/abhr428/web/WebIbs/teams.php on line 18 Notice: Undefined index: operation in /export/SOI-50/students/m2009/abhr428/web/WebIbs/teams.php on line 56 Notice: Undefined index: operation in /export/SOI-50/students/m2009/abhr428/web/WebIbs/teams.php on line 84 Notice: Undefined index: operation in /export/SOI-50/students/m2009/abhr428/web/WebIbs/teams.php on line 132 Notice: Undefined index: operation in /export/SOI-50/students/m2009/abhr428/web/WebIbs/teams.php on line 158 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Teams Management</title> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <style type="text/css"> body { font-size:12px; font-family:Arial, Helvetica, sans-serif; } form { display:block; width:260px; } form .input{ width:120px; float:right; } form label { display:block; width:260px; clear:both; } form textarea { display:block; width:260px; } </style> <script type="text/javascript"> // After Document Load Complete $(document).ready(function(){ //$("#projectid").html("1"); // alert("document loaded 1"); var data = { "operation" : "rolesearch", "roles": [ { "rolname" : "%"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('teams.php', { data: dataString}, rolesearchResult, "text"); }); function rolesearchResult(res) { //alert("checkResult"); // $("#userlist").html("Full response: " +res); var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#rollist").html(obj.ResultData); teamslistgenerate(); } function teamslistgenerate(){ var data = { "operation" : "teamslist", "teams": [ { "projectid" : "1"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('teams.php', { data: dataString}, teamslistResult, "text"); } function teamslistResult(res) { //alert("checkResult"); // $("#userlist").html("Full response: " +res); var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#teamlist").html(obj.ResultData); } // TeamListChoose(".$row['tea_id'].",".$row['tea_projectId'].",".row['tea_userId'].",".$row['tea_rolId']."," .chr(34).$row['usr_name'] .chr(34).",".chr(34).$row['usr_surname'].chr(34).") function TeamListChoose(teamid,projectid,userid,rolid,name,surname) { // Delete için teamid , select için diğerleri kullanılacak. seçilen row ekranda düzenlenecek. //$("#teamid").html(teamid); $("#teamid").val(teamid); $("#selectedUserId").html(userid); $("#selectedUserName").html(name+" "+surname); $('#rollist option:selected').removeAttr('selected'); $('#rollist option[value='+rolid+']').attr('selected', true); } function usersearch() { //alert(document.getElementById("name").value); //alert(document.getElementById("surname").value); var name=$("#name").attr("value"); var surname=$("#surname").attr("value"); // alert ("user search a geliyor"); //var formdata = 'name' : "'+document.getElementById("name").value+",'surname' : '"+document.getElementById("surname").value" ; var data = { "operation" : "usersearch", "user": [ { "name" : name, "surname" : surname } // { "name" : name+"xx", "surname" : surname+"xx" }, // { "name" : name+"yy", "surname" : surname+"yy" } ] // end of sales array } // alert("geldi 1"); //var dataString = JSON.(data); var dataString = $.toJSON(data); // alert(dataString); //alert("geldi 3"); // alert(dataString); $.post('teams.php', { data: dataString}, usersearchResult, "text"); } function usersearchResult(res) { //alert("checkResult"); // $("#userlist").html("Full response: " +res); var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#userlist").html(obj.ResultData); } function UserSearchChoose(userId,userName,userSurName){ alert(userId); $("#userid").val(userId); $("#selectedUserName").val(userName+ " "+userSurName); } function teamdelete() { var teamidval = $("#teamid").attr("value"); alert (teamidval); var data = { "operation" : "teamdelete", "teamid" : teamidval } var dataString = $.toJSON(data); $.post('teams.php', { data: dataString}, teamdeleteResult, "text"); } function teamdeleteResult(res) { var obj = $.evalJSON(res); $("#successfailmessage").html(obj.SuccFailMessage); teamslistgenerate(); } function teamadd() { //alert ("team add a geliyor"); var projectId = $("#projectid").attr("value"); var userId = $("#userid").attr("value"); var rolId = $("#rollist option:selected").val(); // alert ("--".projectId."-".userId."-".rolId."--"); var data = { "operation" : "teamadd", "projectId" : projectId, "userId" : userId, "rolId" : rolId, "recuser" : 1 } var dataString = $.toJSON(data); $.post('teams.php', { data: dataString}, teamdeleteResult, "text"); alert ("user add a geliyor ajax bitti"); } </script> </head> <body> <form id="iletisim"> <span id="successfailmessage"></span> <input class="input" name="teamid" id="teamid" type="text" value="" /> <input class="input" name="projectid" id="projectid" type="text" value="1" /> <input class="input" name="userid" id="userid" type="text" value="" /> <span id="selectedUserName"></span> <label for="name">Name<input class="input" name="name" id="name" type="text" value="" /></label> <label for="surname">Surname<input class="input" name="surname" id="surname" type="text" value="" /></label> <a href='#' onclick="javascript:usersearch();">Search User</a> <span id="userlist"></span> <span id="rollist"></span> <a href='#' onclick="javascript:teamsearch();">Search</a> <a href='#' onclick="javascript:teamadd();">Add</a> <a href='#' onclick="javascript:teamdelete();">Delete</a> <span id="teamlist"></span> </form> </body> </html> php file Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/ Share on other sites More sharing options...
trq Posted November 5, 2010 Share Posted November 5, 2010 You might want to post some relevent code. Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/#findComment-1130661 Share on other sites More sharing options...
Ibshas25 Posted November 5, 2010 Author Share Posted November 5, 2010 <?php include("JSON.php"); require_once("connectdb.php"); /*Connect to your Database $conn = mysql_connect("127.0.0.1", "root", "kasapogluo") or die("Could not connect to MySQL Server: " . mysql_error()); //Select your Database mysql_select_db("test") or die("Could not select database"); */ $req = json_decode(stripslashes($_POST['data']), true); $req["SuccFail"]="fail"; $req["SuccFailMessage"]="Error Occured."; //$logFile = 'logFile'; // error_log("isl=baþladý: ", 3, $logFile); if ($req['operation'] == "usersearch") // select için veri geldi { // error_log("isl==select oluþuyor: ", 3, $logFile); $sql= "select usr_id, usr_username,usr_name,usr_surname,usr_isuseractive from users"; $sql.=" where (usr_name is null or usr_name like '". $req['user'][0]['name']."%' ) and "; $sql.= "(usr_surname is null or usr_surname like '". $req['user'][0]['surname']."%' ) "; $sql .= " order by usr_name , usr_surname"; // error_log($sql, 3, $logFile); //error_log("sql: ".$sql, 3, $logFile); //error_log("\n", 3, $logFile); $result = mysql_query($sql); $reslist = "<table border='1'><tr><th>User Id</th><th>Username</th><th>Name</th><th>Surname</th><th>Is Active</th></tr>"; while($row = mysql_fetch_array($result)) { // error_log("user: ".$row['usr_name']." surname :".$row['usr_username'], 3, $logFile); $user = $row['usr_name']." ".$row['usr_surname']; $reslist .= "<tr><td><a href='#' onclick='javascript:UserSearchChoose(".$row['usr_id'].",".chr(34).$row['usr_name'].chr(34).",".chr(34).$row['usr_surname'].chr(34).");'>".$row['usr_id']."</a></td><td>" . $row['usr_username'] . "</td><td>" . $row['usr_name'] . "</td>"; $reslist .= "<td>" . $row['usr_surname'] . "</td><td>" . $row['usr_isuseractive'] . "</td></tr>"; } // error_log("$reslist: ".$reslist, 3, $logFile); $reslist .= "</table>"; // error_log("$reslist: ".$reslist, 3, $logFile); // error_log("\n", 3, $logFile); $req["SuccFail"]="success"; //operation success or fail $req["SuccFailMessage"]="successfully selected."; //alert($reslist); $req["ResultData"]=$reslist; mysql_close($conn); header("Content-type: text/plain"); echo json_encode($req); return; } else if ($req['operation'] == "rolesearch") // select için veri geldi { $sql= "select rol_Id, rol_name from roles order by rol_name"; $result = mysql_query($sql); $reslist = "<select id='roles' name='roles'>"; while($row = mysql_fetch_array($result)) { $reslist .= "<option value='".$row['rol_Id']."' "; if($row['rol_Id']==1) { $reslist .= " selected "; } $reslist .= " >".$row['rol_name']."</option>"; } //error_log("$reslist: ".$reslist, 3, $logFile); //error_log("\n", 3, $logFile); $req["SuccFail"]="success"; //operation success or fail $req["SuccFailMessage"]="successfully selected."; //alert($reslist); $req["ResultData"]=$reslist; mysql_close($conn); header("Content-type: text/plain"); echo json_encode($req); return; } else if ($req['operation'] == "teamslist") // select için veri geldi { // error_log("isl==teamslist select oluþuyor: ", 3, $logFile); $sql="select tea.tea_id,tea.tea_projectId, prj.prj_projectname , tea.tea_userId,usr.usr_name,usr.usr_surname,tea.tea_rolId,rol.rol_name from teams as tea LEFT JOIN projects as prj ON prj .prj_id = tea.tea_projectId LEFT JOIN users as usr ON usr.usr_id = tea.tea_userId LEFT JOIN roles as rol ON rol.rol_Id = tea.tea_rolId where tea.tea_projectId =".$req['teams'][0][projectid]; $sql.=" order by usr.usr_name , usr.usr_surname ,prj.prj_projectname "; /* (usr.usr_name is null or usr.usr_name like 'ib%' ) and (usr.usr_surname is null or usr.usr_surname like '%' ) order by usr.usr_name , usr.usr_surname ,prj.prj_projectname $sql= "select usr_id, usr_username,usr_name,usr_surname,usr_isuseractive from users"; $sql.=" where (usr_name is null or usr_name like '". $req['user'][0]['name']."%' ) and "; $sql.= "(usr_surname is null or usr_surname like '". $req['user'][0]['surname']."%' ) "; $sql .= " order by usr_name , usr_surname"; */ //error_log("sql: ".$sql, 3, $logFile); //error_log("\n", 3, $logFile); $result = mysql_query($sql); $reslist = "<table border='1'><tr><th>Teams Info</th> </tr>"; while($row = mysql_fetch_array($result)) { // error_log("user: ".$row['usr_name']." surname :".$row['usr_username'], 3, $logFile); //$user = $row['usr_name']." ".$row['usr_surname']; $reslist .= "<tr><td><a href='#' onclick='javascript:TeamListChoose(".$row['tea_id'].",".$row['tea_projectId'].",".$row['tea_userId'].",".$row['tea_rolId'].",".chr(34).$row['usr_name'].chr(34).",".chr(34).$row['usr_surname'].chr(34).");'> ". $row['rol_name'] . " ==> " . $row['usr_name'] . " ". $row['usr_surname'] . "</a></td></tr>"; } // error_log("$reslist: ".$reslist, 3, $logFile); $reslist .= "</table>"; // error_log("$reslist: ".$reslist, 3, $logFile); // error_log("\n", 3, $logFile); $req["SuccFail"]="success"; //operation success or fail $req["SuccFailMessage"]="successfully selected."; //alert($reslist); $req["ResultData"]=$reslist; mysql_close($conn); header("Content-type: text/plain"); echo json_encode($req); return; } else if ($req['operation'] == "teamdelete") // teams silmek için geldi. { //error_log("isl==teamdelete: ", 3, $logFile); //$sql="delete from teams where tea_id=".$req['teamid']; mysql_query("delete from teams where tea_id=".$req['teamid']); //error_log("mysql_affected_rows= ".mysql_affected_rows($con), 3, $logFile); //var $affrows = mysql_affected_rows(); if ( mysql_affected_rows() > 0 ) { $req["SuccFail"]="success"; //operation success or fail $req["SuccFailMessage"]="successfully deleted."; //error_log("isl==teamdelete:success ", 3, $logFile); } else { $req["SuccFail"]="fail"; //operation success or fail $req["SuccFailMessage"]="error occured ". mysql_error(); // error_log("isl==teamdelete:fail ", 3, $logFile); } mysql_close($conn); header("Content-type: text/plain"); echo json_encode($req); return; } else if ($req['operation'] == "teamadd") // teams silmek için geldi. { //error_log("isl==teamdelete: ", 3, $logFile); //$sql="delete from teams where tea_id=".$req['teamid']; $sql="insert into teams VALUES (null,". $req['projectId'].",".$req['userId'].",".$req['rolId'].",now(),".$req['recuser'].")"; mysql_query($sql); //error_log($sql, 3, $logFile); //var $affrows = mysql_affected_rows(); if ( mysql_affected_rows() > 0 ) { $req["SuccFail"]="success"; //operation success or fail $req["SuccFailMessage"]="successfully deleted."; //error_log("isl==teamdelete:success ", 3, $logFile); } else { $req["SuccFail"]="fail"; //operation success or fail $req["SuccFailMessage"]="error occured ". mysql_error(); // error_log("isl==teamdelete:fail ", 3, $logFile); } mysql_close($conn); header("Content-type: text/plain"); echo json_encode($req); return; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/#findComment-1130728 Share on other sites More sharing options...
Pikachu2000 Posted November 5, 2010 Share Posted November 5, 2010 You're attempting to use the value of variables that aren't yet defined. Your <form> tag has no method= attribute, meaning it will revert to GET, therefore your expected $_POST vars are non-existent. Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/#findComment-1130767 Share on other sites More sharing options...
Ibshas25 Posted November 5, 2010 Author Share Posted November 5, 2010 i have tried this but it hasnt made a difference... is there something im missing?? <form id"" method ="post"> Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/#findComment-1130770 Share on other sites More sharing options...
Pikachu2000 Posted November 5, 2010 Share Posted November 5, 2010 Post the entire script just as you have it saved. Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/#findComment-1130779 Share on other sites More sharing options...
Ibshas25 Posted November 5, 2010 Author Share Posted November 5, 2010 teams.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Teams Management</title> <link href="stylesheet1.css" rel="stylesheet" type="text/css"/> <script type="text/javascript" src="jquery-1.4.3.js"></script> <script type="text/javascript" src="jquery.json-2.2.js"></script> <style type="text/css"> body { font-size:12px; font-family:Arial, Helvetica, sans-serif; } form { display:block; width:260px; } form .input{ width:120px; float:right; } form label { display:block; width:260px; clear:both; } form textarea { display:block; width:260px; } </style> <script type="text/javascript"> // After Document Load Complete $(document).ready(function(){ //$("#projectid").html("1"); // alert("document loaded 1"); var data = { "operation" : "rolesearch", "roles": [ { "rolname" : "%"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('teams.php', { data: dataString}, rolesearchResult, "text"); }); function rolesearchResult(res) { //alert("checkResult"); // $("#userlist").html("Full response: " +res); var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#rollist").html(obj.ResultData); teamslistgenerate(); } function teamslistgenerate(){ var data = { "operation" : "teamslist", "teams": [ { "projectid" : "1"}, ] // end of sales array } //alert("geldi 2"); //var dataString = JSON.(data); var dataString = $.toJSON(data); //alert("geldi 3"); // alert(dataString); $.post('teams.php', { data: dataString}, teamslistResult, "text"); } function teamslistResult(res) { //alert("checkResult"); // $("#userlist").html("Full response: " +res); var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#teamlist").html(obj.ResultData); } // TeamListChoose(".$row['tea_id'].",".$row['tea_projectId'].",".row['tea_userId'].",".$row['tea_rolId']."," .chr(34).$row['usr_name'] .chr(34).",".chr(34).$row['usr_surname'].chr(34).") function TeamListChoose(teamid,projectid,userid,rolid,name,surname) { // Delete için teamid , select için diğerleri kullanılacak. seçilen row ekranda düzenlenecek. //$("#teamid").html(teamid); $("#teamid").val(teamid); $("#selectedUserId").html(userid); $("#selectedUserName").html(name+" "+surname); $('#rollist option:selected').removeAttr('selected'); $('#rollist option[value='+rolid+']').attr('selected', true); } function usersearch() { //alert(document.getElementById("name").value); //alert(document.getElementById("surname").value); var name=$("#name").attr("value"); var surname=$("#surname").attr("value"); // alert ("user search a geliyor"); //var formdata = 'name' : "'+document.getElementById("name").value+",'surname' : '"+document.getElementById("surname").value" ; var data = { "operation" : "usersearch", "user": [ { "name" : name, "surname" : surname } // { "name" : name+"xx", "surname" : surname+"xx" }, // { "name" : name+"yy", "surname" : surname+"yy" } ] // end of sales array } // alert("geldi 1"); //var dataString = JSON.(data); var dataString = $.toJSON(data); // alert(dataString); //alert("geldi 3"); // alert(dataString); $.post('teams.php', { data: dataString}, usersearchResult, "text"); } function usersearchResult(res) { //alert("checkResult"); // $("#userlist").html("Full response: " +res); var obj = $.evalJSON(res); //alert(obj.ResultData); //$("#sales1Lastname").html("Lastname of sales[1]: " +obj.sales[0].lastname); $("#userlist").html(obj.ResultData); } function UserSearchChoose(userId,userName,userSurName){ alert(userId); $("#userid").val(userId); $("#selectedUserName").val(userName+ " "+userSurName); } function teamdelete() { var teamidval = $("#teamid").attr("value"); alert (teamidval); var data = { "operation" : "teamdelete", "teamid" : teamidval } var dataString = $.toJSON(data); $.post('teams.php', { data: dataString}, teamdeleteResult, "text"); } function teamdeleteResult(res) { var obj = $.evalJSON(res); $("#successfailmessage").html(obj.SuccFailMessage); teamslistgenerate(); } function teamadd() { //alert ("team add a geliyor"); var projectId = $("#projectid").attr("value"); var userId = $("#userid").attr("value"); var rolId = $("#rollist option:selected").val(); // alert ("--".projectId."-".userId."-".rolId."--"); var data = { "operation" : "teamadd", "projectId" : projectId, "userId" : userId, "rolId" : rolId, "recuser" : 1 } var dataString = $.toJSON(data); $.post('teams.php', { data: dataString}, teamdeleteResult, "text"); alert ("user add a geliyor ajax bitti"); } </script> </head> <body> <center> <div style="width:280pt;height:280pt;border:5px solid #FFFFFF;"> <div id= "logo1"><img src="images/FINALlogo.jpg" width="60" height="50" /></div> <form id="iletisim" method="post" > <span id="successfailmessage"></span> <tr><td> <label for"teamid">Team ID</label> <td><input class="input" name="teamid" id="teamid" type="text" value="" /> </tr></td> <tr><td> <label for"project id">Project ID</label> <td><input class="input" name="projectid" id="projectid" type="text" value="1" /> </tr></td> <tr><td> <label for "userid">User ID</label> <td><input class="input" name="userid" id="userid" type="text" value="" /> </tr></td> <tr><td> <span id="selectedUserName"></span> </tr></td> <tr><td> <label for="name">Name</label> <td><input class="input" name="name" id="name" type="text" value="" /> </tr></td> <tr><td> <label for="surname">Surname</label> <td><input class="input" name="surname" id="surname" type="text" value="" /> </tr></td> <tr><td><a href='#' onclick="javascript:usersearch();">Search User</a> </tr></td> <p> <tr><td><span id="userlist"></span> </tr></td></p> <br> <tr><td><span id="rollist"></span></tr></td> </br> <tr><a href='#' onclick="javascript:teamsearch();">Search</a> </tr> <tr><td> <a href='#' onclick="javascript:teamadd();">Add</a> </tr></td> <a href='#' onclick="javascript:teamdelete();">Delete</a> <span id="teamlist"></span> </form> </div> </center> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/217840-notice-undefined-index-data-in/#findComment-1130783 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.