PHP variables from form data - php
I have a PHP script that I am trying to use to pull form data from a html document, process it and then write the data to a mysql database table.
I can get the script to write to the mysql database ok but it is only passing empty strings, I have declared variables as empty strings at the start of the script, these are then passed $_POST data from the form elements, but it appears not to be working, I have tried every which way of quotation and concatenation without success.
When I echo the variables they are there but just empty, heres the codes, its quite a long form but most of the variables are processed the same way, any help would be greatly appreciated, I'm pretty new to PHP.
<?PHP
//Create null variables
$datereportId = "";
$timereportId = "";
$nameinvolvedId = "";
$maleinvolvedId = "";
$femaleinvolvedId = "";
$addressinvolvedId = "";
$telinvolvedId = "";
$deptinvolvedId = "";
$jobinvolvedId = "";
$supinvolvedId = "";
$cjemployId = "";
$othemployId = "";
$contractId = "";
$visitId = "";
$paxId = "";
$publicId = "";
$apronId = "";
$terminalId = "";
$hangarId = "";
$terminalId = "";
$othlocationId = "";
$captainId = "";
$csId = "";
$aircraftId = "";
$fltnoId = "";
$seatnoId = "";
$sectorId = "";
$accbyId = "";
$relationId = "";
$dateaccId = "";
$timeaccId = "";
$weathercondId = "";
$weathercommentsId = "";
$normdutyId = "";
$normdutnId = "";
$areacleanyId = "";
$areacleannId = "";
$heatyId = "";
$heatnId = "";
$ppeyId = "";
$ppenId = "";
$equipyId = "";
$equipnId = "";
$commentsId = "";
$accna1Id = "";
$accfi2Id = "";
$accex3Id = "";
$accel4Id = "";
$accco5Id = "";
$accob6Id = "";
$accfa7Id = "";
$accsl8Id = "";
$accma9Id = "";
$accpl10Id = "";
$accst11Id = "";
$accve12Id = "";
$accph13Id = "";
$accsh14Id = "";
$accth15Id = "";
$accot16Id = "";
$acccomments17Id = "";
$injna1Id = "";
$injab2Id = "";
$injla3Id = "";
$injbu4Id = "";
$injbr5Id = "";
$injfa6Id = "";
$injir7Id = "";
$injbl8Id = "";
$injfr9Id = "";
$injin10Id = "";
$injre11Id = "";
$injcr12Id = "";
$injel13Id = "";
$injco14Id = "";
$injsh15Id = "";
$injot16Id = "";
$injcomments17Id = "";
$bodna1Id = "";
$bodab2Id = "";
$bodba3Id = "";
$bodch4Id = "";
$bodhe5Id = "";
$bodey6Id = "";
$bodea7Id = "";
$bodno8Id = "";
$bodte9Id = "";
$bodha10Id = "";
$bodar11Id = "";
$bodle12Id = "";
$bodkn13Id = "";
$bodan14Id = "";
$bodfo15Id = "";
$bodot16Id = "";
$bodcomments17Id = "";
$faidyId = "";
$faidnId = "";
$faidy_nameId = "";
$fkityId = "";
$fkitnId = "";
$fkity_nameId = "";
$doctyId = "";
$doctnId = "";
$docty_commentId = "";
$hospyId = "";
$hospnId = "";
$hospy_commentId = "";
$medic_commentId = "";
$wit1nameId = "";
$wit1addrId = "";
$wit1telId = "";
$wit2nameId = "";
$wit2addrId = "";
$wit2telId = "";
$wit3nameId = "";
$wit3addrId = "";
$wit3telId = "";
$submitbyId = "";
$submitbyemailId = "";
$submitbytitleId = "";
$submitbydeptId = "";
$sexinvolvedId = "";
$orginvolved = "";
$location = "";
$normalduty = "";
$areaclean = "";
$heating = "";
$ppeworn = "";
$equipcheck = "";
$accnature = "";
$injnature = "";
$bodnature = "";
$firstaid = "";
$fakused = "";
$doctor = "";
$hospreq = "";
//If form is submitted populate data
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
//Populate variables with sanitised data variables
//$datereportId = test_input($_POST["id_datereport"]);
//$timereportId = test_input($_POST["id_timereport"]);
$nameinvolvedId = test_input($_POST["id_nameinvolved"]);
$maleinvolvedId = test_input($_POST["id_maleinvolved"]);
$femaleinvolvedId = test_input($_POST["id_femaleinvolved"]);
$addressinvolvedId = test_input($_POST["id_addressinvolved"]);
$telinvolvedId = test_input($_POST["id_telinvolved"]);
$deptinvolvedId = test_input($_POST["id_deptinvolved"]);
$jobinvolvedId = test_input($_POST["id_jobinvolved"]);
$supinvolvedId = test_input($_POST["id_supinvolved"]);
$cjemployId = test_input($_POST["id_cjemploy"]);
$othemployId = test_input($_POST["id_othemploy"]);
$contractId = test_input($_POST["id_contract"]);
$visitId = test_input($_POST["id_visit"]);
$paxId = test_input($_POST["id_pax"]);
$publicId = test_input($_POST["id_public"]);
$apronId = test_input($_POST["id_apron"]);
$terminalId = test_input($_POST["id_terminal"]);
$hangarId = test_input($_POST["id_hangar"]);
$terminalId = test_input($_POST["id_terminal"]);
$othlocationId = test_input($_POST["id_othlocation"]);
$captainId = test_input($_POST["id_captain"]);
$csId = test_input($_POST["id_cs"]);
$aircraftId = test_input($_POST["id_aircraft"]);
$fltnoId = test_input($_POST["id_fltno"]);
$seatnoId = test_input($_POST["id_seatno"]);
$sectorId = test_input($_POST["id_sector"]);
$accbyId = test_input($_POST["id_accby"]);
$relationId = test_input($_POST["id_relation"]);
//$dateaccId = test_input($_POST["id_dateacc"]);
//$timeaccId = test_input($_POST["id_timeacc"]);
$weathercondId = test_input($_POST["id_weathercond"]);
$weathercommentsId = test_input($_POST["id_weathercomments"]);
$normdutyId = test_input($_POST["id_normduty"]);
$normdutnId = test_input($_POST["id_normdutn"]);
$areacleanyId = test_input($_POST["id_areacleany"]);
$areacleannId = test_input($_POST["id_areacleann"]);
$heatyId = test_input($_POST["id_heaty"]);
$heatnId = test_input($_POST["id_heatn"]);
$ppeyId = test_input($_POST["id_ppey"]);
$ppenId = test_input($_POST["id_ppen"]);
$equipyId = test_input($_POST["id_equipy"]);
$equipnId = test_input($_POST["id_equipn"]);
$equipcommentsId = test_input($_POST["id_equipcomments"]);
$accna1Id = test_input($_POST["id_accna1"]);
$accfi2Id = test_input($_POST["id_accfi2"]);
$accex3Id = test_input($_POST["id_accex3"]);
$accel4Id = test_input($_POST["id_accel4"]);
$accco5Id = test_input($_POST["id_accco5"]);
$accob6Id = test_input($_POST["id_accob6"]);
$accfa7Id = test_input($_POST["id_accfa7"]);
$accsl8Id = test_input($_POST["id_accsl8"]);
$accma9Id = test_input($_POST["id_accma9"]);
$accpl10Id = test_input($_POST["id_accpl10"]);
$accst11Id = test_input($_POST["id_accst11"]);
$accve12Id = test_input($_POST["id_accve12"]);
$accph13Id = test_input($_POST["id_accph13"]);
$accsh14Id = test_input($_POST["id_accsh14"]);
$accth15Id = test_input($_POST["id_accth15"]);
$accot16Id = test_input($_POST["id_accot16"]);
$acccomments17Id = test_input($_POST["id_acccomments17"]);
$injna1Id = test_input($_POST["id_injna1"]);
$injab2Id = test_input($_POST["id_injab2"]);
$injla3Id = test_input($_POST["id_injla3"]);
$injbu4Id = test_input($_POST["id_injbu4"]);
$injbr5Id = test_input($_POST["id_injbr5"]);
$injfa6Id = test_input($_POST["id_injfa6"]);
$injir7Id = test_input($_POST["id_injir7"]);
$injbl8Id = test_input($_POST["id_injbl8"]);
$injfr9Id = test_input($_POST["id_injfr9"]);
$injin10Id = test_input($_POST["id_injin10"]);
$injre11Id = test_input($_POST["id_injre11"]);
$injcr12Id = test_input($_POST["id_injcr12"]);
$injel13Id = test_input($_POST["id_injel13"]);
$injco14Id = test_input($_POST["id_injco14"]);
$injsh15Id = test_input($_POST["id_injsh15"]);
$injot16Id = test_input($_POST["id_injot16"]);
$injcomments17Id = test_input($_POST["id_injcomments17"]);
$bodna1Id = test_input($_POST["id_bodna1"]);
$bodab2Id = test_input($_POST["id_bodab2"]);
$bodba3Id = test_input($_POST["id_bodba3"]);
$bodch4Id = test_input($_POST["id_bodch4"]);
$bodhe5Id = test_input($_POST["id_bodhe5"]);
$bodey6Id = test_input($_POST["id_bodey6"]);
$bodea7Id = test_input($_POST["id_bodea7"]);
$bodno8Id = test_input($_POST["id_bodno8"]);
$bodte9Id = test_input($_POST["id_bodte9"]);
$bodha10Id = test_input($_POST["id_bodha10"]);
$bodar11Id = test_input($_POST["id_bodar11"]);
$bodle12Id = test_input($_POST["id_bodle12"]);
$bodkn13Id = test_input($_POST["id_bodkn13"]);
$bodan14Id = test_input($_POST["id_bodan14"]);
$bodfo15Id = test_input($_POST["id_bodfo15"]);
$bodot16Id = test_input($_POST["id_bodot16"]);
$bodcomments17Id = test_input($_POST["id_bodcomments17"]);
$faidyId = test_input($_POST["id_faidy"]);
$faidnId = test_input($_POST["id_faidn"]);
$faidy_nameId = test_input($_POST["id_faidy_name"]);
$fkityId = test_input($_POST["id_fkity"]);
$fkitnId = test_input($_POST["id_fkitn"]);
$fkity_nameId = test_input($_POST["id_fkity_name"]);
$doctyId = test_input($_POST["id_docty"]);
$doctnId = test_input($_POST["id_doctn"]);
$docty_commentId = test_input($_POST["id_docty_comment"]);
$hospyId = test_input($_POST["id_hospy"]);
$hospnId = test_input($_POST["id_hospn"]);
$hospy_commentId = test_input($_POST["id_hospy_comment"]);
$medic_commentId = test_input($_POST["id_medic_comment"]);
$wit1nameId = test_input($_POST["id_wit1name"]);
$wit1addrId = test_input($_POST["id_wit1addr"]);
$wit1telId = test_input($_POST["id_wit1tel"]);
$wit2nameId = test_input($_POST["id_wit2name"]);
$wit2addrId = test_input($_POST["id_wit2addr"]);
$wit2telId = test_input($_POST["id_wit2tel"]);
$wit3nameId = test_input($_POST["id_wit3name"]);
$wit3addrId = test_input($_POST["id_wit3addr"]);
$wit3telId = test_input($_POST["id_wit3tel"]);
//$submitbyId = test_input($_POST["id_submitby"]);
//$submitbyemailId = test_input($_POST["id_submitbyemail"]);
//$submitbytitleId = test_input($_POST["id_submitbytitle"]);
//$submitbydeptId = test_input($_POST["id_submitbydept"]);
$sexinvolvedId = $maleinvolvedId . $femaleinvolvedId;
$orginvolved = $cjemployId . $othemployId . $contractId . $visitId . $paxId . $publicId;
$location = $apronId . $terminalId . $hangarId . $terminalId . $othlocationId;
$normalduty = $normdutyId . $normdutnId;
$areaclean = $areacleanyId . $areacleannId;
$heating = $heatyId . $heatnId;
$ppeworn = $ppeyId . $ppeyId;
$equipcheck = $equipyId . $equipnId;
$accnature = $accna1Id . $accfi2Id . $accex3Id . $accel4Id . $accco5Id . $accob6Id . $accfa7Id . $accsl8Id . $accma9Id . $accpl10Id . $accst11Id . $accve12Id . $accph13Id . $accsh14Id . $accth15Id . $accot16Id;
$injnature = $injna1Id . $injab2Id . $injla3Id . $injbu4Id . $injbr5Id . $injfa6Id . $injir7Id . $injbl8Id . $injfr9Id . $injin10Id . $injre11Id . $injcr12Id . $injel13Id . $injco14Id . $injsh15Id . $injot16Id;
$bodnature = $bodna1Id . $bodab2Id . $bodba3Id . $bodch4Id . $bodey6Id . $bodea7Id . $bodno8Id . $bodte9Id . $bodha10Id . $bodar11Id . $bodle12Id . $bodkn13Id . $bodan14Id . $bodfo15Id . $bodot16Id;
$firstaid = $faidyId . $faidnId;
$fakused = $fkityId . $fkitnId;
$doctor = $doctyId . $doctnId;
$hospreq = $hospyId . $hospnId;
}
//Sanitise all variables
function test_input($data)
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
//Mandatory variable handling, define variables and set to empty values
$nameErr = $emailErr = $posErr = $depErr = $dateErr = $timeErr = $dateErr1 = $timeErr1 = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if (empty($_POST["id_submitby"]))
{$nameErr = "Name is required";}
else
{$submitbyId = test_input($_POST["id_submitby"]);}
if (empty($_POST["id_submitbyemail"]))
{$emailErr = "Email is required";}
else
{$submitbyemailId = test_input($_POST["id_submitbyemail"]);}
if (empty($_POST["id_submitbytitle"]))
{$posErr = "Job title is required";}
else
{$submitbytitleId = test_input($_POST["id_submitbytitle"]);}
if (empty($_POST["id_submitbydept"]))
{$depErr = "Department is required";}
else
{$submitbydeptId = test_input($_POST["id_submitbydept"]);}
if (empty($_POST["id_datereport"]))
{$dateErr = "Date is required";}
else
{$datereportId = test_input($_POST["id_datereport"]);}
if (empty($_POST["id_timereport"]))
{$timeErr = "Time is required";}
else
{$datereportId = test_input($_POST["id_datereport"]);}
if (empty($_POST["id_dateacc"]))
{$dateErr1 = "Date is required";}
else
{$datereportId = test_input($_POST["id_dateacc"]);}
if (empty($_POST["id_timeacc"]))
{$timeErr1 = "Time is required";}
else
{$datereportId = test_input($_POST["id_timeacc"]);}
}
$email = test_input($_POST["id_submitbyemail"]);
if (!preg_match("/([\w\-]+\#[\w\-]+\.[\w\-]+)/",$email))
{
$emailErr1 = "Invalid email format";
}
spamcheck($_POST["id_submitbyemail"]);
function spamcheck($field)
{
//filter_var() sanitizes the e-mail
//address using FILTER_SANITIZE_EMAIL
$field=filter_var($field, FILTER_SANITIZE_EMAIL);
//filter_var() validates the e-mail
//address using FILTER_VALIDATE_EMAIL
if(filter_var($field, FILTER_VALIDATE_EMAIL))
{
$submitbyemailId_OK = $field;
return $submitbyemailId_OK;
}
else
{
$submitbyemailId_OK = "Spam email error";
return $submitbyemailId_OK;
}
}
//Check for null or empty variables and assign mysql value
function checkNull($var)
{
if($var == '')
{
$var = '--';
}
else
{
$var = $var;
}
}
//Apply checkNull to variables
checkNull($datereportId);
checkNull($timereportId);
checkNull($nameinvolvedId);
checkNull($addressinvolvedId);
checkNull($telinvolvedId);
checkNull($deptinvolvedId);
checkNull($jobinvolvedId);
checkNull($supinvolvedId);
checkNull($othlocationId);
checkNull($captainId);
checkNull($csId);
checkNull($aircraftId);
checkNull($fltnoId);
checkNull($seatnoId);
checkNull($sectorId);
checkNull($accbyId);
checkNull($relationId);
checkNull($dateaccId);
checkNull($timeaccId);
checkNull($weathercondId);
checkNull($weathercommentsId);
checkNull($equipcommentsId);
checkNull($acccomments17Id);
checkNull($injcomments17Id);
checkNull($bodcomments17Id);
checkNull($faidy_nameId);
checkNull($fkity_nameId);
checkNull($docty_commentId);
checkNull($hospy_commentId);
checkNull($medic_commentId);
checkNull($wit1nameId);
checkNull($wit1addrId);
checkNull($wit1telId);
checkNull($wit2nameId);
checkNull($wit2addrId);
checkNull($wit2telId);
checkNull($wit3nameId);
checkNull($wit3addrId);
checkNull($wit3telId);
checkNull($submitbyId);
checkNull($submitbyemailId);
checkNull($submitbytitleId);
checkNull($submitbydeptId);
checkNull($sexinvolvedId);
checkNull($orginvolvedId);
checkNull($locationId);
checkNull($normaldutyId);
checkNull($areacleanId);
checkNull($heatingId);
checkNull($ppewornId);
checkNull($equipcheckId);
checkNull($accnatureId);
checkNull($injnatureId);
checkNull($bodnatureId);
checkNull($firstaId);
checkNull($fakusedId);
checkNull($doctorId);
checkNull($hospreqId);
//Create mysql connection
$host = '';
$id = 'u1282431_skelly';
$pwd = '';
$db = 'db1282431_healthsafety';
$connection = #mysqli_connect($host, $id, $pwd, $db);
//Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect" . mysqli_connect_error();
}
//Insert entries from form into table
$sql="INSERT INTO healthsafety (datereport, timereport, nameinvolved, sexinvolved, addressinvolved, telinvolved, deptinvolved, jobinvolved, supinvolved, orginvolved, location, othlocation, captain, cs, aircraft, fltno, seatno, sector, accby, relation, dateacc, timeacc, weathercond, weathercomments, normalduty, areaclean, heating, ppeworn, equipcheck, equipcheckcomments, accnature, accother, injnature, injother, bodnature, bodother, firstaid, firstaidby, fakused, fakusedby, doctor, doctorinfo, hospreq, hospinfo, medcomment, wit1name, wit1addr, wit1tel, wit2name, wit2addr, wit2tel, wit3name, wit3addr, wit3tel, submitbyname, submitbyemail, submitbytitle, submitbydept)
VALUES
('$_POST[id_datereport]', '$timereportId', '$nameinvolvedId', '$sexinvolvedId', '$addressinvolvedId', '$telinvolvedId', '$deptinvolvedId', '$jobinvolvedId', '$supinvolvedId', '$orginvolvedId', '$locationId', '$othlocationId', '$captainId', '$csId', '$aircraftId', '$fltnoId', '$seatnoId', '$sectorId', '$accbyId', '$relationId', '$dateaccId', '$timeaccId', '$weathercondId', '$weathercommentsId', '$normaldutyId', '$areacleanId', '$heatingId', '$ppewornId', '$equipcheckId', '$commentsId', '$accnatureId', '$acccomments17Id', '$injnatureId', '$injcomments17Id', '$bodnatureId', '$bodcomments17Id', '$firstaid', '$faidy_nameId', '$fakusedId', '$fkity_nameId', '$doctorId', '$docty_commentId', '$hospreqId', '$hospy_commentId', '$medic_commentId', '$wit1nameId', '$wit1addrId', '$wit1telId', '$wit2nameId', '$wit2addrId', '$wit2telId', '$wit3nameId', '$wit3addrId', '$wit3telId', '$submitbyId', '$submitbyemailId', '$submitbytitleId', '$submitbydeptId');";
//Entry success or failure message
if (!mysqli_query($connection,$sql))
{
//Error message if entry fails
die('Error: ' . mysqli_error($connection));
}
else
{
//output success html page if entries were successfully added:
echo "Entries added";
}
?>
I will try to give you the main concept and you can then apply it to your case. Say you have a form like this:
<form action="path/to/handler/file.php" method="post">
Name: <input type="text" name="name">
Email: <input type="text" name="email">
Phone: <input type="text" name="phone">
<input type="submit" name="submit" value="Submit">
</form>
Now in the handler file:
if (!empty($_POST)) {
foreach ($_POST as $key => $value) {
${$key} = htmlspecialchars(trim($value), ENT_QUOTES, 'UTF-8');
}
}
This snippet of code will give you the next:
// supposing that the next values are those the user entered
$name = "john doe";
$email = "john.doe#gmail.com";
$phone = "55555555";
Now you can deal with these variables ($name, $email and $phone) to do whatever you want, like to check if a variable is empty or not, check if it is a valid email or not, check if it is an number or not, etc... and then save them in the database.
try using something like this, to get the propper contents:
function give_get($varname)
{
if (isset($_GET[$varname])) return trim($_GET[$varname]);
else return "";
}
function give_post($varname)
{
if (isset($_POST[$varname])) return trim($_POST[$varname]);
else return "";
}
Related
unable to change input data and db query result to array for pattern recognition
I'm unable to change an input string($prima = $_POST['id'];) and a db query result ($systemuser['id'];) into an array which will be used for pattern matching using one single character at a time and then trying to find a match in the database "id" row that is queried. The point is to use two-third of an id(supposedly incomplete id of a user of a system) to query and find the complete id. Please see my code. I'd appreciate some help. Thanks I'm getting "undefined offset:0 through 9" error. <?php session_start(); include_once('server.php'); $error = false; $gat = ""; $get = ""; $rt1 = ""; $rt2 = ""; $rt3 = ""; $rt4 = ""; $rt5 = ""; $rt6 = ""; $rt7 = ""; $rt8 = ""; $rt9 = ""; $rt0 = ""; if(isset($_POST['btn-login'])){ $firstname = $_POST['firstname']; $firstname = trim($firstname); $firstname = trim($_POST['firstname']); $firstname = htmlspecialchars(strip_tags($firstname)); $lastname = $_POST['lastname']; $lastname = trim($lastname); $lastname = trim($_POST['lastname']); $lastname = htmlspecialchars(strip_tags($lastname)); $id = $_POST['id']; $id = trim($id); $id = trim($_POST['id']); $id = htmlspecialchars(strip_tags($id)); $gender = $_POST['gender']; if(!$error) { //search data if no errors $query = "select * from subscribers"; $conditions = array(); if(! empty($firstname)){ $conditions[] = "firstname='$firstname'"; } if(! empty($lastname)){ $conditions[] = "lastname='$lastname'"; } if(! empty($gender)){ $conditions[] = "gender='$gender'"; } $sql = $query; if(count($conditions) > 0){ $sql .= " WHERE " . implode(' AND ', $conditions); } $result = mysqli_query($conn, $sql); while($systemuser = mysqli_fetch_array($result, MYSQLI_ASSOC)){ $systemuser['id']; $gat = $systemuser['id']; } //convert user input to array $prima = $_POST['id']; $prima = array(); $rt1 = $prima[0]; $rt2 = $prima[1]; $rt3 = $prima[2]; $rt4 = $prima[3]; $rt5 = $prima[4]; $rt6 = $prima[5]; $rt7 = $prima[6]; $rt8 = $prima[7]; $rt9 = $prima[8]; $rt0 = $prima[9]; //retrieve and convert db data into array $gat = array(); foreach( $gat as $get ){ $rt1 = $prima[0]; if (preg_match("/[$rt1]+/", $gat));{ $get += 1; } $rt2 = $prima[1]; if (preg_match("/[$rt2]+/", $gat)){ $get += 1; } $rt3 = $prima[2]; if (preg_match("/[$rt3]+/", $gat)){ $get += 1; } $rt4 = $prima[3]; if (preg_match("/[$rt4]+/", $gat)){ $get += 1; } $rt5 = $prima[4]; if (preg_match("/[$rt5]+/", $gat)){ $get += 1; } $rt6 = $prima[5]; if (preg_match("/[$rt6]+/", $gat)){ $get += 1; } $rt7 = $prima[6]; if (preg_match("/[$rt7]+/", $gat)){ $get += 1; } $rt8 = $prima[7]; if (preg_match("/[$rt8]+/", $gat)){ $get += 1; } $rt9 = $prima[8]; if (preg_match("/[$rt9]+/", $gat)){ $get += 1; } $rt0 = $prima[9]; if (preg_match("/[$rt0]+/", $gat)){ $get += 1; } if ($get > 9){ echo 'match found!'; } else{ echo 'match not found!'; } } } } ?>
I started to refactor but there is just too much that is wrong. You are getting that Undefined offset: 0 notice because... <?php $prima = array(); $rt1 = $prima[0]; Is referencing offset zero on an empty array. The code makes no sense. You seem to frequently assign a value and then overwrite in on the next line. FWIW: strings in PHP can behave much like an array... UPDATE: I'm a little confused about crux here honestly. If I wanted to reference the first and second letters in a string I would do: $str = "I like PHP"; $firstLetter = (isset($str[0])) ? $str[0] : ''; $secondLetter = (isset($str[1])) ? $str[1] : ''; See if you can follow this example: $str = 'I like PHP'; for ($i=0; $i<strlen($str); $i++) { echo $str[$i] . "|"; } And then... are you looking to do a WHERE foo LIKE 'a%' type query? A "wildcard" search?
Check duplication while uploading to database
I need to find duplicated details in the existing table while uploading a Excel file that contains some details,i need to find that by phone number and customer name. I am using mattexcel to upload the data into database. I don't want to insert that details if it is in there but other details must insert into that table Controller public function importExcel(Request $request) { if ($request->hasFile('import_file')) { Excel::load($request->file('import_file')->getRealPath(), function ($reader) { foreach ($reader->toArray() as $key => $row) { $data['customername'] = $row['customername']; $data['chassis'] = $row['chassis']; $data['model'] = $row['model']; $data['branchcode'] = $row['branchcode']; $data['delivery'] = $row['delivery']; $data['customerid'] = $row['customerid']; $data['phone'] = $row['phone']; $data['invoicedate'] = $row['invoicedate']; $data['dse'] = $row['dse']; $data['branch'] = $row['branch']; $data['finance'] = $row['finance']; $data['dono'] = $row['dono']; $data['invoice'] = $row['invoice']; $data['zsm'] = $row['zsm']; $data['sm'] = $row['sm']; $data['agm'] = $row['agm']; $data['dsecode'] = $row['dsecode']; $data['address'] = $row['address']; $data['email'] = $row['email']; $data['color'] = $row['color']; $data['extendedwarrenty'] = $row['extendedwarrenty']; $data['autocaddownload'] = $row['autocaddownload']; $data['numberplate'] = $row['numberplate']; $data['mcpstatus'] = $row['mcpstatus']; $data['plandt'] = $row['plandt']; $data['planok'] = $row['planok']; $data['fasttag'] = $row['fasttag']; // $data['settilment_pdf_path'] = $row['settilment_pdf_path']; $data['rcstatus'] = $row['rcstatus']; $branch = Branch::where([['branch_code', $row['branchcode']], ['status', 0]])->first(); $registration_id = Registration::orderBy('registration_id', 'desc')->take(1)->get(); if (count($registration_id) > 0) { $regid = $registration_id[0]->registration_id; $regid = $regid + 1; } else { $regid = 1; } $register = new Registration(); $register->registration_id = $regid; $register->customername = $row['customername']; $register->chassis = $row['chassis']; $register->model = $row['model']; $register->branchcode = $row['branchcode']; $register->delivery = $row['delivery']; $register->customerid = $row['customerid']; $register->phone = $row['phone']; $register->invoicedate = $row['invoicedate']; $register->dse = $row['dse']; $register->branch = $row['branch']; $register->finance = $row['finance']; $register->dono = $row['dono']; $register->invoice = $row['invoice']; $register->zsm = $row['zsm']; $register->sm = $row['sm']; $register->agm = $row['agm']; $register->dsecode = $row['dsecode']; $register->address = $row['address']; $register->email = $row['email']; $register->color = $row['color']; $register->extendedwarrenty = $row['extendedwarrenty']; $register->autocaddownload = $row['autocaddownload']; $register->numberplate = $row['numberplate']; $register->mcpstatus = $row['mcpstatus']; $register->plandt = $row['plandt']; $register->planok = $row['planok']; $register->fasttag = $row['fasttag']; $register->rcstatus = $row['rcstatus']; $register->dealership = $branch->dealership_id; $register->zone = $branch->zone_id; $register->dh = $branch->dh_id; $register->status = '0'; $register->created_user_id = Session::get('created_id'); $register->save(); $regidn = Registration::orderBy('registration_id', 'desc')->get(); $regidd = $regidn[0]->registration_id; $ssitrack = new Ssi_track(); $ssitrack->registration_id = $regid; $ssitrack->ssi_track_id = $regid; $ssitrack->save(); $ssitrackk = Ssi_track::orderBy('ssi_track_id', 'desc')->get(); $ssitrackk = $ssitrackk[0]->registration_id; } }); } return back()->with('success', 'Your File Is Successfully Uploaded To Database!'); }
Option 1. You can add unique values combination in migration. Schema::table('your_table_name', function (Blueprint $table) { $table->unique(['phone ','customername ']); }); This won't let you insert same combination values for these column combination, however it also throws error stopping you import function. Option 2 (Better). Check if value already exits and ignore import for that column. $old_customer = Regiter::where('phone', $row['phone'])->where('customername', $customername )->first(); //Inser only if customer not found if(is_null($old_customer)) { //INSERT QUERY } To decrease number of query you can pluck name and phone with single query or use any other optimization tricks.
How to retrieve data via a while loop in PHP
I am looping through a MySQL result but I am running into an issue. The issue is that only my first if statement is being executed. The rest of my if statements are returning empty strings. What is confusing me is this: When I remove the first if statement in the while loop, the next if statement will return data but all other statements below it will not. Here is my relevant code: // Get Addresses $queryAddresses = "SELECT * FROM contact_addresses WHERE contact_id = $contactID"; $resultAddresses = mysqli_query($dbc, $queryAddresses); $numAddresses = mysqli_num_rows($resultAddresses); if ($numAddresses >= 1) { $address_labels = ''; $addresses = ''; while ($address = mysqli_fetch_array($resultAddresses, MYSQLI_ASSOC)) { $address_labels .= $address['label'].'<br>'; if (!empty($address['address'])) { $address = $address['address'].', '; } else { $address = ''; } /* ALL OF THE IF STATEMENTS BELOW THIS LINE RETURN EMPTY STRINGS EVEN THOUGH THE INFORMATION IS STORED IN THE DATABASE. */ if (!empty($address['address_two'])) { $address_two = $address['address_two'].', '; } else { $address_two = ''; } if (!empty($address['city'])) { $city = $address['city'].', '; } else { $city = ''; } if (!empty($address['state'])) { $state = $address['state'].', '; } else { $state = ''; } if (!empty($address['zip'])) { $zip = $address['zip'].', '; } else { $zip = ''; } if (!empty($address['country'])) { $country = $address['country'].', '; } else { $country = ''; } $addresses .= $address.''.$address_two.''.$city.''.$state.''.$zip.''.$country.'<br>'; } }
With the line $address = $address['address'].', '; you are replacing the $address array with the new string and wiping out the array. Try changing the string variable name: if (!empty($address['address'])) { $address_one = $address['address'].', '; } else { $address_one = ''; } if (!empty($address['address_two'])) { $address_two = $address['address_two'].', '; } else { $address_two = ''; } if (!empty($address['city'])) { $city = $address['city'].', '; } else { $city = ''; } if (!empty($address['state'])) { $state = $address['state'].', '; } else { $state = ''; } if (!empty($address['zip'])) { $zip = $address['zip'].', '; } else { $zip = ''; } if (!empty($address['country'])) { $country = $address['country'].', '; } else { $country = ''; } $addresses .= $address_one.''.$address_two.''.$city.''.$state.''.$zip.''.$country.'<br>';
while ($address = mysqli_fetch_array($resultAddresses, MYSQLI_ASSOC)) { $address_labels .= $address['label'].'<br>'; if (!empty($address['address'])) { $address = $address['address'].', '; } else { $address = ''; } } What I found while going through your code is you are using the same variable $address for the while loop as well as the first if statement. Try changing the loop variable, say $result and try
Plz paste following Code in your editor: $servername = "localhost"; $username = "root"; $password = ""; $dbname = "databasename"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } $sql = "SELECT * FROM users"; $result = $conn->query($sql); if ($result->num_rows > 0) { // output data of each row while($row = $result->fetch_assoc()) { //echo "id: " . $row["id"]. " - Name: " . $row["first_name"]. " " . $row["last_name"]. "<br>"; $fnanem =""; $lnanem =""; if(!empty($row["first_name"])){ $fnanem = $row["first_name"]; }else{ $fnanem = ""; } if(!empty($row["last_name"])){ $lnanem = $row["last_name"]; }else{ $lnanem = ""; } echo $fnanem."---->".$lnanem."<br>"; } } else { echo "0 results"; } $conn->close();
In the following code change the variable, as it is replacing the values of the array by assigning new value. if (!empty($address['address'])) { $address = $address['address'].', ';//Chang variable name here } else { $address = '';//Chang variable name here }
Try to use paypal invocing app in my website but following are error found
I have try most of the class that are availble on internet but when i execute some error found here ---------------------------------Send Invoice API------------------------------------- Failure Invalid request parameter: quantity must be in the range 0.001 through 9999.999 → quantity = 0 but i have set this quantity =1 then why it given this error... i have use following code of require_once('class.invoice.php'); $ppInv = new PaypalInvoiceAPI("sandbox"); //pass 'live' for actual paypal account /** * Populate Data */ $aryData['language'] = "en_US"; $aryData['merchantEmail'] = $business; $aryData['payerEmail'] = "eyemedianetwork#gmail.com"; $aryData['currencyCode'] = "USD"; //$aryData['orderId'] = "0001"; $aryData['orderId'] = strtotime('now'); $aryData['invoiceDate'] = "2014-09-19T05:38:48Z"; $aryData['dueDate'] = "2014-12-31T05:38:48Z"; $aryData['paymentTerms'] = "Net45"; //[DueOnReceipt, DueOnDateSpecified, Net10, Net15, Net30, Net45] $aryData['discountPercent'] = "0"; $aryData['discountAmount'] = "0"; $aryData['invoiceTerms'] = "These are Inovice Terms and Conditions"; $aryData['invoiceNote'] = "These are Invoice notes"; $aryData['merchantMemo'] = "This is Merchant Memo"; $aryData['shippingAmount'] = "10.00"; $aryData['shippingTaxName'] = "S Tax Name"; $aryData['shippingTaxRate'] = "5.00"; $aryData['logoURL'] = "https://xyx.com/wp-content/uploads/2013/12/logo1.png"; $aryData['merchantFirstName'] = "Ashish"; $aryData['merchantLastName'] = "Sharma"; $aryData['merchantBusinessName'] = "Selling"; $aryData['merchantPhone'] = ""; $aryData['merchantFax'] = ""; $aryData['merchantWebsite'] = ""; $aryData['merchantCustomValue'] = ""; $aryData['merchantLine1'] = "Bhopal"; $aryData['merchantLine2'] = "Merchant Address Line 2"; $aryData['merchantCity'] = "Merchant City"; $aryData['merchantState'] = "Merchant State"; $aryData['merchantPostalCode'] = "462021"; $aryData['merchantCountryCode'] = "IN"; $aryData['billingFirstName'] = "Sam"; $aryData['billingLastName'] = "Peter"; $aryData['billingBusinessName'] = "Shiping"; $aryData['billingPhone'] = ""; $aryData['billingFax'] = ""; $aryData['billingWebsite'] = ""; $aryData['billingCustomValue'] = ""; $aryData['billingLine1'] = "Bhopal"; $aryData['billingLine2'] = ""; $aryData['billingCity'] = ""; $aryData['billingState'] = ""; $aryData['billingPostalCode'] = "462021"; $aryData['billingCountryCode'] = "IN"; $aryData['shippingFirstName'] = "Ashish"; $aryData['shippingLastName'] = "Sharma"; $aryData['shippingBusinessName'] = "Shipping Business Name"; $aryData['shippingPhone'] = "Shipping Phone"; $aryData['shippingFax'] = "Shipping Fax"; $aryData['shippingWebsite'] = "Shipping Website"; $aryData['shippingCustomValue'] = "Shipping Custom Value"; $aryData['shippingLine1'] = "India"; $aryData['shippingLine2'] = "Shipping Line 2"; $aryData['shippingCity'] = "Shipping City"; $aryData['shippingState'] = "Shipping State"; $aryData['shippingPostalCode'] = "Shipping Postal Code"; $aryData['shippingCountryCode'] = "US"; $aryItems[0]['name'] = "Individual Product"; $aryItems[0]['description'] = "Item 1 Description"; $aryItems[0]['date'] = "2014-09-20T05:38:48Z"; $aryItems[0]['quantity'] = "003"; $aryItems[0]['unitprice'] = "1"; $aryItems[0]['taxName'] = ""; $aryItems[0]['taxRate'] = ""; /** * Create Invoice Task */ echo "<br /><br />---------------------------------Send Invoice API-------------------------------------<br /><br />"; $res = $ppInv->doCreateInvoice($aryData, $aryItems); // echo "<pre>"; // print_r($res); // echo "</pre>"; if($res['responseEnvelope.ack']== "Success") { echo "<br />Success Creating Invoice: '{$res['invoiceID']}'"; echo "<br /><br />---------------------------------Send Invoice API-------------------------------------<br /><br />"; $res_send = $ppInv->doSendInvoice($res['invoiceID']); // echo "<pre>"; // print_r($res_send); // echo "</pre>"; if($res_send['responseEnvelope.ack']== "Success") { echo "<br />Success Sending Invoice"; } else { //Get Error String echo $ppInv->formatErrorMessages($res_send); } } else { //Get Error String echo $ppInv->formatErrorMessages($res); } ?> This is the fuction function prepareCreateInvoice($aryData, $aryItems) { $aryCreateInvoice = array(); if(trim(#$aryData['language'])!= "") $aryCreateInvoice['requestEnvelope.errorLanguage'] = $aryData['language']; //en_US //TODO if(trim(#$aryData['merchantEmail'])!= "") $aryCreateInvoice['invoice.merchantEmail'] = $aryData['merchantEmail']; if(trim(#$aryData['payerEmail'])!= "") $aryCreateInvoice['invoice.payerEmail'] = $aryData['payerEmail']; if(trim(#$aryData['currencyCode'])!= "") $aryCreateInvoice['invoice.currencyCode'] = $aryData['currencyCode']; //USD TODO if(trim(#$aryData['orderId'])!= "") $aryCreateInvoice['invoice.number'] = $aryData['orderId']; if(trim(#$aryData['invoiceID'])!= "") $aryCreateInvoice['invoiceID'] = $aryData['invoiceID']; if(trim(#$aryData['paymentTerms'])!= "") $aryCreateInvoice['invoice.paymentTerms'] = $aryData['paymentTerms']; //[DueOnReceipt, DueOnDateSpecified, Net10, Net15, Net30, Net45] if(trim(#$aryData['discountPercent'])!= "") $aryCreateInvoice['invoice.discountPercent'] = $aryData['discountPercent']; if(trim(#$aryData['discountAmount'])!= "") $aryCreateInvoice['invoice.discountAmount'] = $aryData['discountAmount']; if(trim(#$aryData['invoiceTerms'])!= "") $aryCreateInvoice['invoice.terms'] = $aryData['invoiceTerms']; if(trim(#$aryData['invoiceNote'])!= "") $aryCreateInvoice['invoice.note'] = $aryData['invoiceNote']; if(trim(#$aryData['merchantMemo'])!= "") $aryCreateInvoice['invoice.merchantMemo'] = $aryData['merchantMemo']; if(trim(#$aryData['shippingAmount'])!= "") $aryCreateInvoice['invoice.shippingAmount'] = $aryData['shippingAmount']; if(trim(#$aryData['shippingTaxName'])!= "") $aryCreateInvoice['invoice.shippingTaxName'] = $aryData['shippingTaxName']; if(trim(#$aryData['shippingTaxRate'])!= "") $aryCreateInvoice['invoice.shippingTaxRate'] = $aryData['shippingTaxRate']; if(trim(#$aryData['logoURL'])!= "") $aryCreateInvoice['invoice.logoUrl'] = $aryData['logoURL']; if(trim(#$aryData['merchantFirstName'])!= "") $aryCreateInvoice['invoice.merchantInfo.firstName'] = $aryData['merchantFirstName']; if(trim(#$aryData['merchantLastName'])!= "") $aryCreateInvoice['invoice.merchantInfo.lastName'] = $aryData['merchantLastName']; if(trim(#$aryData['merchantBusinessName'])!= "") $aryCreateInvoice['invoice.merchantInfo.businessName'] = $aryData['merchantBusinessName']; if(trim(#$aryData['merchantPhone'])!= "") $aryCreateInvoice['invoice.merchantInfo.phone'] = $aryData['merchantPhone']; if(trim(#$aryData['merchantFax'])!= "") $aryCreateInvoice['invoice.merchantInfo.fax'] = $aryData['merchantFax']; if(trim(#$aryData['merchantWebsite'])!= "") $aryCreateInvoice['invoice.merchantInfo.website'] = $aryData['merchantWebsite']; if(trim(#$aryData['merchantCustomValue'])!= "") $aryCreateInvoice['invoice.merchantInfo.customValue'] = $aryData['merchantCustomValue']; if(trim(#$aryData['merchantLine1'])!= "") $aryCreateInvoice['invoice.merchantInfo.address.line1'] = $aryData['merchantLine1']; if(trim(#$aryData['merchantLine2'])!= "") $aryCreateInvoice['invoice.merchantInfo.address.line2'] = $aryData['merchantLine2']; if(trim(#$aryData['merchantCity'])!= "") $aryCreateInvoice['invoice.merchantInfo.address.city'] = $aryData['merchantCity']; if(trim(#$aryData['merchantState'])!= "") $aryCreateInvoice['invoice.merchantInfo.address.state'] = $aryData['merchantState']; if(trim(#$aryData['merchantPostalCode'])!= "") $aryCreateInvoice['invoice.merchantInfo.address.postalCode'] = $aryData['merchantPostalCode']; if(trim(#$aryData['merchantCountryCode'])!= "") $aryCreateInvoice['invoice.merchantInfo.address.countryCode'] = $aryData['merchantCountryCode']; if(trim(#$aryData['billingFirstName'])!= "") $aryCreateInvoice['invoice.billingInfo.firstName'] = $aryData['billingFirstName']; if(trim(#$aryData['billingLastName'])!= "") $aryCreateInvoice['invoice.billingInfo.lastName'] = $aryData['billingLastName']; if(trim(#$aryData['billingBusinessName'])!= "") $aryCreateInvoice['invoice.billingInfo.businessName'] = $aryData['billingBusinessName']; if(trim(#$aryData['billingPhone'])!= "") $aryCreateInvoice['invoice.billingInfo.phone'] = $aryData['billingPhone']; if(trim(#$aryData['billingFax'])!= "") $aryCreateInvoice['invoice.billingInfo.fax'] = $aryData['billingFax']; if(trim(#$aryData['billingWebsite'])!= "") $aryCreateInvoice['invoice.billingInfo.website'] = $aryData['billingWebsite']; if(trim(#$aryData['billingCustomValue'])!= "") $aryCreateInvoice['invoice.billingInfo.customValue'] = $aryData['billingCustomValue']; if(trim(#$aryData['billingLine1'])!= "") $aryCreateInvoice['invoice.billingInfo.address.line1'] = $aryData['billingLine1']; if(trim(#$aryData['billingLine2'])!= "") $aryCreateInvoice['invoice.billingInfo.address.line2'] = $aryData['billingLine2']; if(trim(#$aryData['billingCity'])!= "") $aryCreateInvoice['invoice.billingInfo.address.city'] = $aryData['billingCity']; if(trim(#$aryData['billingState'])!= "") $aryCreateInvoice['invoice.billingInfo.address.state'] = $aryData['billingState']; if(trim(#$aryData['billingPostalCode'])!= "") $aryCreateInvoice['invoice.billingInfo.address.postalCode'] = $aryData['billingPostalCode']; if(trim(#$aryData['billingCountryCode'])!= "") $aryCreateInvoice['invoice.billingInfo.address.countryCode'] = $aryData['billingCountryCode']; if(trim(#$aryData['shippingFirstName'])!= "") $aryCreateInvoice['invoice.shippingInfo.firstName'] = $aryData['shippingFirstName']; if(trim(#$aryData['shippingLastName'])!= "") $aryCreateInvoice['invoice.shippingInfo.lastName'] = $aryData['shippingLastName']; if(trim(#$aryData['shippingBusinessName'])!= "") $aryCreateInvoice['invoice.shippingInfo.businessName'] = $aryData['shippingBusinessName']; if(trim(#$aryData['shippingPhone'])!= "") $aryCreateInvoice['invoice.shippingInfo.phone'] = $aryData['shippingPhone']; if(trim(#$aryData['shippingFax'])!= "") $aryCreateInvoice['invoice.shippingInfo.fax'] = $aryData['shippingFax']; if(trim(#$aryData['shippingWebsite'])!= "") $aryCreateInvoice['invoice.shippingInfo.website'] = $aryData['shippingWebsite']; if(trim(#$aryData['shippingCustomValue'])!= "") $aryCreateInvoice['invoice.shippingInfo.customValue'] = $aryData['shippingCustomValue']; if(trim(#$aryData['shippingLine1'])!= "") $aryCreateInvoice['invoice.shippingInfo.address.line1'] = $aryData['shippingLine1']; if(trim(#$aryData['shippingLine2'])!= "") $aryCreateInvoice['invoice.shippingInfo.address.line2'] = $aryData['shippingLine2']; if(trim(#$aryData['shippingCity'])!= "") $aryCreateInvoice['invoice.shippingInfo.address.city'] = $aryData['shippingCity']; if(trim(#$aryData['shippingState'])!= "") $aryCreateInvoice['invoice.shippingInfo.address.state'] = $aryData['shippingState']; if(trim(#$aryData['shippingPostalCode'])!= "") $aryCreateInvoice['invoice.shippingInfo.address.postalCode'] = $aryData['shippingPostalCode']; if(trim(#$aryData['shippingCountryCode'])!= "") $aryCreateInvoice['invoice.shippingInfo.address.countryCode'] = $aryData['shippingCountryCode']; //US TODO $nLoop = count($aryItems); for($cnt=0;$cnt<$nLoop;$cnt++) { if(trim(#$aryItems[$cnt]['name'])!= "") $aryCreateInvoice["invoice.itemList.item($cnt).name"] = $this->adjustStringLength($aryItems[$cnt]['item_name']); if(trim(#$aryItems[$cnt]['description'])!= "") $aryCreateInvoice["invoice.itemList.item($cnt).description"]= $this->adjustStringLength($aryItems[$cnt]['item_description']); #if(trim(#$aryData['$aryItems[$cnt]['date']'])!= "") #$aryCreateInvoice["invoice.itemList.item($cnt).date"] = $aryItems[$cnt]['date']; if(trim(#$aryItems[$cnt]['quantity'])!= "") $aryCreateInvoice["invoice.itemList.item($cnt).quantity"] = $this->adjustStringLength($aryItems[$cnt]['item_quantity']); if(trim(#$aryItems[$cnt]['unitprice'])!= "") $aryCreateInvoice["invoice.itemList.item($cnt).unitPrice"] = $this->adjustStringLength($aryItems[$cnt]['item_unitprice']); if(trim(#$aryItems[$cnt]['taxName'])!= "") $aryCreateInvoice["invoice.itemList.item($cnt).taxName"] = $aryItems[$cnt]['taxName']; if(trim(#$aryItems[$cnt]['taxRate'])!= "") $aryCreateInvoice["invoice.itemList.item($cnt).taxRate"] = $aryItems[$cnt]['taxRate']; } if(trim(#$aryData['invoiceDate'])!= "") $aryCreateInvoice['invoice.invoiceDate'] = urldecode($aryData['invoiceDate']); //2011-12-31T05:38:48Z if(trim(#$aryData['dueDate'])!= "") $aryCreateInvoice['invoice.dueDate'] = urldecode($aryData['dueDate']); // $reqstr .= "&invoice.invoiceDate={$aryData['invoiceDate']}"; // $reqstr .= "&invoice.dueDate={$aryData['dueDate']}"; $request_string = http_build_query( $aryCreateInvoice ); return $request_string; }#end of prepareCreateInvoice()
data not being updated
Data not being updated when i am trying to update, its showing could not update data only always, i have the session carrying reg from my registration table and i want to update with reg in my slam table in which reg is present. here reg is present in both tables. <?php session_start(); if($_SERVER["REQUEST_METHOD"] == "POST") { $con=mysqli_connect("xyz","aaa","aaa","aaa"); if (mysqli_connect_errno($con)) { echo "Failed to connect to MySQL: " . mysqli_connect_error(); } $reg = $_REQUEST["reg"]; $t1 = $_REQUEST["t"]; $t2 = $_REQUEST['t2']; $t3 = $_REQUEST['t3']; $t4 = $_REQUEST['t4']; $t5 = $_REQUEST['t5']; $t6 = $_REQUEST['t6']; $t7 = $_REQUEST['t7']; $t8 = $_REQUEST['t8']; $t9 = $_REQUEST['t9']; $t10 = $_REQUEST['t10']; $t11 = $_REQUEST['t11']; $t13 = $_REQUEST['t13']; $t14 = $_REQUEST['t14']; $t15 = $_REQUEST['t15']; $t16 = $_REQUEST['t16']; $t17 = $_REQUEST['t17']; $t18 = $_REQUEST['t18']; $t19 = $_REQUEST['t19']; $t20 = $_REQUEST['t20']; $t21 = $_REQUEST['t21']; $t22 = $_REQUEST['t22']; $t23 = $_REQUEST['t23']; $t24 = $_REQUEST['t24']; $t25 = $_REQUEST['t25']; $t26 = $_REQUEST['t26']; $t27 = $_REQUEST['t27']; $t28 = $_REQUEST['t28']; $t29 = $_REQUEST['t29']; $t30 = $_REQUEST['t30']; $t31 = $_REQUEST['t31']; $t32 = $_REQUEST['t32']; $t33 = $_REQUEST['t33']; $t34 = $_REQUEST['t34']; $t35 = $_REQUEST['t35']; $t36 = $_REQUEST['t36']; $t37 = $_REQUEST['t37']; $t38 = $_REQUEST['t38']; $sql="UPDATE slambook SET iam = '$t1' ,pals = '$t2',birthday = '$t3' ,mobile = '$t4' ,zodiac ='$t5' ,address = '$t6',email ='$t7',site = '$t8',id = '$t9' ,hang = '$t10',food = '$t11',colour = '$t13',outfit = '$t14',novel = '$t15',singer = '$t16',song = '$t17',movie = '$t18',actor = '$t19',aim = '$t20',memor = '$t21',you = '$t22',date = '$t23',city = '$t24',frienship = '$t25',nuts = '$t26',besties = '$t27',destiny = '$t28',y = '$t29',moment = '$t30',achieve = '$t31',dream = '$t32',experience = '$t33',imagination = '$t34',regrets = '$t35',stupid = '$t36',belief = '$37',about = '$38' where reg=$reg"; $retval = mysqli_query($con,$sql); if(!$retval ) { die('Could not update data: ' . mysql_error()); } echo "Updated data successfully\n"; mysqli_close($con); } else { ?>