<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "candidatesList";
//create connection
$conn = mysqli_connect($servername, $username, $password,$dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// $sql = "INSERT INTO candidatesListFields (Sourcing_HR, DOS, Candidate_Name, Total_Experience, Current_CTC, Expected_CTC, Current_Location, Preferred_Location) VALUES ('', '', '', '', '', '','','')";
?>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 header">
<h3 class="pull-left">Track your Candidates</h3>
<button type="button" class="pull-right btn btn-primary exportBtn" data-toggle="modal" data-target=".exportTable"><i class="glyphicon glyphicon-save saveIcon"></i> Export to Excel</button>
<div class="clear"></div>
</div>
<div class="col-xs-12">
<div class="col-lg-12 formWrapper">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div class="form-group col-xs-12 col-md-3">
<label for="sourcingHR">Sourcing HR</label>
<input type="text" class="form-control" id="sourcingHR" value="<?php echo $Sourcing_HR;?>" name="Sourcing_HR" placeholder="Sourcing HR">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="dateOfSourcing">Date of Sourcing</label>
<input type="text" class="form-control" id="dateOfSourcing" name="DOS" placeholder="Date of sourcing">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="candidateName">Candidate Name</label>
<input type="text" class="form-control" id="candidateName" name="Candidate_Name" placeholder="Candidate Name">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="totalExperience">Total Experience</label>
<input type="text" class="form-control" id="totalExperience" name="Total_Experience" placeholder="Total Experience">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="currCTC">Curr. CTC</label>
<input type="text" class="form-control" id="currCTC" name="Current_CTC" placeholder="Current CTC">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="expCTC">Exp. CTC</label>
<input type="text" class="form-control" id="expCTC" name="Expected_CTC" placeholder="Expected CTC">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="currLocation">Current Location</label>
<input type="text" class="form-control" id="currLocation" name="Current_Location" placeholder="Current Location">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="prefLocation">Preferred Location</label>
<input type="text" class="form-control" id="prefLocation" name="Preferred_Location" placeholder="Preferred Location">
</div>
<div class="form-group col-xs-12 text-right">
<button class="btn btn-success" type="submit">
<i class="glyphicon glyphicon-floppy-disk saveIcon"></i> Save
</button>
</div>
</form>
</div>
</div>
</div>
</div>
Here I have created Data base and now I want to save values into the database for the following fields but it is giving undefined index. what can I do for this.
if(!empty($_POST['Sourcing_HR'] AND $_POST['DOS'] AND $_POST['Candidate_Name'] AND $_POST['Candidate_Name'] AND $_POST['Total_Experience'] AND $_POST['Current_CTC'] AND $_POST['Expected_CTC'] AND $_POST['Current_Location'] AND $_POST['Preferred_Location'])){
$sql = "INSERT INTO candidatesListFields (Sourcing_HR, DOS, Candidate_Name, Total_Experience, Current_CTC, Expected_CTC, Current_Location, Preferred_Location) VALUES ('$Sourcing_HR', '$DOS', '$Candidate_Name', '$Total_Experience', '$Current_CTC', '$Expected_CTC','$Current_Location','$Preferred_Location')";
echo($_POST[$Sourcing_HR.' '. $DOS.' '. $Candidate_Name.' '. $Total_Experience.' '. $Current_CTC.' '. $Expected_CTC.' '. $Current_Location.' '. $Preferred_Location]);
}
if (isset($_POST['Sourcing_HR'])) {
$Sourcing_HR = $_POST['Sourcing_HR'];
}
?>
This is not working properly please help if anyone out there*
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "candidatesList";
//create connection
$conn = mysqli_connect($servername, $username, $password,$dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// $sql = "INSERT INTO candidatesListFields (Sourcing_HR, DOS, Candidate_Name, Total_Experience, Current_CTC, Expected_CTC, Current_Location, Preferred_Location) VALUES ('', '', '', '', '', '','','')";
?>
<?php
$sql = "INSERT INTO candidatesListFields (Sourcing_HR, DOS, Candidate_Name, Total_Experience, Current_CTC, Expected_CTC, Current_Location, Preferred_Location) VALUES ('', '', '', '', '', '','','')";
// getting values of input fields from form
$Sourcing_HR = mysqli_real_escape_string($conn,$_POST['Sourcing_HR']);
$DOS = mysqli_real_escape_string($conn,$_POST['DOS']);
$Candidate_Name = mysqli_real_escape_string($conn,$_POST['Candidate_Name']);
$Total_Experience = mysqli_real_escape_string($conn,$_POST['Total_Experience']);
$Current_CTC = mysqli_real_escape_string($conn,$_POST['Current_CTC']);
$Expected_CTC = mysqli_real_escape_string($conn,$_POST['Expected_CTC']);
$Current_Location = mysqli_real_escape_string($conn,$_POST['Current_Location']);
$Preferred_Location = mysqli_real_escape_string($conn,$_POST['Preferred_Location']);
if(!empty($_POST['Sourcing_HR'] AND $_POST['DOS'] AND $_POST['Candidate_Name'] AND $_POST['Candidate_Name'] AND $_POST['Total_Experience'] AND $_POST['Current_CTC'] AND $_POST['Expected_CTC'] AND $_POST['Current_Location'] AND $_POST['Preferred_Location'])){
$sql = "INSERT INTO candidatesListFields (Sourcing_HR, DOS, Candidate_Name, Total_Experience, Current_CTC, Expected_CTC, Current_Location, Preferred_Location) VALUES ('$Sourcing_HR', '$DOS', '$Candidate_Name', '$Total_Experience', '$Current_CTC', '$Expected_CTC','$Current_Location','$Preferred_Location')";
echo($_POST[$Sourcing_HR.' '. $DOS.' '. $Candidate_Name.' '. $Total_Experience.' '. $Current_CTC.' '. $Expected_CTC.' '. $Current_Location.' '. $Preferred_Location]);
}
if (isset($_POST['Sourcing_HR'])) {
$Sourcing_HR = $_POST['Sourcing_HR'];
}
?>
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 header">
<h3 class="pull-left">Track your Candidates</h3>
<button type="button" class="pull-right btn btn-primary exportBtn" data-toggle="modal" data-target=".exportTable"><i class="glyphicon glyphicon-save saveIcon"></i> Export to Excel</button>
<div class="clear"></div>
</div>
<div class="col-xs-12">
<div class="col-lg-12 formWrapper">
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<div class="form-group col-xs-12 col-md-3">
<label for="sourcingHR">Sourcing HR</label>
<input type="text" class="form-control" id="sourcingHR" value="<?php echo $Sourcing_HR;?>" name="Sourcing_HR" placeholder="Sourcing HR">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="dateOfSourcing">Date of Sourcing</label>
<input type="text" class="form-control" id="dateOfSourcing" name="DOS" placeholder="Date of sourcing">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="candidateName">Candidate Name</label>
<input type="text" class="form-control" id="candidateName" name="Candidate_Name" placeholder="Candidate Name">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="totalExperience">Total Experience</label>
<input type="text" class="form-control" id="totalExperience" name="Total_Experience" placeholder="Total Experience">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="currCTC">Curr. CTC</label>
<input type="text" class="form-control" id="currCTC" name="Current_CTC" placeholder="Current CTC">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="expCTC">Exp. CTC</label>
<input type="text" class="form-control" id="expCTC" name="Expected_CTC" placeholder="Expected CTC">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="currLocation">Current Location</label>
<input type="text" class="form-control" id="currLocation" name="Current_Location" placeholder="Current Location">
</div>
<div class="form-group col-xs-12 col-md-3">
<label for="prefLocation">Preferred Location</label>
<input type="text" class="form-control" id="prefLocation" name="Preferred_Location" placeholder="Preferred Location">
</div>
<div class="form-group col-xs-12 text-right">
<button class="btn btn-success" type="submit">
<i class="glyphicon glyphicon-floppy-disk saveIcon"></i> Save
</button>
</div>
</form>
</div>
</div>
</div>
</div>
*