<?php function conectar() { $dbhost = 'localhost'; $dbuser = '******'; $dbpass = '******'; $dbname = 'SobreviviendoUp'; $dbh = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); return $dbh; } $pidProfesores = $_GET["idProfesores"]; $pComentario = $_GET["Comentario"]; function addcom($idProfesores, $comentario) { $sql = 'INSERT INTO Comentario (idProfesores, comentario) VALUES (:idProfesores,:comentario)'; try { $db = conectar(); $stmt = $db->prepare($sql); $stmt->bindParam('idProfesores', $idProfesores); $stmt->bindParam('comentario', $comentario); $stmt->execute(); echo $stmt->rowCount(); $db = null; } catch (PDOException $e) { echo 'Error: ' . $e->getMessage(); } } addcom($pidProfesores, $pComentario);
function _Comment_add() { $nid = param_num("nid"); if (!$nid) { $this->_header("index.php"); } $newsdata = getNews($nid); if (!$newsdata) { $this->_header("index.php"); } $comrows = 6; $data = $_SESSION['steps']; #information message, step 2 if ($data['addcom']) { #save step unset($data['addcom']); $_SESSION['steps'] = $data; $pages = getNewsCommentsPages($nid, $comrows); $this->forms['information']['url'] = $this->backtracking->backlink(); $this->forms['information']['title'] = "Kommentar hinzufügen"; $this->forms['information']['message'] = "Kommentar hinzugefügt"; $this->forms['information']['style'] = "green"; $this->show('message_information', "Kommentar hinzufügen"); } #formular send if ($_REQUEST['send']) { if ($_REQUEST['next_x']) { $items['message'] = param_str("message", true); $errors = false; #check if empty foreach ($items as $key => $value) { if (!$value) { $this->forms['addcom']['fields'][$key]['error'] = 'Feld darf nicht leer sein!'; $this->forms['addcom']['fields'][$key]['bgrd'] = '_error'; $errors = true; } else { $this->forms['addcom']['fields'][$key]['value'] = $value; } } #optional parameters if (!$errors) { #save step $data['addcom'] = 1; $_SESSION['steps'] = $data; $id = addcom($nid, editPostdata($items['message']), $this->userdata['uid']); addToLogfile("Kommentar zu News <b>" . $newsdata['title'] . "</b> hinzugefügt", "News", $this->userdata['uid']); $this->_header("index.php?action=addcom&nid=" . $nid . "&send"); } } else { $this->_header($this->backtracking->backlink()); } } $this->forms['addcom']['name'] = $return['name']; $this->forms['addcom']['url'] = "index.php?nid=" . $nid; $this->forms['addcom']['action'] = 'addcom'; $this->show('com_add_form', "Kommentar hinzufügen"); }
<?php if (tp('verif') == 1) { $nextid = getnextidtable('communique'); model::load('com', 'addcom'); if (!addcom(tp('titrfr'), tp('titren'), tp('titrar'), tp('contfr'), tp('conten'), tp('contar'), $nextid, tp('dat'))) { exit("0"); } else { exit("1"); } } else { view::load('com', 'addcom'); }