Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="<?php echo $_SERVER["PHP_SELF"]; ?>?action=adatfelvetel_form">Adatfelvétel (blog)</a><br />
- <?php
- if (isset($_GET["action"]) and $_GET["action"]=="adatfelvetel_form"){
- $form_blog_felvetel = new blogbejegyzesek();
- $form_blog_felvetel->felvetel_form();
- }
- if (isset($_GET["action"]) and $_GET["action"]=="cmd_update_form"){
- $form_blog_modositas = new blogbejegyzesek();
- $form_blog_modositas->cmd_update_form();
- }
- if (isset($_GET["action"]) and $_GET["action"]=="cmd_update_vegrehajt"){
- $blog_modositas = new blogbejegyzesek();
- $blog_modositas->cmd_update_vegrehajt_muvelet();
- }
- if (isset($_GET["action"]) and $_GET["action"]=="cmd_delete"){
- $torles = new blogbejegyzesek();
- $torles->adat_torles();
- }
- if (isset($_GET["action"]) and $_GET["action"]=="cmd_update_aktivalas"){
- $aktivalas = new blogbejegyzesek();
- $aktivalas->adat_aktivalas();
- }
- if (isset($_GET["action"]) and $_GET["action"]=="cmd_update_inaktivalas"){
- $inaktivalas = new blogbejegyzesek();
- $inaktivalas->adat_inaktivalas();
- }
- if (isset($_GET["action"]) and $_GET["action"]=="cmd_insert"){
- $felvetel = new blogbejegyzesek();
- $felvetel->adatok_felvetele();
- }
- $tartalom = new blogbejegyzesek();
- $tartalom->osszes_bejegyzes();
- class blogbejegyzesek{
- private $servername = "localhost";
- private $username = "root";
- private $password = "";
- private $dbname = "fakkkkkk";
- private $conn = "";
- private $result = "";
- private $row = "";
- private $sql = "";
- public function __construct(){
- $this->kapcsolat_nyitas();
- }
- public function __destruct(){
- $this->kapcsolat_bontas();
- }
- public function cmd_update_vegrehajt_muvelet(){
- $this->sql = "UPDATE
- bobik
- SET
- `nev` = '".$_GET['input_nev']."',
- `nem` = '".$_GET['input_nem']."',
- `foglalkozas` = '".$_GET['input_fogl']."'
- WHERE
- id = ".$_GET['input_modositando_id']."
- ";
- if ($this->conn->query($this->sql) === TRUE) {
- echo "Sikeres módosítás";
- } else {
- echo "Sikertelen módosítás";
- }
- }
- public function cmd_update_form(){
- $this->result = $this->conn->query("SELECT * FROM
- bobik
- WHERE
- id = ".$_GET['modositando_id']."
- ");
- if ($this->result->num_rows > 0) {
- while($this->row = $this->result->fetch_assoc()) {
- //$this->row["nev"]
- ?>
- <fieldset>
- <legend>Adatok módosítása</legend>
- <form method="GET" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
- Név:
- <input type="text" name="input_nev"
- value="<?php echo $this->row["nev"]; ?>"><br />
- Nem:
- <input type="text" name="input_nem"
- value="<?php echo $this->row["nem"]; ?>"><br />
- Foglalkozas:
- <input type="text" name="input_fogl"
- value="<?php echo $this->row["foglalkozas"]; ?>"><br />
- <input type="hidden" name="input_modositando_id"
- value="<?php echo $this->row["id"]; ?>">
- <input type="hidden" name="site" value="blog">
- <input type="hidden" name="action" value="cmd_update_vegrehajt">
- <input type="submit" value="Módosítás" />
- </form>
- </fieldset>
- <?php
- }
- } else {
- echo "Nincs felvett blogbejegyzés!";
- }
- }
- public function felvetel_form(){
- ?>
- <fieldset>
- <legend>Adatok felvétele</legend>
- <form method="GET" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
- Név:
- <input type="text" name="input_nev"><br />
- Nem:
- <input type="text" name="input_nem"><br />
- Foglalkozas:
- <input type="text" name="input_fogl"><br />
- <input type="hidden" name="site" value="blog">
- <input type="hidden" name="action" value="cmd_insert">
- <input type="submit" value="Felvétel" />
- </form>
- </fieldset>
- <?php
- }
- /* public function adat_aktivalas(){
- if (isset($_GET['aktivalando_id']) and
- !empty($_GET['aktivalando_id']) and
- is_numeric($_GET['aktivalando_id'])
- ){
- $this->sql = "UPDATE
- bobik
- SET
- aktivitas = 'aktiv'
- WHERE
- id = ".$_GET['aktivalando_id']."
- ";
- if ($this->conn->query($this->sql) === TRUE) {
- echo "Sikeres aktiválás!";
- } else {
- echo "Sikertelen aktiválás";
- }
- }
- } */
- /* public function adat_inaktivalas(){
- if (isset($_GET['inaktivalando_id']) and
- !empty($_GET['inaktivalando_id']) and
- is_numeric($_GET['inaktivalando_id'])
- ){
- $this->sql = "UPDATE
- bobik
- SET
- aktivitas = 'inaktiv'
- WHERE
- id = ".$_GET['inaktivalando_id']."
- ";
- if ($this->conn->query($this->sql) === TRUE) {
- echo "Sikeres inaktiválás!";
- } else {
- echo "Sikertelen inaktiválás";
- }
- }
- } */
- public function adat_torles(){
- if (isset($_GET['torlendo_id']) and
- is_numeric($_GET['torlendo_id']) and
- !empty($_GET['torlendo_id'])
- ){
- $this->sql = "DELETE FROM bobik
- WHERE id = ".$_GET['torlendo_id']."
- ";
- if ($this->conn->query($this->sql) === TRUE) {
- echo "Sikeres törlés!";
- } else {
- echo "Sikertelen törlés";
- }
- }
- }
- public function adatok_felvetele(){
- if (isset($_GET['input_nev']) and
- !empty($_GET['input_nev']) and
- isset($_GET['input_nem']) and
- !empty($_GET['input_nem']) and
- isset($_GET['input_fogl']) and
- !empty($_GET['input_fogl'])
- ) {
- $this->sql = "INSERT INTO
- bobik
- (
- `nev`,
- `nem`,
- `foglalkozas`
- )
- VALUES
- (
- '".$_GET['input_nev']."',
- '".$_GET['input_nem']."',
- '".$_GET['input_fogl']."'
- )
- ";
- if ($this->conn->query($this->sql) === TRUE) {
- echo "New record created successfully";
- } else {
- echo "Error: " . $this->sql . "<br>" . $this->conn->error;
- }
- }
- }
- /* public function osszes_bejegyzes_moderalasra(){
- $this->result = $this->conn->query("SELECT * FROM bobik");
- if ($this->result->num_rows > 0) {
- while($this->row = $this->result->fetch_assoc()) {
- echo "<p>";
- echo $this->row["nev"];
- echo "[" . $this->row["aktivitas"] . "] ";
- $aktivalas_url = "";
- $aktivalas_url .= "?site=blog";
- $aktivalas_url .= "&action=cmd_update_aktivalas";
- $aktivalas_url .= "&aktivalando_id=".$this->row["id"];
- echo "<a href='".$_SERVER['PHP_SELF']."".$aktivalas_url."'>Aktiválás</a> ";
- $inaktivalas_url = "";
- $inaktivalas_url .= "?site=blog";
- $inaktivalas_url .= "&action=cmd_update_inaktivalas";
- $inaktivalas_url .= "&inaktivalando_id=".$this->row["id"];
- echo "<a href='".$_SERVER['PHP_SELF']."".$inaktivalas_url."'>Inaktiválás</a> ";
- echo "</p>";
- }
- } else {
- echo "Nincs felvett blogbejegyzés!";
- }
- } */
- public function osszes_bejegyzes(){
- ?>
- <form method="GET" action="<?php echo $_SERVER["PHP_SELF"];?>">
- <input type="text" name="keresett_szo" placeholder="Keresendő kifejezés">
- <input type="hidden" name="action" value="keres">
- <input type="submit" value="Keress!">
- </form>
- <br />
- <?php
- if (isset($_GET["action"]) and $_GET["action"]=="keres"){
- if(isset($_GET["keresett_szo"]) and !empty($_GET["keresett_szo"])){
- $this->sql = "SELECT * FROM bobik WHERE nev like '%".$_GET['keresett_szo']."%' ORDER BY nev asc";
- } else {
- $this->sql = "SELECT * FROM bobik ORDER BY nev asc";
- }
- } else {
- $this->sql = "SELECT * FROM bobik ORDER BY nev asc";
- }
- $this->result = $this->conn->query($this->sql);
- if ($this->result->num_rows > 0) {
- while($this->row = $this->result->fetch_assoc()) {
- echo "<p>";
- echo $this->row["nev"];
- /* echo "[" . $this->row["aktivitas"] . "] "; */
- $del_url = "";
- $del_url .= "?site=blog";
- $del_url .= "&action=cmd_delete";
- $del_url .= "&torlendo_id=".$this->row["id"];
- echo "<a href='".$_SERVER["PHP_SELF"]."".$del_url."'>Törlés</a> ";
- /* $aktivalas_url = "";
- $aktivalas_url .= "?site=blog";
- $aktivalas_url .= "&action=cmd_update_aktivalas";
- $aktivalas_url .= "&aktivalando_id=".$this->row["id"];
- echo "<a href='".$_SERVER['PHP_SELF']."".$aktivalas_url."'>Aktiválás</a> ";
- $inaktivalas_url = "";
- $inaktivalas_url .= "?site=blog";
- $inaktivalas_url .= "&action=cmd_update_inaktivalas";
- $inaktivalas_url .= "&inaktivalando_id=".$this->row["id"];
- echo "<a href='".$_SERVER['PHP_SELF']."".$inaktivalas_url."'>Inaktiválás</a> "; */
- $modositas_url = "";
- $modositas_url .= "?site=blog";
- $modositas_url .= "&action=cmd_update_form";
- $modositas_url .= "&modositando_id=".$this->row["id"];
- echo "<a href='".$_SERVER['PHP_SELF']."".$modositas_url."'>Módosítás</a> ";
- echo "</p>";
- }
- } else {
- echo "Nincs felvett blogbejegyzés!";
- }
- }
- public function osszes_bejegyzes_user(){
- $this->result = $this->conn->query("SELECT * FROM bobik");
- if ($this->result->num_rows > 0) {
- while($this->row = $this->result->fetch_assoc()) {
- echo "<p>";
- echo $this->row["nev"];
- echo "[" . $this->row["aktivitas"] . "] ";
- echo "</p>";
- }
- } else {
- echo "Nincs felvett blogbejegyzés!";
- }
- }
- public function kapcsolat_nyitas() {
- $this->conn = new mysqli($this->servername, $this->username, $this->password, $this->dbname);
- if ($this->conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- } else {
- //echo "Kapcsolat rendben!";
- }
- $this->conn->set_charset("utf8");
- }
- public function kapcsolat_bontas(){
- $this->conn->close();
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement