Jump to content

hazem

Members
  • Posts

    5
  • Joined

  • Last visited

hazem's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. 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,,,,,,,
  2. 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>
  3. 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
  4. 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();} }?> AddMedicine.php Medicine.repo.php
×
×
  • Create New...