Jump to content

alphasil

Members
  • Posts

    21
  • Joined

  • Last visited

alphasil's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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 = "xxxx@gmail.com"; $mail->Password = "xxxx"; $mail->setFrom('xxxx@gmail.com', 'PAAD - Atividades'); $mail->addReplyTo('xxxx@gmail.com', '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
  2. 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?
  3. 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
  4. 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
  5. 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
  6. Yes i know that but it just a small webite to my school, just to put some records about activities. Many thanks to all
  7. Thank you Done...about the md5 right now i leave it this way...it is just a test. Thanks
  8. 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>'; } }
  9. 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
  10. Thank you it was the double you mentioned. Best regards
  11. 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?
  12. 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
  13. 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??
  14. Ok Thanks for your help. I will try your suggestion best regards
  15. 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
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.