hazem
-
Posts
5 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by hazem
-
-
-
Are you submitting to the right place? The PHP code you showed doesn't show the form again, it just prints a message. PHP variable names are case-sensitive though, $message is not the same as $Message. If it is refreshing the form then you probably aren't submitting to that PHP page.
Is There anything wrong in HTML tags?
<html> <body> <fieldset><legend>Add Medicune</legend> <form method="POST" action="" enctype="multipart/form-data"> Medicine name: <input type="text" name="Medicine_name"/><br /> Medicine Level: <input type="text" name="Medicine_level"/><br /> <input type="submit" name="btnsubmit" value="Add "/> <input type="reset" name="reset"/> </form> </fieldset> </body></html>
-
You're saying it doesn't update the database? What happens when you submit the form?
When I submit form ,information is sent but it doesn't insert into DB and doesn't show any message or error......just reload form without data
-
If I manage to Insert Infomation to medicine table .....the Information go without insert into DateBase Addmedicine.php
<?phpinclude_once("../Include/connectionstring.php");include_once("../Repositories/Medicine.repo.php");if(isset($_POST['btnsubmit'], $_POST['Id_Medicine'], $_POST['Medicine_name'], $_POST['Medicine_Level'])) { $Idmedicine=intval($_POST['Id_Medicine']); $MedicineName=strval($_POST['Medicine_name']); $MedicineLevel=intval($_POST['Medicine_Level']); $AddMedicine= new MedicineRepo(); $affectedRows=$AddMedicine->AddMedicine($MedicineName,$MedicineLevel); $isDone = $affectedRows == 1; if($isDone==TRUE) $message="Operation Succeeded!"; else $message="Operation Failed";}else$Message="ALL FIELD ARE REQUIRED";echo $Message;?>
Medicine.repo.php<?phpinclude_once("../include/connectionstring.php");class MedicineRepo{function GetMedicine(){ $dbh=DBClass::GetConnectionString(); $sql="select * from medicine"; $stmt=$dbh->prepare($sql); $stmt->setFetchMode(PDO::Fetchclass,'Medicine'); $stmt->execute(); return $stmt->fetchAll(); } function AddMedicine($MedicineName,$MedicineLevel) { $dbh=DBClass::GetConnectionString(); $sql="insert into medicine(Medicine_name,Medicine_Level)values(:MedicineName,:MedicineLevel)"; $stmt=$dbh->prepare($sql); $stmt->bindparm(':MedicineName',$MedicineName,PDO::PARAM_STR); $stmt->bindparm(':MedicineLevel',$MedicineLevel,PDO::PARAM_INT); $stmt->execute(); return $stmt->rowcount(); } function DeleteMedicine($IdMedicine){ $dbh=DBClass::GetConnectionString(); $sql="delete from Medicine where Id_Medicine=:IdMedicine"; $stmt=$dbh->prepare($sql); $stmt->bindparm(':IdMedicine',$IdMedicine,PDO::PARM_INT); $stmt->execute();} }?>
Problem In Insert Opreration
in PHP
Posted
Thank u very much for your reply ....
Id_medicine in DB is auto increment so I want to show Id without ability to insert to DB from User...Can you help me in this matter ?
I Will remove enctype from form tag but I don't know which page will be redirect in action property,,,,,,,