I am facing a strange issue here,I had a piece of code which was working fine until yesterday.Suddenly my button has stopped making POST Request.
Below is the sample code.When i click on the button btnsubmit
,the page gets redirected to view_teacherupdate.php but it doesnt print "button submitted";
<form method="post" action="view_teacherUpdate.php">
<input type="submit" name="btnsubmit" value="submit"/>
</form>
view_teacherUpdate.php
if(isset($_POST["btnsubmit"]))
{
echo "button submitted";
}
I have enabled error_reporting(E_ALL);
but I am not getting any error or warning.
Session is enabled in both pages.
any help would be appreciated. Thanks in advance.
Full Code:
ViewTeacherUpdatePage:
<?php
session_start();
require_once 'includewisdom/class.user.php';
//require_once 'includewisdom/class.user.php';
error_reporting(E_ALL);
$user_home = new USER();
if(!$user_home->is_logged_in())
{
$user_home->redirect('includewisdom/login.php');
}
function file_upload_error_message($error_code) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
case UPLOAD_ERR_FORM_SIZE:
return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
case UPLOAD_ERR_PARTIAL:
return 'The uploaded file was only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk';
case UPLOAD_ERR_EXTENSION:
return 'File upload stopped by extension';
default:
return 'Unknown upload error';
}
}
if(isset($_POST["btnUpdateNew"]))
{
echo "hfvghfhgfhgf enter";
$TeacherID=5;
$teachername=trim($_POST["teachername"]);
$current_address=trim($_POST["current_address"]);
$teaching_locationsarray=$_POST["teaching_locations"];
$teaching_locationsarray=array_unique($teaching_locationsarray);
$teaching_location="";
foreach($teaching_locationsarray as $temp)
{
$teaching_location=$temp.",".$teaching_location;
}
$teaching_location=rtrim($teaching_location,",");
//echo $teaching_location;
$teachingzone=trim($_POST["teachingzone"]);
//$TeacherLocation[]
$TeacherLocationarray=$_POST["TeacherLocation"];
$TeacherLocationarray=array_unique($TeacherLocationarray);
$TeacherLocation="";
foreach($TeacherLocationarray as $temp)
{
$TeacherLocation=$temp.",".$TeacherLocation;
}
$TeacherLocation=rtrim($TeacherLocation,",");
//$residenceZone=trim($_POST["residenceZone"]);
//$Teaching_subject[]
$Teaching_subjectarray=$_POST["Teaching_subject"];
$Teaching_subjectarray=array_unique($Teaching_subjectarray);
$Teaching_subject="";
foreach($Teaching_subjectarray as $temp)
{
$Teaching_subject=$temp.",".$Teaching_subject;
}
$Teaching_subject=rtrim($Teaching_subject,",");
//$residenceZone=trim($_POST["residenceZone"]);
//$TeachingGroup[]
$TeachingGrouparray=$_POST["TeachingGroup"];
$TeachingGrouparray=array_unique($TeachingGrouparray);
$TeachingGroup="";
foreach($TeachingGrouparray as $temp)
{
$TeachingGroup=$temp.",".$TeachingGroup;
}
$TeachingGroup=rtrim($TeachingGroup,",");
//$residenceZone=trim($_POST["residenceZone"]);
//$edu_subject[]
$edu_subjectarray=$_POST["edu_subject"];
$edu_subjectarray=array_unique($edu_subjectarray);
$edu_subject="";
foreach($edu_subjectarray as $temp)
{
$edu_subject=$temp.",".$edu_subject;
}
$edu_subject=rtrim($edu_subject,",");
//$residenceZone=trim($_POST["residenceZone"]);
//$EducationGroup[]
$EducationGrouparray=$_POST["EducationGroup"];
$EducationGrouparray=array_unique($EducationGrouparray);
$EducationGroup="";
foreach($EducationGrouparray as $temp)
{
$EducationGroup=$temp.",".$EducationGroup;
}
$EducationGroup=rtrim($EducationGroup,",");
$residenceZone=trim($_POST["residenceZone"]);
$gender=trim($_POST["gender"]);
$board=trim($_POST["board"]);
$Qualification=trim($_POST["Qualification"]);
$enrollmentdate=trim($_POST["enrollmentdate"]);
$dob=trim($_POST["dob"]);
}
ViewTeacherPage(where button gets clicked)
<?php
session_start();
require_once 'includewisdom/class.user.php';
//require_once 'includewisdom/class.user.php';
error_reporting(E_ALL);
define('PAC_PATH','phpAutocomplete');
require_once("phpAutocomplete/conf.php");
$user_home = new USER();
if(!$user_home->is_logged_in())
{
$user_home->redirect('includewisdom/login.php');
}
$tutorRequirement=[];
if(isset($_POST["deleteDocs"]))
{
$TeacherID=trim($_GET["id"]);
//echo $TeacherID;
$stmt1 = $user_home->runQuery("UPDATE `teacher_info` SET `idproof`='',`degree`='',`marksheet`='',`tenmarksheet`='',`degreemarksheet`='',
`additionalDocuments`='',
`addressproof`='' WHERE userid=:uid");
$stmt1->bindparam(":uid",$TeacherID);
$stmt1->execute();
//echo "sgadjfdgs";
}
if(isset($_POST["submitRequestRequirement"]))
{
$noteid=trim($_GET["noteid"]);
$tutorid=trim($_GET["id"]);
$stmtInsert="";
$stmtRequest = $user_home->runQuery("SELECT * FROM `TutorRequestRequirement` WHERE TutorID='$tutorid' and RequestID='$noteid'");
$stmtRequest->execute();
//fetch(PDO::FETCH_ASSOC)
$tutorRequirement = $stmtRequest->fetchAll(PDO::FETCH_ASSOC);
$requestRequirement=trim($_POST["requestRequirement"]);
if(count($tutorRequirement)>0)
{
$stmtInsert = $user_home->runQuery("Update TutorRequestRequirement set Requirement=:Requirement where TutorID=:TutorID and RequestID=:RequestID");
}
else
{
$stmtInsert = $user_home->runQuery("INSERT INTO `TutorRequestRequirement`(`TutorID`, `Requirement`, `RequestID`) Values
(:TutorID,:Requirement,:RequestID)");
}
$stmtInsert->bindparam(":TutorID",$tutorid);
$stmtInsert->bindparam(":Requirement",$requestRequirement);
$stmtInsert->bindparam(":RequestID",$noteid);
$result=$stmtInsert->execute();
}
if(isset($_GET["noteid"]))
{
$noteid=trim($_GET["noteid"]);
$tutorid=trim($_GET["id"]);
$stmtRequest = $user_home->runQuery("SELECT * FROM `TutorRequestRequirement` WHERE TutorID='$tutorid' and RequestID='$noteid'");
$stmtRequest->execute();
//fetch(PDO::FETCH_ASSOC)
$tutorRequirement = $stmtRequest->fetchAll(PDO::FETCH_ASSOC);
//echo count($tutorRequirement);
//var_dump($tutorRequirement);
}
function file_upload_error_message($error_code) {
switch ($error_code) {
case UPLOAD_ERR_INI_SIZE:
return 'The uploaded file exceeds the upload_max_filesize directive in php.ini';
case UPLOAD_ERR_FORM_SIZE:
return 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form';
case UPLOAD_ERR_PARTIAL:
return 'The uploaded file was only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file was uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'Missing a temporary folder';
case UPLOAD_ERR_CANT_WRITE:
return 'Failed to write file to disk';
case UPLOAD_ERR_EXTENSION:
return 'File upload stopped by extension';
default:
return 'Unknown upload error';
}
}
$stmt = $user_home->runQuery("SELECT * FROM RoleInfoWisdomManagementSystem WHERE id=:uid");
$stmt->execute(array(":uid"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$msg = "<div class='alert alert-block' style='background:#48cfad;margin-top:10px'>
<button class='close' data-dismiss='alert'>×</button>
<strong> Your Profile Updated Successfully. </strong>
</div>";
$role=$row['role'];
$name=$row['Name'];
$TeacherID=trim($_GET["id"]);
$stmt = $user_home->runQuery("SELECT * FROM teacher_info WHERE userid=:uid");
$stmt->execute(array(":uid"=>$TeacherID));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$teachingPreferencearray=explode(",",$row["tution_type"]);
$stmtArea = $user_home->runQuery("SELECT * FROM kolkata_locations");
$stmtArea->execute();
$rowarea = $stmtArea->fetchAll();
$stmt112 = $user_home->runQuery("SELECT distinct `subject_name` FROM `subjects`");
$stmt112->execute();
$rowsubjects = $stmt112->fetchAll();
$stmt1123 = $user_home->runQuery("SELECT * FROM `subjects`");
$stmt1123->execute();
$rowTeachingsubjects = $stmt1123->fetchAll();
//$arrinbox=explode("#",$inbox);
<form method="post" action="view_teacherUpdate.php">
<button id="btnUpdate" name="btnUpdateNew" value="btnUpdateNew" type="submit" class="btn btn-success">Save</button>
</form>
The code you submitted contains 2 submit-buttons (1 < button >, 1 < input type="submit" >. Depending on the button pressed, a different value is actually submitted. I guess that the form only adds the button (or element type=submit) that was actually clicked to the POST-data (which makes sense from an UI-standpoint)
Depending on the button pressed I either got
Array ( [btnsubmit] => Verzenden )
or
Array ( [btnUpdateNew] => btnUpdateNew )
("Verzenden" is the dutch translation for Send, as the browser translates this)
So, could it be that you were pressing the wrong button by any chance?
<form method="post" action="view_teacherUpdate.php">
<input type="submit" name="btnsubmit"/>
<button id="btnUpdate" name="btnUpdateNew" value="btnUpdateNew" type="submit" class="btn btn-success">Save</button>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With