
alphasil
Members-
Posts
21 -
Joined
-
Last visited
Everything posted by alphasil
-
Hi I'm using this framework to my project and i'm having some issues I have created a funciont sendEmail() to use after validate that my query has been inserted.but when i have this function my main page doesn't close the dialog, if i remove this function tha page close the dialog I don't undertand that This is php <?php require 'PHPMailerAutoload.php'; require_once('class.phpmailer.php'); include("class.smtp.php"); include 'conn.php'; header("Content-Type: text/html;charset=utf-8"); mysql_query("SET NAMES 'utf8'"); $idUser = filter_input(INPUT_POST, 'userid'); $email = filter_input(INPUT_POST, 'email'); $cargo = filter_input(INPUT_POST, 'cargo'); $atividade = filter_input(INPUT_POST, 'nome'); $data = filter_input(INPUT_POST, 'data'); $hora = filter_input(INPUT_POST, 'hora'); $local = filter_input(INPUT_POST, 'local'); $inter = filter_input(INPUT_POST, 'inter'); $notas = filter_input(INPUT_POST, 'notas'); $newDate = date("Y-m-d", strtotime($data)); $cargoId = mysql_query("SELECT idcargo FROM pae_cargo WHERE cargo= '$cargo'"); $cargoRow = mysql_fetch_row($cargoId)or die(mysql_error()); $cargoNome = $cargoRow[0]; if ($cargoNome != null) { $sql = "Insert into `pae_atividades`(idutilizador, idcargo,atividade,data,hora,local,inter,notas) values('$idUser','$cargoNome', '$atividade','$newDate','$hora','$local','$inter','$notas')"; } $result = mysql_query($sql); if ($result) { sendEmail(); echo json_encode(array( 'success' => true, 'message' => 'Atividade Registada com Sucesso')); } else { echo json_encode(array('errorMsg' => 'Erro...nada foi registado.')); } function sendEmail() { $email = filter_input(INPUT_POST, 'email'); $atividade = filter_input(INPUT_POST, 'nome'); $data = filter_input(INPUT_POST, 'data'); $hora = filter_input(INPUT_POST, 'hora'); $local = filter_input(INPUT_POST, 'local'); $inter = filter_input(INPUT_POST, 'inter'); $notas = filter_input(INPUT_POST, 'notas'); $newDate = date("Y-m-d", strtotime($data)); $vaiEmail = "A sua atividade foi registada com sucesso\n\nAtividade: $atividade\n\nData: $newDate\n\nHora: $hora\n\nLocal: $local\n\nIntervenientes: $inter\n\nNotas: $notas\n\nObrigado"; $mail = new PHPMailer; $mail->isSMTP(); $mail->SMTPDebug = 1; $mail->Debugoutput = 'html'; $mail->Mailer = "smtp"; $mail->SMTPSecure = "ssl"; $mail->Host = "smtp.gmail.com"; $mail->Port = 465; $mail->SMTPKeepAlive = true; $mail->SMTPAuth = true; $mail->Username = "[email protected]"; $mail->Password = "xxxx"; $mail->setFrom('[email protected]', 'PAAD - Atividades'); $mail->addReplyTo('[email protected]', 'PAAD - Atividades'); $mail->addAddress($email); $mail->Subject = 'Registo de nova atividade'; $mail->Body = $vaiEmail; if (!$mail->Send()) { echo "Mailer Error: " . $mail->ErrorInfo; } else { echo "Message sent!"; } } And this is my javascript function atividadeNova() { $('#fm').form('submit', { url: 'nova_atividade.php', onSubmit: function () { return $(this).form('validate'); }, success: function (result) { var result = eval('(' + result + ')'); if (result.errorMsg) { console.log(result.errorMsg), $.messager.show({ title: 'EBSPMA Atividades - Erro', msg: result.errorMsg }); } else { $.messager.show({ title: 'EBSPMA Atividades - Sucesso', msg: result.message, timeout: 2000, showType: 'slide', style: { right: '', top: document.body.scrollTop + document.documentElement.scrollTop, bottom: '', zIndex: $.fn.window.defaults.zIndex++ } }); $('#dlg').dialog('close'); // close the dialog $('#dg').datagrid('reload'); // reload the user data } } }); } If i use the function i receive the email but the javascript seems not responding I'm sending an example to see...with function sendEmail(); the record has been inserted into the database but that window dialog doesn't close. What's wrong? Thanks
-
Hi I'm having this issue, when i put an url who must show me records i have blank html page <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once 'database_connection.php'; $post=array( 'limit'=>(isset($_REQUEST['rows']))?$_REQUEST['rows']:'', 'page'=>(isset($_REQUEST['page']))?$_REQUEST['page']:'', 'orderby'=>(isset($_REQUEST['sidx']))?$_REQUEST['sidx']:'', 'orden'=>(isset($_REQUEST['sord']))?$_REQUEST['sord']:'', 'search'=>(isset($_REQUEST['_search']))?$_REQUEST['_search']:'', ); $se =""; if($post['search'] == 'true'){ $b = array(); $search['like']=elements(array('utilizador','email'),$_REQUEST); foreach($search['like'] as $key => $value){ if($value != false) $b[]="$key like '%$value%'"; } $search['where']=elements(array('nome','utilizador','email'),$_REQUEST); foreach($search['where'] as $key => $value){ if($value != false) $b[]="$key = '$value'"; } $se=" where ".implode(' and ',$b ); } $query = mysql_query("select count(*) as t from utilizador".$se); if(!$query) echo mysql_error(); $count = mysql_result($query,0); if( $count > 0 && $post['limit'] > 0) { $total_pages = ceil($count/$post['limit']); if ($post['page'] > $total_pages) $post['page']=$total_pages; $post['offset']=$post['limit']*$post['page'] - $post['limit']; } else { $total_pages = 0; $post['page']=0; $post['offset']=0; } $sql = "SELECT idutilizador, nome, utilizador, telefone, email, password FROM utilizador ".$se; if( !empty($post['orden']) && !empty($post['orderby'])) $sql .= " ORDER BY $post[orderby] $post[orden] "; if($post['limit'] && $post['offset']) $sql.=" limit $post[offset], $post[limit]"; elseif($post['limit']) $sql .=" limit 0,$post[limit]"; $query = mysql_query($sql); if(!$query) echo mysql_error(); $result = array(); $i = 0; while($row = mysql_fetch_object($query)){ $result[$i]['id']=$row->idutilizador; $result[$i]['cell']=array($row->idutilizador,$row->nome,$row->utilizador,$row->telefone,$row->email,$row->password); $i++; } $json = new stdClass(); $json->rows=$result; $json->total=$total_pages; $json->page=$post['page']; $json->records=$count; echo json_encode($json); function elements($items, $array, $default = FALSE) { $return = array(); if ( ! is_array($items)){ $items = array($items); } foreach ($items as $item){ if (isset($array[$item])){ $return[$item] = $array[$item]; }else{ $return[$item] = $default; } } return $return; } ?> *Update It works if i put $result[$i]['cell']=array($row->idutilizador,$row->telefone,$row->email,$row->password); So i'm think it's because in $nome(ex: Luis Miguel) and $utlizador(ex Susana Maria) don't accept this (space between words) it is correct?
-
Ok Almost everything fixed but now i having this problem The Jgrid gives me this url Request URL:http://localhost/login/server.php?_search=false&rows=20&page=1&sidx=&sord=asc And nothing is show but if i put this url manually i have records http://localhost/login/server.php?_search=false&page=1&rows=3&sidx=1&sord=asc So how can i change the Jgrid url? regards
-
Hi Thank you my server.php is now <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once 'database_connection.php'; $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $result = mysql_query("SELECT COUNT(*) AS count FROM utilizador"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT * FROM utilizador ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[idutilizador]; $responce->rows[$i]['cell']=array($row[idutilizador],$row[nome],$row[utilizador],$row[telefone],$row[email]); $i++; } echo json_encode($responce); ?> I have put the error reporting and when i run only server.php i have this Notice: Undefined index: page in C:\xampp\htdocs\login\server.php on line 5 Notice: Undefined index: rows in C:\xampp\htdocs\login\server.php on line 6 Notice: Undefined index: sidx in C:\xampp\htdocs\login\server.php on line 7 Notice: Undefined index: sord in C:\xampp\htdocs\login\server.php on line 8 Warning: Division by zero in C:\xampp\htdocs\login\server.php on line 16 Couldn t execute query.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 But i'm following this tutorial http://www.trirand.com/blog/jqgrid/jqgrid.html
-
Hi I have another problem with my code I have records in my database and i want to put them in Jgrid but no records are show. This is my php <?php error_reporting(0); require_once 'database_connection.php'; $page = $_GET['page']; // get the requested page $limit = $_GET['rows']; // get how many rows we want to have into the grid $sidx = $_GET['sidx']; // get index row - i.e. user click to sort $sord = $_GET['sord']; // get the direction if(!$sidx) $sidx =1; // connect to the database $result = mysql_query("SELECT COUNT(*) AS count FROM utilizador"); $row = mysql_fetch_array($result,MYSQL_ASSOC); $count = $row['count']; if( $count >0 ) { $total_pages = ceil($count/$limit); } else { $total_pages = 0; } if ($page > $total_pages) $page=$total_pages; $start = $limit*$page - $limit; // do not put $limit*($page - 1) $SQL = "SELECT * FROM utilizador ORDER BY $sidx $sord LIMIT $start , $limit"; $result = mysql_query( $SQL ) or die("Couldn t execute query.".mysql_error()); $responce->page = $page; $responce->total = $total_pages; $responce->records = $count; $i=0; while($row = mysql_fetch_array($result,MYSQL_ASSOC)) { $responce->rows[$i]['id']=$row[idutilizador]; $responce->rows[$i]['cell']=array($row[idutilizador],$row[nome],$row[utilizador],$row[telefone],$row[email]); $i++; } echo json_encode($responce); ?> And this is the Jgrid <html> <head> <title>jQGrid example</title> <!-- Load CSS--><br /> <link rel="stylesheet" href="css/ui.jqgrid.css" type="text/css" media="all" /> <!-- For this theme, download your own from link above, and place it at css folder --> <link rel="stylesheet" href="css/jquery-ui-1.9.2.custom.css" type="text/css" media="all" /> <!-- Load Javascript --> <script src="js/jquery_1.5.2.js" type="text/javascript"></script> <script src="js/jquery-ui-1.8.1.custom.min.js" type="text/javascript"></script> <script src="js/i18n/grid.locale-pt.js" type="text/javascript"></script> <script src="js/jquery.jqGrid.min.js" type="text/javascript"></script> </head> <body> <table id="datagrid"></table> <div id="navGrid"></div> <p><script language="javascript"> jQuery("#datagrid").jqGrid({ url:'example.php', datatype: "json", colNames:['Idutilizador','Nome', 'Utilizador', 'Telefone','Email'], colModel:[ {name:'idutilizador',index:'idutilizador', width:55,editable:false,editoptions:{readonly:true,size:10}}, {name:'nome',index:'nome', width:80,editable:true,editoptions:{size:10}}, {name:'idutilizador',index:'idutilizador', width:90,editable:true,editoptions:{size:25}}, {name:'telefone',index:'telefone', width:60, align:"right",editable:true,editoptions:{size:10}}, {name:'email',index:'email', width:60, align:"right",editable:true,editoptions:{size:10}} ], rowNum:10, rowList:[10,15,20,25,30,35,40], pager: '#navGrid', sortname: 'idutilizador', sortorder: "asc", height: 500, width:900, viewrecords: true, caption:"Atividades Registadas" }); jQuery("#datagrid").jqGrid('navGrid','#navGrid',{edit:true,add:true,del:true}); </script> </body> </html> Anything wrong with the code? Regards
-
Yes i know that but it just a small webite to my school, just to put some records about activities. Many thanks to all
-
Thank you Done...about the md5 right now i leave it this way...it is just a test. Thanks
-
Thank you for your help Yes i have error display but there is error right now, i don't have the 404 error but another issue I put the header and now the login page and the index page are displayed at same time after login. Why the login page not close? elseif($_POST["page"] == "users_login") { $user_utilizador = trim(strip_tags($_POST['email'])); $user_password = trim(strip_tags($_POST['passwd'])); $encrypted_md5_password = md5($user_password); $validate_user_information = mysql_query("select * from `utilizador` where `utilizador` = '".mysql_real_escape_string($user_utilizador)."' and `password` = '".mysql_real_escape_string($encrypted_md5_password)."'"); if(mysql_num_rows($validate_user_information) == 1) { $get_user_information = mysql_fetch_array($validate_user_information); $user_nome = $get_user_information["nome"]; $_SESSION["VALID_USER_ID"] = $user_utilizador; $_SESSION["USER_FULLNAME"] = $user_nome; header("Location: index.php"); } else { echo '<br><div class="info">Desculpe, a informação fornecida está errada. Corrije-a por favor. Obrigado.</div><br>'; } }
-
Hi I'm getting this error but i'm sure the file is there, this is my code where i'm having this problem elseif($_POST["page"] == "users_login") { $user_utilizador = trim(strip_tags($_POST['email'])); $user_password = trim(strip_tags($_POST['passwd'])); $encrypted_md5_password = md5($user_password); $validate_user_information = mysql_query("select * from `utilizador` where `utilizador` = '".mysql_real_escape_string($user_utilizador)."' and `password` = '".mysql_real_escape_string($encrypted_md5_password)."'"); echo $validate_user_information; if(mysql_num_rows($validate_user_information) == 1) { $get_user_information = mysql_fetch_array($validate_user_information); $_SESSION["VALID_USER_ID"] = $user_utilizador; $_SESSION["USER_FULLNAME"] = strip_tags($get_user_information["nome"]); echo 'index.php?uid='.$_SESSION["USER_FULLNAME"].'&'; echo 'login_process_completed_successfully=yes'; } else { echo '<br><div class="info">Desculpe, a informação fornecida está errada. Corrije-a por favor. Obrigado.</div><br>'; } } So after the login process it should open the index.php I have try with header(Location: index,php) and the details are displayed in the same page as the login... any help please? Thanks
-
Thank you it was the double you mentioned. Best regards
-
Thanks again...i'm learning a lot from you guys. Last question, it workings, i can see the dates in the url but the pages comes blank this is my query $dataInicio=$_GET['dataInicio']; $dataFim=$_GET['dataFim']; echo $dataInicio; echo $dataFim; $pdf->connect('localhost', 'xxxxxx', 'xxxxxx', 'xxxxxx'); $pdf->mysql_report("SELECT `atividade` , `data` , `hora` , `local` , `inter` FROM `pae_atividades` WHERE(`data` BETWEEN '$dataInicio' AND '$dataFim'") ORDER BY `data` ASC LIMIT 0 , 30"); ?> and the url is http://ebspma.edu.pt/atividades/pdfAct.php?dataInicio=2014-12-05&dataFim=2014-12-19 So it must be the query...any help?
-
Thanks Resolved, the submit was wrong. After submit i want to keep 2 variable (dataInicio) and (dataFim) to pass to another query to make the pdf. <?php if(isset($_POST['submitted'])) { $fgmembersite->PesquisarPorDatas(); $dataInicio = $_POST["dataInicio"]; $dataFim = $_POST["dataFim"]; } then in the url <p><a href='pdfAct.php?dataInicio=$dataInicio&dataFim=$dataFim'>Imprimir estas atividades</a></p> but the result is blank http://xxxxxxxxxxx/atividades/pdfAct.php?dataInicio=$dataInicio&dataFim=$dataFim So i have no values....whats wrong?? Thanks
-
Hi I'm trying to get the layout like i want but it's not easy I have this file <?PHP require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("login.php"); exit; } if(isset($_POST['submitted'])) { $fgmembersite->PesquisarPorDatas(); } ?> <div id='fg_membersite_content'> <div class="CSSTableGenerator" > //I want the result here </div> <br> I want the result of this $fgmembersite->PesquisarPorDatas(); in "//I want the result here" the r of my code, when the user use the "Pesquisar" button this fucntion is called but the result comes out of my css any help please??
-
Error with login...Notice: Undefined index: salt
alphasil replied to alphasil's topic in PHP Coding Help
Ok Thanks for your help. I will try your suggestion best regards -
Error with login...Notice: Undefined index: salt
alphasil replied to alphasil's topic in PHP Coding Help
Thank you So how can i use one way, i mean only the password to verify if the hashed pass is equal to the one stored in database? i have this function <code=php> public function checkhashSSHA($salt, $password) { $hash = base64_encode(sha1($password . $salt, true) . $salt); return $hash; } <code> Thanks -
Hi I'm having a strange error with this code and i get it working properly function CheckLoginInDB($username,$password) { if(!$this->DBLogin()) { $this->HandleError("Erro na ligação à Base de Dados!"); return false; } $username = $this->SanitizeForSQL($username); $nresult = mysql_query("SELECT * FROM utilizador WHERE utilizador = '$username'", $this->connection) or die(mysql_error()); // check for result $no_of_rows = mysql_num_rows($nresult); if ($no_of_rows > 0) { $nresult = mysql_fetch_array($nresult); $salt = $nresult['salt']; echo $salt; $encrypted_password = $nresult['password']; $hash = $this->checkhashSSHA($salt, $password); echo $hash; } $qry = "Select idutilizador, nome, email from utilizador where utilizador='$username' and password='$hash'"; $result = mysql_query($qry,$this->connection); if(!$result || mysql_num_rows($result) <= 0) { $this->HandleError("Erro: Utilizador ou password errados"); return false; } $row = mysql_fetch_assoc($result); $_SESSION['idutilizador'] = $row['idutilizador']; $_SESSION['name_of_user'] = $row['nome']; $_SESSION['email_of_user'] = $row['email']; return true; } This is my table Field Type Collation Null Key Default Extra Privileges Comment --------------------------------------------- ----------- ----------------- ------ ------ ------- -------------- ------------------------------- --------- idutilizador int(11) (NULL) NO PRI (NULL) auto_increment select,insert,update,references nome varchar(45) latin1_general_ci NO (NULL) select,insert,update,references utilizador varchar(45) latin1_general_ci NO (NULL) select,insert,update,references telefone int(11) (NULL) YES (NULL) select,insert,update,references email varchar(45) latin1_general_ci NO (NULL) select,insert,update,references password varchar(45) latin1_general_ci NO (NULL) select,insert,update,references sexo int(11) (NULL) NO (NULL) select,insert,update,references opcao binary(10) (NULL) NO (NULL) select,insert,update,references grupodisciplinar_idgrupodisciplinar int(11) (NULL) YES MUL (NULL) select,insert,update,references escola_idescola int(11) (NULL) YES MUL (NULL) select,insert,update,references tipoutilizador_idtipoutilizador int(11) (NULL) YES MUL (NULL) select,insert,update,references departamento_iddepartamento int(11) (NULL) YES MUL (NULL) select,insert,update,references categoriaprofissional_idcategoriaprofissional int(11) (NULL) YES MUL (NULL) select,insert,update,references nivelensino_idnivelensino int(11) (NULL) YES MUL (NULL) select,insert,update,references privilegio_idprivilegio int(11) (NULL) YES MUL (NULL) select,insert,update,references Any help please? Thanks
-
Thank you....it works now But before moving to another page i would like to stay few seconds with a message to confrim the record has been deleted....it is possible? Thank you
-
ok...but how can i fix this? because when i first load the page i have my record in a table, using refresh the record is deleted from the database without using the button. Any suggestion to fix this code? Thanks
-
Hi I have this function in php file function verAtividadesDocente() { if(!$this->DBLogin()) { $this->HandleError("Erro na ligação à Base de Dados!"); return false; } $image = $iduser = $this->UserId(); $nresult = mysql_query("SELECT t1.idatividade, t1.atividade, t1.data, t1.hora, t1.local,t2.nome FROM atividades t1, utilizador t2 WHERE t2.idutilizador = '$iduser'", $this->connection) or die(mysql_error()); $num_rows = mysql_num_rows($nresult); echo "<table>"; echo "<tr> <td>Nome</td> <td>Data</td> <td>Hora</td> <td>Local</td> <td>Intervenientes</td> <td>Operações</td> </tr>"; while($row = mysql_fetch_assoc($nresult)) { echo "<tr>"; $id = $row['idatividade']; echo "<td>".$row['atividade']."</td>"; echo "<td>".$row['data']."</td>"; echo "<td>".$row['hora']."</td>"; echo "<td>".$row['local']."</td>"; echo "<td>".$row['nome']."</td>"; echo "<td>".'<a href="editaAtividade.php?id=',$id,'"><img src="images/tick.png"></a>'.' / '.'<a href="' . $this->removerAtividade($id) . '";><img src="images/delete.png"></a>'."</td>"; echo "</tr>"; } echo "</table>"; } and my problem is this line echo "<td>".'<a href="editaAtividade.php?id=',$id,'"><img src="images/tick.png"></a>'.' / '.'<a href="' . $this->removerAtividade($id) . '";><img src="images/delete.png"></a>'."</td>"; I have two link with images, but when i load the page i have my database record, if i use refresh the record disapear without using any of those buttons....why? thanks for any help
-
Hi Thanks for your help That query is not what i'm looking for Before book i must check if there is any book between 'idtempoInicio' and 'idTempoFim', both are id, those columns belongs to tempo table with the following information idtempo inicio fim ------- -------- ---------- 11 08:15:00 09:00:00 12 09:00:00 09:45:00 13 10:00:00 10:45:00 14 10:45:00 11:30:00 15 11:40:00 12:25:00 16 12:25:00 13:10:00 17 13:20:00 14:05:00 18 14:05:00 14:50:00 19 15:00:00 15:45:00 20 15:45:00 16:30:00 21 16:45:00 17:30:00 22 17:30:00 18:15:00 So i want to check if i can book between id 11 (inicio) and id 12(fim) for example, i must query the table idreserva idutilizador idsala idtempoInicio idTempoFim data idequipamento idfuncionario --------- ------------ ------ ------------- ---------- ---------- ------------- --------------- 9 1261 4 12 12 2014-05-05 (NULL) (NULL) 10 1261 4 11 11 2014-05-05 (NULL) (NULL) 11 1261 2 11 11 2014-05-05 (NULL) (NULL) 12 1261 3 11 11 2014-05-09 (NULL) (NULL) Does it clear now??
-
Hi I need to make a quety using between because i need to check if a classroom is reserved between two differents time idtempoInicio and idTempoFim this is my query SELECT `idsala`, `idtempoInicio`, `idTempoFim`, `data` FROM `req_material_reserva` WHERE `idsala` = 3 AND `idtempoInicio` BETWEEN = 12 AND `idTempoFim` = 12 AND `data` = "2014-05-05" Error Code: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where `idtempoInicio` between = 12 AND `idTempoFim` = 12 AND `data` = "2014-05-0' at line 1 any help please??