I have a problem with my php-code. On the first site is a list with all the data. The table of the data is correctly displayed. In the last column of the table is a link placed to the next page which should hand over the id of the row.
Here's the link:
print 'Ändern';
But I can't now get the data into the input fields for edit. The form show up correct, but i have in every input field this error:
Warning: Illegal string offset 'vorname' in /home_pr5/d/e/deniseli.ch/htdocs/www.deniseli.ch/T .... tor/editsr.php on line 130S
Here's the editsr.php:
<?php
session_start();
require_once("inc/config.inc.php");
require_once("inc/functions.inc.php");
$id = $_GET['id'];
$statement = $pdo->prepare("SELECT * FROM users WHERE id = $id");
$result = $statement->execute(array('id' => ['id']));
$user = $statement->fetch();
include("templates/header.inc.php");
if(isset($_GET['save'])) {
$save = $_GET['save'];
if($save == 'personal_data') {
$vorname = trim($_POST['vorname']);
$nachname = trim($_POST['nachname']);
$adresse = trim($_POST['adresse']);
$plz = trim($_POST['plz']);
$ort = trim($_POST['ort']);
$geburtstag = trim($_POST['geburtstag']);
$handy = trim($_POST['handy']);
$liga = trim($_POST['liga']);
$verein = trim($_POST['verein']);
$bank = trim($_POST['bank']);
$iban = trim($_POST['iban']);
if($vorname == "" || $nachname == "" || $adresse == "" || $plz == "" || $ort == "" || $handy == "" || $liga == "" || $verein == "") {
$error_msg = "Bitte alle Angaben ausfüllen.";
} else {
$statement = $pdo->prepare("UPDATE users SET vorname = :vorname, nachname = :nachname, adresse = :adresse, plz = :plz, ort = :ort, geburtstag = :geburtstag, handy = :handy, liga = :liga, verein = :verein, bank = :bank, iban = :iban, id = :id, updated_at=NOW() WHERE id = $id");
$result = $statement->execute(array('vorname' => $vorname, 'nachname'=> $nachname,'adresse' => $adresse, 'plz' => $plz, 'ort' => $ort, 'geburtstag' => $geburtstag, 'handy' => $handy, 'liga' => $liga, 'verein' => $verein,'bank' => $bank, 'iban' => $iban, 'id' => $user['id'] ));
$success_msg = "Daten erfolgreich gespeichert.";
}
} else if($save == 'email') {
$passwort = $_POST['passwort'];
$email = trim($_POST['email']);
$email2 = trim($_POST['email2']);
if($email != $email2) {
$error_msg = "Die eingegebenen E-Mail-Adressen stimmten nicht überein.";
} else if(!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error_msg = "Bitte eine gültige E-Mail-Adresse eingeben.";
} else if(!password_verify($passwort, $user['passwort'])) {
$error_msg = "Bitte korrektes Passwort eingeben.";
} else {
$statement = $pdo->prepare("UPDATE users SET email = :email WHERE id = $id");
$result = $statement->execute(array('email' => $email));
$success_msg = "E-Mail-Adresse erfolgreich gespeichert.";
}
} else if($save == 'passwort') {
$passwortAlt = $_POST['passwortAlt'];
$passwortNeu = trim($_POST['passwortNeu']);
$passwortNeu2 = trim($_POST['passwortNeu2']);
if($passwortNeu != $passwortNeu2) {
$error_msg = "Die eingegebenen Passwörter stimmten nicht überein.";
} else if($passwortNeu == "") {
$error_msg = "Das Passwort darf nicht leer sein.";
} else if(!password_verify($passwortAlt, $user['passwort'])) {
$error_msg = "Bitte korrektes Passwort eingeben.";
} else {
$passwort_hash = password_hash($passwortNeu, PASSWORD_DEFAULT);
$statement = $pdo->prepare("UPDATE users SET passwort = :passwort WHERE id = $id");
$result = $statement->execute(array('passwort' => $passwort_hash));
$success_msg = "Passwort erfolgreich gespeichert.";
}
}
}
?>
<div class="container main-container">
<h1>Schiedsrichter Profil bearbeiten</h1>
<?php
if(isset($success_msg) && !empty($success_msg)):
?>
<div class="alert alert-success">
×
<?php echo $success_msg; ?>
</div>
<?php
endif;
?>
<?php
if(isset($error_msg) && !empty($error_msg)):
?>
<div class="alert alert-danger">
×
<?php echo $error_msg; ?>
</div>
<?php
endif;
?>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Übersicht</li>
<li role="presentation">Persönliche Daten</li>
<li role="presentation">E-Mail</li>
<li role="presentation">Passwort</li>
</ul>
<!-- Übersicht-->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<br>
<form action="?save=personal_data&id=<?php echo $_GET['id'] ?>" method="post" class="form-horizontal">
<div class="form-group">
<label for=inputVorname class="col-sm-2 control-label">Vorname</label>
<div class="col-sm-10">
<input class="form-control" id="inputVorname" name="vorname" type="text" value="<?php echo htmlentities($user['vorname']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputNachname" class="col-sm-2 control-label">Nachname</label>
<div class="col-sm-10">
<input class="form-control" id="inputNachname" name="nachname" type="text" value="<?php echo htmlentities($user['nachname']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputAdresse" class="col-sm-2 control-label">Adresse</label>
<div class="col-sm-10">
<input class="form-control" id="inputAdresse" name="adresse" type="text" value="<?php echo htmlentities($user['adresse']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputPLZ" class="col-sm-2 control-label">PLZ</label>
<div class="col-sm-10">
<input class="form-control" id="inputPLZ" name="plz" type="text" value="<?php echo htmlentities($user['plz']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputOrt" class="col-sm-2 control-label">Ort</label>
<div class="col-sm-10">
<input class="form-control" id="inputOrt" name="ort" type="text" value="<?php echo htmlentities($user['ort']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputGeburtstag" class="col-sm-2 control-label">Geburtsdatum</label>
<div class="col-sm-10">
<input class="form-control" id="inputGeburtstag" name="geburtstag" type="text" value="<?php echo htmlentities($user['geburtstag']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">E-Mail</label>
<div class="col-sm-10">
<input class="form-control" id="inputEmail" name="email" type="email" value="<?php echo htmlentities($user['email']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputHandy" class="col-sm-2 control-label">Handy</label>
<div class="col-sm-10">
<input class="form-control" id="inputHandy" name="handy" type="text" value="<?php echo htmlentities($user['handy']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputLiga" class="col-sm-2 control-label">Liga</label>
<div class="col-sm-10">
<input class="form-control" id="inputLiga" name="liga" type="text" value="<?php echo htmlentities($user['liga']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputVerein" class="col-sm-2 control-label">Verein</label>
<div class="col-sm-10">
<input class="form-control" id="inputVerein" name="verein" type="text" value="<?php echo htmlentities($user['verein']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputBank" class="col-sm-2 control-label">Bankname</label>
<div class="col-sm-10">
<input class="form-control" id="inputBank" name="bank" type="text" value="<?php echo htmlentities($user['bank']); ?>" readonly>
</div>
</div>
<div class="form-group">
<label for="inputIban" class="col-sm-2 control-label">IBAN</label>
<div class="col-sm-10">
<input class="form-control" id="inputIban" name="iban" type="text" value="<?php echo htmlentities($user['iban']); ?>" readonly>
</div>
</div>
</form>
</div>
<!-- Persönliche Daten-->
<div role="tabpanel" class="tab-pane" id="data">
<br>
<form action="?save=personal_data&id=<?php echo $_GET['id'] ?>" method="post" class="form-horizontal">
<div class="form-group">
<label for="inputVorname" class="col-sm-2 control-label">Vorname</label>
<div class="col-sm-10">
<input class="form-control" id="inputVorname" name="vorname" type="text" value="<?php echo htmlentities($user['vorname']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputNachname" class="col-sm-2 control-label">Nachname</label>
<div class="col-sm-10">
<input class="form-control" id="inputNachname" name="nachname" type="text" value="<?php echo htmlentities($user['nachname']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputAdresse" class="col-sm-2 control-label">Adresse</label>
<div class="col-sm-10">
<input class="form-control" id="inputAdresse" name="adresse" type="text" value="<?php echo htmlentities($user['adresse']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputPLZ" class="col-sm-2 control-label">PLZ</label>
<div class="col-sm-10">
<input class="form-control" id="inputPLZ" name="plz" type="text" value="<?php echo htmlentities($user['plz']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputOrt" class="col-sm-2 control-label">Ort</label>
<div class="col-sm-10">
<input class="form-control" id="inputOrt" name="ort" type="text" value="<?php echo htmlentities($user['ort']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputGeburtstag" class="col-sm-2 control-label">Geburtsdatum</label>
<div class="col-sm-10">
<input class="form-control" id="inputGeburtstag" name="geburtstag" type="text" value="<?php echo htmlentities($user['geburtstag']); ?>" placeholder="01.01.2000">
</div>
</div>
<div class="form-group">
<label for="inputHandy" class="col-sm-2 control-label">Handy</label>
<div class="col-sm-10">
<input class="form-control" id="inputHandy" name="handy" type="text" value="<?php echo htmlentities($user['handy']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputLiga" class="col-sm-2 control-label">Liga</label>
<div class="col-sm-10">
<input class="form-control" id="inputLiga" name="liga" type="text" value="<?php echo htmlentities($user['liga']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputVerein" class="col-sm-2 control-label">Verein</label>
<div class="col-sm-10">
<input class="form-control" id="inputVerein" name="verein" type="text" value="<?php echo htmlentities($user['verein']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputBank" class="col-sm-2 control-label">Bankname</label>
<div class="col-sm-10">
<input class="form-control" id="inputBank" name="bank" type="text" value="<?php echo htmlentities($user['bank']); ?>" placeholder="Postfinance">
</div>
</div>
<div class="form-group">
<label for="inputIban" class="col-sm-2 control-label">IBAN</label>
<div class="col-sm-10">
<input class="form-control" id="inputIban" name="iban" type="text" value="<?php echo htmlentities($user['iban']); ?>" placeholder="CHxx xxxx xxxx xxxx xxxx x">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a class="btn btn-danger" href='internal.php'>Abbrechen</a>
</div>
</div>
</form>
</div>
<!-- Änderung der E-Mail-Adresse -->
<div role="tabpanel" class="tab-pane" id="email">
<br>
<p>Zum Änderen deiner E-Mail-Adresse gib bitte dein aktuelles Passwort sowie die neue E-Mail-Adresse ein.</p>
<form action="?save=email&id=<?php echo $_GET['id'] ?>" method="post" class="form-horizontal">
<div class="form-group">
<label for="inputPasswort" class="col-sm-2 control-label">Passwort</label>
<div class="col-sm-10">
<input class="form-control" id="inputPasswort" name="passwort" type="password" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">E-Mail</label>
<div class="col-sm-10">
<input class="form-control" id="inputEmail" name="email" type="email" value="<?php echo htmlentities($user['email']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail2" class="col-sm-2 control-label">E-Mail (wiederholen)</label>
<div class="col-sm-10">
<input class="form-control" id="inputEmail2" name="email2" type="email" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a class="btn btn-danger" href='spielliste.php'>Abbrechen</a>
</div>
</div>
</form>
</div>
<!-- Änderung des Passworts -->
<div role="tabpanel" class="tab-pane" id="passwort">
<br>
<p>Zum Änderen deines Passworts gib bitte dein aktuelles Passwort sowie das neue Passwort ein.</p>
<form action="?save=passwort&id=<?php echo $_GET['id'] ?>" method="post" class="form-horizontal">
<div class="form-group">
<label for="inputPasswort" class="col-sm-2 control-label">Altes Passwort</label>
<div class="col-sm-10">
<input class="form-control" id="inputPasswort" name="passwortAlt" type="password" required>
</div>
</div>
<div class="form-group">
<label for="inputPasswortNeu" class="col-sm-2 control-label">Neues Passwort</label>
<div class="col-sm-10">
<input class="form-control" id="inputPasswortNeu" name="passwortNeu" type="password" required>
</div>
</div>
<div class="form-group">
<label for="inputPasswortNeu2" class="col-sm-2 control-label">Neues Passwort (wiederholen)</label>
<div class="col-sm-10">
<input class="form-control" id="inputPasswortNeu2" name="passwortNeu2" type="password" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a class="btn btn-danger" href='spielliste.php'>Abbrechen</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
include("templates/footer.inc.php")
?>
UPDATE: new code editsr.php. Works fine with the tabs, only the changes displayed after refresh the site.
Look at your code carefully
on the top you are using the $user variable like below
$id = $_GET['id'];
$statement = $pdo->prepare("SELECT * FROM users WHERE id = :id");
$result = $statement->execute(array('id' => ['id']));
$user = $statement->fetch(); // here
and again on the bottom of php code you are using $user variable like below
$id = $_GET['id'];
$user = "SELECT * FROM users WHERE id = :id"; // here
?>
on the input you are trying to get like htmlentities($user['vorname']);
<div class="form-group">
<label for=inputVorname class="col-sm-2 control-label">Vorname</label>
<div class="col-sm-10">
<input class="form-control" id="inputVorname" name="vorname" type="text" value="<?php echo htmlentities($user['vorname']); ?>" readonly>
</div>
</div>
that's the problem of error in every input :)
New Code with only one form:
<?php
session_start();
require_once("inc/config.inc.php");
require_once("inc/functions.inc.php");
$id = $_GET['id'];
$statement = $pdo->prepare("SELECT * FROM users WHERE id = $id");
$result = $statement->execute(array('id' => ['id']));
$user = $statement->fetch();
include("templates/header.inc.php");
if(isset($_GET['save'])) {
$save = $_GET['save'];
if($save == 'personal_data') {
$vorname = trim($_POST['vorname']);
$nachname = trim($_POST['nachname']);
$adresse = trim($_POST['adresse']);
$plz = trim($_POST['plz']);
$ort = trim($_POST['ort']);
$geburtstag = trim($_POST['geburtstag']);
$handy = trim($_POST['handy']);
$email = trim($_POST['email']);
$liga = trim($_POST['liga']);
$verein = trim($_POST['verein']);
$bank = trim($_POST['bank']);
$iban = trim($_POST['iban']);
$passwortNeu = trim($_POST['passwortNeu']);
if($vorname == "" || $nachname == "" || $adresse == "" || $plz == "" || $ort == "" || $handy == "" || $liga == "" || $verein == "" || $email == "" || $passwortNeu == "" ){
$error_msg = "Bitte alle Angaben ausfüllen.";
} else {
$passwort_hash = password_hash($passwortNeu, PASSWORD_DEFAULT);
$statement = $pdo->prepare("UPDATE users SET vorname = :vorname, nachname = :nachname, adresse = :adresse, plz = :plz, ort = :ort, geburtstag = :geburtstag, handy = :handy, liga = :liga, verein = :verein, bank = :bank, iban = :iban, passwort = :passwort, email = :email, updated_at=NOW() WHERE id = $id");
$result = $statement->execute(array('vorname' => $vorname, 'nachname'=> $nachname,'adresse' => $adresse, 'plz' => $plz, 'ort' => $ort, 'geburtstag' => $geburtstag, 'handy' => $handy, 'liga' => $liga, 'verein' => $verein,'bank' => $bank, 'iban' => $iban, 'passwort' => $passwort_hash, 'email' => $email));
$success_msg = "Daten erfolgreich gespeichert.";
}
}
}
?>
<div class="container main-container">
<h1>Schiedsrichter Profil bearbeiten</h1>
<?php
if(isset($success_msg) && !empty($success_msg)):
?>
<div class="alert alert-success">
×
<?php echo $success_msg; ?>
</div>
<?php
endif;
?>
<?php
if(isset($error_msg) && !empty($error_msg)):
?>
<div class="alert alert-danger">
×
<?php echo $error_msg; ?>
</div>
<?php
endif;
?>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">Persönliche Daten</li>
</ul>
<!-- Persönliche Daten-->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="data">
<br>
<form action="?save=personal_data" method="post" class="form-horizontal">
<div class="form-group">
<label for="inputVorname" class="col-sm-2 control-label">Vorname</label>
<div class="col-sm-10">
<input class="form-control" id="inputVorname" name="vorname" type="text" value="<?php echo htmlentities($user['vorname']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputNachname" class="col-sm-2 control-label">Nachname</label>
<div class="col-sm-10">
<input class="form-control" id="inputNachname" name="nachname" type="text" value="<?php echo htmlentities($user['nachname']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputAdresse" class="col-sm-2 control-label">Adresse</label>
<div class="col-sm-10">
<input class="form-control" id="inputAdresse" name="adresse" type="text" value="<?php echo htmlentities($user['adresse']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputPLZ" class="col-sm-2 control-label">PLZ</label>
<div class="col-sm-10">
<input class="form-control" id="inputPLZ" name="plz" type="text" value="<?php echo htmlentities($user['plz']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputOrt" class="col-sm-2 control-label">Ort</label>
<div class="col-sm-10">
<input class="form-control" id="inputOrt" name="ort" type="text" value="<?php echo htmlentities($user['ort']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputGeburtstag" class="col-sm-2 control-label">Geburtsdatum</label>
<div class="col-sm-10">
<input class="form-control" id="inputGeburtstag" name="geburtstag" type="text" value="<?php echo htmlentities($user['geburtstag']); ?>" placeholder="01.01.2000">
</div>
</div>
<div class="form-group">
<label for="inputHandy" class="col-sm-2 control-label">Handy</label>
<div class="col-sm-10">
<input class="form-control" id="inputHandy" name="handy" type="text" value="<?php echo htmlentities($user['handy']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputEmail" class="col-sm-2 control-label">E-Mail</label>
<div class="col-sm-10">
<input class="form-control" id="inputEmail" name="email" type="email" value="<?php echo htmlentities($user['email']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputLiga" class="col-sm-2 control-label">Liga</label>
<div class="col-sm-10">
<input class="form-control" id="inputLiga" name="liga" type="text" value="<?php echo htmlentities($user['liga']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputVerein" class="col-sm-2 control-label">Verein</label>
<div class="col-sm-10">
<input class="form-control" id="inputVerein" name="verein" type="text" value="<?php echo htmlentities($user['verein']); ?>" required>
</div>
</div>
<div class="form-group">
<label for="inputBank" class="col-sm-2 control-label">Bankname</label>
<div class="col-sm-10">
<input class="form-control" id="inputBank" name="bank" type="text" value="<?php echo htmlentities($user['bank']); ?>" placeholder="Postfinance">
</div>
</div>
<div class="form-group">
<label for="inputIban" class="col-sm-2 control-label">IBAN</label>
<div class="col-sm-10">
<input class="form-control" id="inputIban" name="iban" type="text" value="<?php echo htmlentities($user['iban']); ?>" placeholder="CHxx xxxx xxxx xxxx xxxx x">
</div>
</div>
<div class="form-group">
<label for="inputPasswortNeu" class="col-sm-2 control-label">Neues Passwort</label>
<div class="col-sm-10">
<input class="form-control" id="inputPasswortNeu" name="passwortNeu" type="password" value="<?php echo htmlentities($user['passwort']); ?>" required>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="submit" class="btn btn-primary">Speichern</button>
<a class="btn btn-danger" href='internal.php'>Abbrechen</a>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<?php
include("templates/footer.inc.php")
?>
Related
I'm getting the following error message:
Warning: Missing argument 3 for DB::update(), called in C:\xampp\htdocs\my.sleeptrak.com\users\step-1-edit.php on line 51 and defined in C:\xampp\htdocs\my.sleeptrak.com\users\classes\DB.php on line 261
Here is my db.php:
public function update($table, $id, $fields){
$sql = "UPDATE {$table} SET " . (empty($fields) ? "" : "`") . implode("` = ? , `", array_keys($fields)) . (empty($fields) ? "" : "` = ? ");
$is_ok = true;
if (!is_array($id)) {
$sql .= "WHERE id = ?";
$fields[] = $id;
} else {
if (empty($id))
return false;
if ($where_text = $this->_calcWhere($id, $fields, "and", $is_ok))
$sql .= "WHERE $where_text";
}
if ($is_ok)
if (!$this->query($sql, $fields)->error())
return true;
return false;
}
And here is my edit.php
<form class="needs-validation" method="post">
<div class="offset-2 col-md-8 order-md-1">
<div class="card">
<div class="card-body">
<?php
if(isset($_POST['save'])) {
$fields = array(
"PatientFirstName" => $_POST['PatientFirstName'],
"PatientLastName" => $_POST['PatientLastName'],
"PatientStreet" => $_POST['PatientStreet'],
"PatientCity" => $_POST['PatientCity'],
"PatientProvince" => $_POST['PatientProvince'],
"PatientPostalCode" => $_POST['PatientPostalCode'],
"PatientCountry" => $_POST['PatientCountry'],
"PatientEmail" => $_POST['PatientEmail'],
"PatientPhone" => $_POST['PatientPhone'],
"PatientDOB" => $_POST['PatientDOB'],
"PatientBMI" => $_POST['PatientBMI'],
"PhysicianName" => $_POST['PhysicianName'],
"PhysicianEmail" => $_POST['PhysicianEmail']
);
$db->update("patients", $fields);
//print_r($db->errorInfo());
echo '<div class="alert alert-success mb-4" role="alert">The patient has been successfully updated!</div>';
} else {
?>
<h4 class="mb-3">Edit Patient <?php echo $PatientFirstName . ' ' . $PatientLastName; ?></h4>
<div class="row">
<div class="col-md-6 mb-3">
<label for="PatientFirstName">Patient first name</label>
<input type="text" class="form-control" name="PatientFirstName" value="<?php echo $PatientFirstName; ?>">
<div class="invalid-feedback">Valid first name is required.</div>
</div>
<div class="col-md-6 mb-3">
<label for="PatientLastName">Patient last name</label>
<input type="text" class="form-control" name="PatientLastName" value="<?php echo $PatientLastName; ?>">
<div class="invalid-feedback">Valid last name is required.</div>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<label for="PatientDOB">Patient DOB</label>
<input type="date" class="form-control" name="PatientDOB" value="<?php echo $PatientDOB; ?>">
</div>
<div class="col-md-4 mb-3">
<label for="email">Email</label>
<input type="text" class="form-control" name="PatientEmail" value="<?php echo $PatientFirstName; ?>">
</div>
<div class="col-md-4 mb-3">
<label for="PatientPhone">Phone</label>
<input type="text" class="form-control" name="PatientPhone" value="<?php echo $PatientPhone; ?>">
<div class="invalid-feedback">Valid last name is required.</div>
</div>
</div>
</div><!--card-body-->
</div><!--card-->
<div class="card mt-3">
<div class="card-body">
<h4>Patient Address</h4>
<div class="row">
<div class="col-md-8 mb-3">
<label for="PatientStreet">Street</label>
<input type="text" class="form-control" name="PatientStreet" value="<?php echo $PatientStreet; ?>">
<div class="invalid-feedback">Valid address is required.</div>
</div>
<div class="col-md-4 mb-3">
<label for="PatientCity">City</label>
<input type="text" class="form-control" name="PatientCity" value="<?php echo $PatientCity; ?>">
<div class="invalid-feedback">
City is required.
</div>
</div>
</div>
<div class="row">
<div class="col-md-4 mb-3">
<label for="state">Province / State</label>
<input type="text" class="form-control" name="PatientProvince" value="<?php echo $PatientProvince; ?>">
<div class="invalid-feedback">
Please provide a valid province/state.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="PatientPostalCode">Postal Code / Zip</label>
<input type="text" class="form-control" name="PatientPostalCode" value="<?php echo $PatientPostalCode; ?>">
<div class="invalid-feedback">
Postal Code / Zip Code is required.
</div>
</div>
<div class="col-md-5 mb-3">
<label for="PatientCountry">Country</label>
<input type="text" class="form-control" name="PatientCountry" value="<?php echo $PatientCountry; ?>">
<div class="invalid-feedback">
Please select a valid country.
</div>
</div>
</div>
</div><!--card-body-->
</div><!--card-->
<div class="card mt-3">
<div class="card-body">
<h4>Body Mass Index</h4>
<div class="row">
<div class="col-md-6 mb-3">
<label for="PatientBMI">Patient BMI</label>
<input type="text" class="form-control" name="PatientBMI" value="<?php echo $PatientBMI; ?>">
</div>
</div>
</div><!--card-body-->
</div><!--card-->
<div class="card mt-3">
<div class="card-body">
<div class="row">
<div class="col-md-6 mb-3">
<label for="PhysicianName">Physician Name</label>
<input type="text" class="form-control" name="PhysicianName" value="<?php echo $PhysicianName; ?>">
<div class="invalid-feedback">Valid last name is required.</div>
</div>
<div class="col-md-6 mb-3">
<label for="PhysicianEmail">Physician Email</label>
<input type="text" class="form-control" name="PhysicianEmail" value="<?php echo $PhysicianEmail; ?>">
</div>
</div>
</div><!--card-body-->
</div><!--card-->
<button class="btn btn-primary btn-lg btn-block mt-4" name="save" type="submit">Update</button>
</div>
</form>
I research all same errors on this form but i can't fix it. I tried to replace this: php public function update($table, $id, $field) with this public function update($table, $id, $fields=null) but is not working for me. How ever, the error is gone when i put null in function but still don't save in db my changes.
you have to write all arguments for update method
$db->update("patients", $id, $fields);
you missed $id.
I succesfully managed to add to my url an parameter but I can't increment it. For example, if I click on the submit button the url should transform from http://localhost/code/1 to http://localhost/code/2 . I have made an input hidden to access the url but I can't redirect it to the desired value, how can I do this? This is my PHP code:
<?php
$cod=strtoupper($_GET['params']);
$i=$_GET['params1'];
$id_rezervare="SELECT id FROM trezervare WHERE numar_rezervare = '$cod'";
$id_rezervare = $db->DbGetOne($id_rezervare);
$cod_rezervare="SELECT UPPER(numar_rezervare) FROM trezervare WHERE numar_rezervare = '$cod'";
$cod_rezervare = $db->DbGetOne($cod_rezervare);
$cod_rezervare1 = strtoupper($cod_rezervare);
$nr_camere="SELECT count(*) FROM trezervarecont WHERE idrezervare= $id_rezervare ";
$nr_camere = $db->DbGetOne($nr_camere);
$checkin_status=TRUE;
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$data_nasterii= $_GET['datanasterii'];
$test_arr = explode('/', $data_nasterii);
if(isset($_POST['trimite'])){
if (count($test_arr) == 3) {
if (checkdate($test_arr[0], $test_arr[1], $test_arr[2])) {
} else {
$message = "Date has an invalid format";
echo "<script type='text/javascript'>alert('$message');</script>";
}
} else {
$message = "No date selected";
echo "<script type='text/javascript'>alert('$message');</script>";
}
}
if(isset($_POST['trimite'])){
$i++;
}
?>
<div class="animated fadeOutZoom">
<div class="container container-sm animated fadeInDown">
<div class="center-block mt-xl">
<div class="panel">
<div class="panel-body">
<p class="pv text-bold">Check-in for room number <?php echo $i; ?></p>
<form action="" method="post">
<div class="row">
<div class="col-md-12 form-group">
<label for="nume">Nume</label>
<input type="text" id="text " class="form-control " name="nume" >
</div>
<input type="hidden" id="custId" name="checkin_status" value="<?php echo 1;?>">
<input type="text" id="custId" name="checkin_status" value="<?php echo $actual_link;?>">
<div class="col-md-12 form-group">
<label for="nume">Data Nasterii</label>
<input type="text" class="form-control" id="arrival_date" name="datanasterii"required/>
</div>
<div class="col-md-12 form-group">
<label for="nume">Locul nasterii</label>
<input type="text" id="text "class="form-control " name="loculnasterii" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Cetatenia</label>
<input type="text" id="text "class="form-control " name="cetatenie" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Localitate</label>
<input type="text" id="text "class="form-control " name="localitate" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Strada</label>
<input type="text" id="text "class="form-control " name="strada" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Numar strada</label>
<input type="text" id="text "class="form-control " name="nrstrada" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Tara</label>
<input type="text" id="text "class="form-control " name="tara" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Tip act</label>
<input type="text" id="text "class="form-control " name="tipact" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Serie act</label>
<input type="text" id="text "class="form-control " name="serieact" required>
</div>
<div class="col-md-12 form-group">
<label for="nume">Numar act</label>
<input type="text" id="text "class="form-control " name="nract" required>
</div>
</div>
<div class="row">
<div class="col-md-12 form-group">
<label for="telefon">Telefon</label>
<input type="phone" id="telefon " class="form-control " name="telefon" required>
</div>
</div>
<div class="row">
<div class="col-md-12 form-group">
<label for="email">Email</label>
<input type="email" id="email" class="form-control" name="email" required >
</div>
</div>
<div class="row">
<div class="col-md-6 form-group">
<?php if($i==$nr_camere) echo'
<input type="submit" value="Finalizeaza rezervarea" class="btn btn-primary" name="trimite">';
elseif ($i>$nr_camere) {
header("location:../finalizeaza.php");
}
else echo ' <input type="submit" value="Continua rezervarea" class="btn btn-primary" name="trimite">';
?>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.8.0/js/bootstrap-datepicker.min.js"></script>
<script>
//$('#arrival_date, #departure_date').datepicker({format: 'yyyy/mm/dd'});
$('#arrival_date, #departure_date').datepicker({
format: 'yyyy-mm-dd',
endDate: '+0d',
minDate: '-120Y',
autoclose: true
});
</script>
If there are any errors while registration or login into the sit then it is not displaying the error message just printing the variable.Here is the code.Tried by doing echo as well but it is also not working.Tried with storing the result in a variable and displaying the message but still not worked.
<?php
include 'includes/db.php';
$match = '';
if(isset($_POST['submit_user']))
{
$email = $_POST['email'];
$check=mysqli_query($conn,"select * from users where user_email='$email'");
$checkrows=mysqli_num_rows($check);
if($checkrows>0)
{
$msg = "Email Already Exists";
header('Location:registration.php?msg=$msg');
}
else
{
if($_POST['password'] == $_POST['con_password'])
{
$ins_sql = "INSERT INTO users (first_name, last_name, user_email, user_password, username) VALUES ('$_POST[first_name]', '$_POST[last_name]', '$_POST[email]', '$_POST[password]', '$_POST[username]')";
$run_sql = mysqli_query($conn,$ins_sql);
}
else
{
$match = '<div class="alert alert-danger">Password doesn't match!</div>';
}
}
}
?>
<form class="form-horizontal" action="registration.php" method="post" role="form">
<div class="body">
<div class="row clearfix">
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="First Name" name="first_name" id="first_name" onkeypress="return checkSpcialChar(event)" required>
</div>
</div>
</div>
<div class="col-sm-6 col-xs-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="Last Name" name="last_name" id="last_name" required>
</div>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="Enter Your Email" name="email" id="email" required>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="password" class="form-control" placeholder="Password" name="password" id="password" required>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="type" class="form-control" placeholder="Confirm Password" name="con_password" id="con_password" required>
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="form-line">
<input type="text" class="form-control" placeholder="Enter Username" name="username" id="username">
</div>
</div>
</div>
<div class="col-sm-12">
<div class="form-group drop-custum">
<select class="form-control show-tick" name="user_role" id="user_role" required>
<option value="">-- Select User role --</option>
<option value="admin">Admin</option>
<option value="employee">Employee</option>
</select>
</div>
</div>
<div class="col-sm-12">
<button type="submit" class="btn btn-raised g-bg-cyan" name="submit_user" id="subject">Submit</button>
<button type="submit" class="btn btn-raised">Cancel</button>
</div>
<span>
<?php if(isset($_GET['msg']))
echo $_GET['msg'];
?>
</span>
</div>
</div>
</form>
When i am try to update details using for loop it is updated as a empty(Null) to refer columns.
Below is my code please help me what wrong with my logic.
View Code
The No. of text fields are going to generate depends on no. of values present in table. It is executing in foreach loop
<form method="post" action="<?php echo site_url('Home/advisor_update'); ?>"
<?php
if ($advisor_emp->num_rows()>0 )
{
$i=1;
foreach($advisor_emp->result() as $data)
{
$eid = $data->id;
$cn = $data->company_name;
$fd = $data->from_date;
$td = $data->to_date;
$tb = $data->type_of_buisness;
$c1 = $data->company_addres_lane_1;
$c2 = $data->company_addres_lane_2;
$cc = $data->c_city;
$cp = $data->c_pincode;
$cs = $data->c_state;
$cun = $data->c_country; ?>
<div class="col-md-6">
<div class="form-group">
<input type="" name="eid[]" class="form-control" value="<?php echo $eid; ?>">
</div>
<div class="col-md-12">
<div class="form-group">
<label>Previous Employer</label>
<input type="text" class="form-control" name="pcmp" value="<?php echo $cn; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>From</label>
<input type="text" name="pcmpfrom" class="form-control" value="<?php echo $fd ; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>To</label>
<input type="text" name="pcmpto" class="form-control" value="<?php echo $td ; ?>">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Designation</label>
<input type="text" name="pcmpdesi" class="form-control" value="<?php echo $tb;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 1</label>
<input type="text" name="pcmpadr1[]" class="form-control" value="<?php echo $c1;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 2</label>
<input type="text" name="pcmpadr2" class="form-control" value="<?php echo $c2;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" name="pcmpcit" class="form-control" value="<?php echo $cc;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Pin Code</label>
<input type="text" name="pcmppin[]" class="form-control" value="<?php echo $cp;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>State</label>
<input type="text" name="pcmpstat[]" class="form-control" value="<?php echo $cs; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Country</label>
<input type="text" name="pcmpcun[]" class="form-control" value="<?php echo $cun; ?>">
</div>
</div>
</div>
<?php
$i++;
}
}
?>
<div class="col-md-12"
<input type="submit" class="btn btn-primary" name="advisor_update" value="Update" >
</div>
</form>
Here is my Controller
In controller i'm goin to getting data from the view using for loop and sending recieved data to modal.
if ($this->input->post('advisor_update'))
{
$emp_his_id = $this->input->post('eid');
$count_eid = count($emp_his_id);
for($i=0;$i<$count_eid;$i++)
{
$emp_his_pk = $emp_his_id[$i];
$inserte['company_name']= $this->input->post('cn');
$inserte['from_date']= $this->input->post('fd');
$inserte['to_date']= $this->input->post('td');
$inserte['type_of_buisness']= $this->input->post('tb');
$inserte['company_addres_lane_1']= $this->input->post('c1');
$inserte['company_addres_lane_2']= $this->input->post('c2');
$inserte['c_city']= $this->input->post('cc');
$inserte['c_pincode']= $this->input->post('cp');
$inserte['updated_on'] = date("Y-m-d");
$up_emp_history=$this->Frontend_model->update_employe($inserte=array(),$emp_his_pk);
}
}
Here is my Modal
function update_employe($inserte=array(),$emp_his_pk)
{
$this->db->where('id',$emp_his_pk);
$result=$this->db->update("is_employment", $inserte);
return $result;
}
View Code
I have change your view codes input name
<form method="post" action="<?php echo site_url('Home/advisor_update'); ?>" >
<?php
if ($advisor_emp->num_rows()>0 )
{
foreach($advisor_emp->result() as $data)
{
$eid = $data->id;
$cn = $data->company_name;
$fd = $data->from_date;
$td = $data->to_date;
$tb = $data->type_of_buisness;
$c1 = $data->company_addres_lane_1;
$c2 = $data->company_addres_lane_2;
$cc = $data->c_city;
$cp = $data->c_pincode;
$cs = $data->c_state;
$cun = $data->c_country; ?>
<div class="col-md-6">
<div class="form-group">
<input type="" name="eid[]" class="form-control" value="<?php echo $eid; ?>">
</div>
<div class="col-md-12">
<div class="form-group">
<label>Previous Employer</label>
<input type="text" class="form-control" name="cn[]" value="<?php echo $cn; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>From</label>
<input type="text" name="fd[]" class="form-control" value="<?php echo $fd ; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>To</label>
<input type="text" name="td[]" class="form-control" value="<?php echo $td ; ?>">
</div>
</div>
<div class="col-md-12">
<div class="form-group">
<label>Designation</label>
<input type="text" name="tb[]" class="form-control" value="<?php echo $tb;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 1</label>
<input type="text" name="c1[]" class="form-control" value="<?php echo $c1;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Company Address Line 2</label>
<input type="text" name="c2[]" class="form-control" value="<?php echo $c2;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>City</label>
<input type="text" name="cc[]" class="form-control" value="<?php echo $cc;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Pin Code</label>
<input type="text" name="cp[]" class="form-control" value="<?php echo $cp;?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>State</label>
<input type="text" name="cs[]" class="form-control" value="<?php echo $cs; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Country</label>
<input type="text" name="cun[]" class="form-control" value="<?php echo $cun; ?>">
</div>
</div>
</div>
<?php
}
}
?>
Controller Code
You have to run a foreach loop in controller.
if ($this->input->post('advisor_update'))
{
$emp_his_id = $this->input->post('eid');
$cn = $this->input->post('cn');
$fd = $this->input->post('fd');
$td = $this->input->post('td');
$td = $this->input->post('tb');
$c1 = $this->input->post('c1');
$c2 = $this->input->post('c2');
$cc = $this->input->post('cc');
$cp = $this->input->post('cp');
foreach($emp_his_id as $key => $eid)
{
$emp_his_pk = $eid;
$inserte = array();
$inserte['company_name']= $cn[$key];
$inserte['from_date']= $fd[$key];
$inserte['to_date']= $td[$key];
$inserte['type_of_buisness']= $tb[$key];
$inserte['company_addres_lane_1']= $c1[$key];
$inserte['company_addres_lane_2']= $c2[$key];
$inserte['c_city']= $cc[$key];
$inserte['c_pincode']= $cp[$key];
$inserte['updated_on'] = date("Y-m-d");
$up_emp_history=$this->Frontend_model->update_employe($inserte=array(),$emp_his_pk);
}
}
Hope This works for you
I'm trying to allow user to update a database of products through form but upon submit nothing happens... No errors are even fired. I have been trying to work this out for hours and maybe my eyes are getting too tire because I can't see what's wrong...
form.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', '1');
require_once $_SERVER['DOCUMENT_ROOT'].'/ecommerce/core/init.php';
include 'includes/header.php';
if(isset($_GET['add'])){
$parentQuery = $db->query("SELECT * FROM categories WHERE parent= 0" );
if (isset($_POST['submit'])) {
if(isset($_POST['prod_name']))
{
$prod_name = sanitize($_POST)['prod_name'];
}
if(isset($_POST['child']))
{
$categories = sanitize($_POST)['child'];
}
if(isset($_POST['price']))
{
$price = sanitize($_POST)['price'];
}
if(isset($_POST['list_price']))
{
$prod_name = sanitize($_POST)['list_price'];
}
if(isset($_POST['prod_width']))
{
$prod_width = sanitize($_POST)['prod_width'];
}
if(isset($_POST['prod_depth']))
{
$prod_depth = sanitize($_POST)['prod_depth'];
}
if(isset($_POST['prod_height']))
{
$prod_height = sanitize($_POST)['prod_height'];
}
if(isset($_POST['prod_material']))
{
$prod_material = sanitize($_POST)['prod_material'];
}
if(isset($_POST['quantity']))
{
$quantity = sanitize($_POST)['quantity'];
}
if(isset($_POST['care_instructions']))
{
$care_instructions = sanitize($_POST)['care_instructions'];
}
if(isset($_POST['image_1']))
{
$image_1 = $_FILES['image_1'];
}
if(isset($_POST['image_2']))
{
$image_2 = $_FILES['image_2'];
}
if(isset($_POST['image_3']))
{
$image_3 = $_FILES['image_3'];
}
if(isset($_POST['image_4']))
{
$image_4 = $_FILES['image_4'];
}
if(isset($_POST['description']))
{
$description = sanitize($_POST)['description'];
} else {
$errors = array();
$required = array('prod_name','child','price','prod_width', 'prod_depth','prod_height', 'prod_material', 'quantity', 'description', 'care_instructions', 'image_1', 'image_2', 'image_3', 'image_4');
foreach ($required as $field) {
if ($_POST[$field] == '') {
$errors[] = 'All Fields With and Astrisk are required';
break; } else {
//upload file and insert into database
//move_uploaded_file($tmpLoc, $uploadPath);
$insertSql = "INSERT INTO `product` (`prod_name`,`child`,`price`,`list_price`,`prod_width`,`prod_depth`,`prod_height`, `prod_material`, `quantity`, `description`, `care_instructions`, `image_1`, `image_2`, `image_3`, `image_4`); VALUES ('$prod_name','$child','$price','$list_price','$prod_width', '$prod_depth','$prod_height', '$prod_material', '$quantity', '$description', '$care_instructions', '$image_1', '$image_2', '$image_3', '$image_4');";
$db->query($insertSql) or die(mysqli_error($db));
header('Location: products.php');}}}}?>
<form action="products.php?add=1" method="POST" enctype="multipart/form-data">
<div class='container_12'>
<div class="form-group col-md-3">
<label for="prod_name">Product Name*:</label>
<input type="text" name="prod_name" id="prod_name" class="form-control" value="<?=((isset($_POST['prod_name']))?sanitize($_POST['prod_name']):' ');?>">
</div>
<div class="form-group col-md-3">
<label for="parent">Parent Category*:</label>
<select class="form-control" id="parent" name="parent">
<option value=""<?=((isset($_POST['parent']) && $_POST['parent'] == '')?'selected':'');?>></option>
<?php while($parent = mysqli_fetch_assoc($parentQuery)): ?>
<option value=" <?=$parent['id'];?>"<?=((isset($_POST['parent']) && $_POST['parent'] == $parent['id'])?' select':'');?>><?=$parent['category_name'];?></option>
<?php endwhile; ?>
</select>
</div>
<div class='form-group col-md-3'>
<label for='child'>Second Category*:</label>
<select id='child' name='child' class='form-control'></select>
</div>
</div>
<div class='container_12'>
<div class='form-group col-md-3'>
<label for='list_price'>List Price(OPTIONAL): </label>
<input type="text" id="list_price" name="list_price" class="form-control" value="<?=((isset($_POST['list_price']))?sanitize($_POST['list_price']):'');?>">
</div>
<div class="form-group col-md-3">
<label for="price">Price*:</label>
<input type="text" id="price" name="price" class="form-control" value="<?=((isset($_POST['price']))?sanitize($_POST['price']):'');?>">
</div>
<div class='form-group col-md-3'>
<label for='prod_width'>Width* (in inches):</label>
<input type="text" id="prod_width" name="prod_width" class="form-control" value="<?=((isset($_POST['prod_width']))?sanitize($_POST['prod_width']):'');?>">
</div>
<div class='form-group col-md-3'>
<label for='prod_depth'>Height*(in inches):</label>
<input type="text" id="'prod_depth" name="'prod_depth" class="form-control" value="<?=((isset($_POST['prod_depth']))?sanitize($_POST['prod_depth']):'');?>">
</div>
</div>
<div class='container_12'>
<div class='form-group col-md-3'>
<label for='prod_height'>Depth*(in inches):</label>
<input type="text" id="prod_height" name="prod_height" class="form-control" value="<?=((isset($_POST['prod_height']))?sanitize($_POST['prod_height']):'');?>">
</div>
<div class='form-group col-md-3'>
<label for='prod_material'>Construction Material:</label>
<input type="text" id="prod_material" name="prod_material" class="form-control" value="<?=((isset($_POST['prod_material']))?sanitize($_POST['prod_material']):'');?>">
</div>
<div class='form-group col-md-6'>
<label>Quantity * :</label>
<input type="text" id="quantity" name="quantity" class="form-control" value="<?=((isset($_POST['quantity']))?sanitize($_POST['quantity']):'');?>">
</div>
</div>
<div class='container_12'>
<div class="form-group col-md-3"> <label for="image_1">Product Photo #1:</label>
<input type="file" name="image_1" id="image_1" class="form-control">
</div>
<div class="form-group col-md-3"> <label for="image_2">Product Photo #2:</label>
<input type="file" name="image_2" id="image_2" class="form-control">
</div>
<div class="form-group col-md-3"> <label for="image_3">Product Photo #3:</label>
<input type="file" name="image_3" id="image_3" class="form-control">
</div>
<div class="form-group col-md-3"> <label for="image_4">Product Photo#4:</label>
<input type="file" name="image_4" id="image_4" class="form-control">
</div>
</div>
<div class='container_12'>
<div class="form-group col-md-6">
<label for="description">Description:</label>
<textarea id="description" name="description" class="form-control" rows="6"><?=((isset($_POST['description']))?sanitize($_POST['description']):'');?></textarea>
</div>
<div class="form-group col-md-6">
<label for="care_instructions">Care Instructions*:</label>
<textarea id="care_instructions" name="care_instructions" class="form-control" rows="6"><?=((isset($_POST['care_instructions']))?sanitize($_POST['care_instructions']):'');?></textarea>
</div></div>
<div class='container_12'>
<div class="form-group pull-right">
<input type='submit' name='submit' value='Add Product' class='form-control btn-success pull-right'>
</div></div>
</form>