Jump to content

funbinod

Members
  • Posts

    501
  • Joined

  • Last visited

Posts posted by funbinod

  1. i want.

     

    I've tried also.

    <?phprequire('capquery.php');?><script>$(document).ready(function(e) {	var cap = <?php echo $capstotal; ?>;	var staff = <?php echo $staffstotal; ?>;	var suncr = <?php echo $suncrstotal; ?>;	var pro = <?php echo $prostotal; ?>;	var tax = <?php echo $taxstotal; ?>;	var curl = parseInt(cap) + parseInt(staff) + parseInt(suncr) + parseInt(pro) + parseInt(tax);	var ll = <?php echo $llstotal; ?>;    $('#cap').append(cap);    $('#staff').append(staff);    $('#suncr').append(suncr);    $('#pro').append(pro);    $('#tax').append(tax);    $('#curl').append(curl);    $('#ll').append(ll);});</script>

    this work very fine. i just gave a try with .load() and found it to be slow. so i wanted to why this? in the load method, i tried loading specific div, one by one, not everything at once. this why this happens? i just wanted to be clear about this..

  2. i'm trying to load some divs on some page. but I found that the data load is slow. in stead if I php include that page and echo the var, it echos instantly but if I use jquery load(), it delays it.

     

    here is the jquery load() tryout

    $(document).ready(function(e) {    $('#cap').load('capquery.php #cap');    $('#curl').load('capquery.php #curl');    $('#ll').load('capquery.php #ll');    $('#pl').load('pl.php #pl');    $('#cura').load('capquery.php #cura');    $('#fa').load('capquery.php #fa');    $('#inv').load('capquery.php #inv');    $('#mea').load('capquery.php #mea');});

    why is this?

  3. the exact is what i'm doing but not in array...

     

    the all if statements in the above code block, except the last one, are to create session vars if error occurred. and the last if statement is to run if any of them is set. and if any or many error session are set, the all form data are collected on other session vars and send back to the register.php.

     

    is this ok?

  4. sorry! it became hard to make u understand. by return I meant I want the values of the vars and I want them on the forwarded page (register.php).

     

    but I now found where I did mistake. actually there is another if condition before this query and I found that it escaped to the else { } condition and thus it failed to execute these querys.

     

    I solved the problem now....

     

    but will u tell me if this method of validation is good or not. is there any other best way to do this?

  5. i'm trying to validate my form. I assumed it the following way

    if ( $_POST['company'] == '') {	session_start();	$_SESSION['cerr'] = 'company name cannot be blank';}if ( ($_POST['caddress'])=='') {	session_start();	$_SESSION['caerr'] = 'company address cannot be blank';}if ( ($_POST['phone'])=='') {	session_start();	$_SESSION['pherr'] = 'company phone cannot be blank';}if ( ($_POST['name'])=='' ) {	session_start();	$_SESSION['nerr'] = 'admin name cannot be blank';}if ( ($_POST['aaddress'])=='' ) {	session_start();	$_SESSION['aaerr'] = 'admin address cannot be blank';}if ( ($_POST['aphone'])=='' ) {	session_start();	$_SESSION['apherr'] = 'please specify admin phone number';}if ( ($_POST['username'])=='' ) {	session_start();	$_SESSION['uerr'] = 'please input your email address';}// check password strengthif ((!preg_match("~([a-z][A-Z]+d|[a-z]d+[A-Z]|[A-Z][a-z]+d|[A-Z]d+[a-z]|d[a-z]+[A-Z]|d[A-Z]+[a-z])~",$_SESSION['pass'])) || strlen($_SESSION['pass'])<8 || (!preg_match("~([a-z][A-Z]+d|[a-z]d+[A-Z]|[A-Z][a-z]+d|[A-Z]d+[a-z]|d[a-z]+[A-Z]|d[A-Z]+[a-z])~",$_SESSION['pass'])) && strlen($_SESSION['pass'])<8) {	session_start();	$_SESSION['pserr'] = 'use at least 1 CAPITAL LETTER, 1 small letter, 1 NUMB3R and minimum 8 characters!';}// check required lengthif ( strlen($company)<5 ) {	session_start();	$_SESSION['cerr'] = 'use at least 5 characters';}if ( strlen($_POST['caddress'])<5 ) {	session_start();	$_SESSION['caerr'] = 'use at least 5 characters';}if ( strlen($_POST['phone'])<11 ) {	session_start();	$_SESSION['pherr'] = 'input at least 11 digits';}if ( strlen($_POST['name'])<5 ) {	session_start();	$_SESSION['nerr'] = 'input at least 5 characters';}if ( strlen($_POST['aaddress'])<5 ) {	session_start();	$_SESSION['aaerr'] = 'input at least 5 characters';}if ( strlen($_POST['aphone'])<11 ) {	session_start();	$_SESSION['pherr'] = 'input at least 11 digits';}if ( strlen($_POST['username'])<5 ) {	session_start();	$_SESSION['uerr'] = 'input at least 5 characters';}if (!filter_var($username, FILTER_VALIDATE_EMAIL)) {	session_start();	$_SESSION['ucerr'] = 'email not in proper format';}if ($pass != $conpass) {	session_start();	$_SESSION['pmerr'] = 'passwords didnot match';}if (isset($_SESSION['cerr']) || isset($_SESSION['caerr']) || isset($_SESSION['pherr']) || isset($_SESSION['nerr']) || isset($_SESSION['aaerr']) || isset($_SESSION['apherr']) || isset($_SESSION['uerr']) || isset($_SESSION['pserr']) || isset($_SESSION['ucerr']) || $_SESSION['pmerr'] ) {	session_start();	$_SESSION['company'] = ($_POST['company']);	$_SESSION['caddress'] = ($_POST['caddress']);	$_SESSION['phone'] = ($_POST['phone']);	$_SESSION['name'] = ($_POST['name']);	$_SESSION['aaddress'] = ($_POST['aaddress']);	$_SESSION['aphone'] = ($_POST['aphone']);	$_SESSION['username'] = ($_POST['username']);	die(header('location: register.php?'));} else {	/* execution code */}

    this is working except executing specified error errors. its not executing $_SESSION['cerr'] and others but executing $_SESSION['company'] and others.

     

    feeling confused whether i'm doing the right way or not. all I want is to display all _SESSION messages on register.php if it encounter any error..

  6. I was trying to style <progress> bar. and I wrote this for IE---

    progress {	color:#F00; background-color:#EFD259; height:30px; border-radius:10px; border:2px solid #FFF;}

    then I wrote this for chrome---

    progress::-webkit-progress-bar {	color:#F00; background-color:#EFD259; height:30px; border-radius:10px; border:2px solid #FFF;}

    it worked fine for IE. but for chrome it only shows block. the progress bar doesn't progress. i'm using chrome version 39

     

    here is the try

    http://jsfiddle.net/vnm6mbae/

  7. hi guys!

    i'm trying to create a page that can load misc pages on the same page.

     

    here is some try----

    <!--this is the main page. when the page is ready, it loads the 'default.php' page in 'main' div.--><script>$(document).ready(function(e) {	$('#main').delay(100).queue(function(nxt) {		$(this).load('default.php?');		nxt();	});	$('#main').fadeIn(1000);});</script><div id="main" style="text-align:center; display:none;"></div>
    <!--default.phpwhen user presses key 'A' then the div 'main' first fades out then emptys it and loads 'acman.php' in it then fades in.--><script>$(document).ready(function(e) {    $('body').keydown(function(e) {        if (e.which === 65) {            e.preventDefault();            $("#main").fadeOut(1000);            $('#main').empty();            $('#main').append('<div style="align-self:center; width:100%;"><progress style="width:50%; color:#FF0;">testing</progress></div>');            $('#main').delay(100).queue(function(nxt) {                $('#main').fadeIn(1000).load('acman.php?');                nxt();            });            $('#main').fadeIn(1000);        }    });});</script>
    <!--acman.phpwhen user presses key 'ESC' then the div 'main' first fades out then emptys it and loads 'default.php' back in it then fades in.--><script>$(document).ready(function(e) {    $('body').keydown(function(e) {        if (e.which === 27) {            e.preventDefault();            $("#main").fadeOut(1000);            $('#main').empty();            $('#main').append('<div style="align-self:center; width:100%;"><progress style="width:50%; color:#FF0;">testing</progress></div>');            $('#main').delay(100).queue(function(nxt) {                $('#main').fadeIn(1000).load('default.php?');                nxt();            });            $('#main').fadeIn(1000);        }    });});</script>

    everythis works fine. but for the first time only. when after the default.php is loaded back and I repeat loading acman.php again, then it fades out and fades in two times and the same happens if the default.php is loaded back again. the interesting is that, the number of times I repeat loading acman.php and default.php back to back, it fades out and in the number of times. please suggest me what is the mistake....

  8. oh I got it. I googled and found that I should free_result the previous query before I should prepare the another. I had one query previously to get salt column. after I freed the quert by $rstmt->free_result(); this query worked. thanks for the support and the company brother.

     

    (or there is any other method? if yes please share....)

  9. I dunno! :P

    but it returns the query on "else" segment not on "if" segment. see the following---

    if($stmt = $mysqli->prepare("SELECT uid,cid,name,username,password,type FROM user WHERE username=? AND password=?")) {	$stmt->bind_param('ss', $username, $password);	$stmt->execute();	$stmt->bind_result($uid1, $cid1, $name, $uname, $dbPass, $typ);	$stmt->fetch();	echo 'result:'.$uid1.','.$cid1;} else {	echo 'error'; // it returns this block.....}
  10. oh ok. I will remove escape string.

     

    yes I did the exact hashing procedure while adding the password to the database. it worked before with MySQLi query method. I tried to change it with prepared statements but it did not give the return the data for the columns...

     

    EDIT:

    I found that it is showing error on this statement query---

    if($stmt = $mysqli->prepare("SELECT uid,cid,name,username,password,type FROM user WHERE username=? AND password=?")) {
  11. thank u. I understood d problem.

    but i'm encountering problem still

     

    please find some error on following if any----

    $username = mysqli_real_escape_string($mysqli, $_POST['username']);if($rstmt = $mysqli->prepare("SELECT salt,password FROM user WHERE username=?")) {	$rstmt->bind_param('s', $username);	$rstmt->execute();	$rstmt->bind_result($salt,$dbPass);	$rstmt->fetch();}$password = hash('sha512', mysqli_real_escape_string($mysqli, $_POST['password']).$salt);if($stmt=$mysqli->prepare("SELECT uid,cid,name,username,password,type FROM user WHERE username=? AND password=?")){	$stmt->bind_param('ss', $username, $password);	$stmt->execute();	$stmt->store_result();	if($stmt->num_rows()!=0) {		$stmt->bind_result($uid1, $cid1, $name, $uname, $dbPass, $typ);		$stmt->fetch();	} else {		$_SESSION['error']="Username and Password didnot match on our database!";		return false;	}}
  12. I got a error on same type of query..

     

    this is my first try on prepared statements so please consider my mistake...

    $username = mysqli_real_escape_string($mysqli, $_POST['username']);if($rstmt = $mysqli->prepare("SELECT salt,active FROM user WHERE username='$username'")) {	$rstmt->execute();	$rstmt->bind_result('ss', $salt,$active);	$rstmt->fetch();}$password = hash('sha512', mysqli_real_escape_string($mysqli, $_POST['password'] . $salt));

    this query returned error

     

    Fatal error: Cannot pass parameter 1 by reference

     

    please guide....

  13. thank u! it helped me a lot. another question regarding d same topic...

     

    at http://php.net/manual/en/mysqli-stmt.bind-param.php

    there is a prepared statement as example...

     

    $stmt = $mysqli->prepare("INSERT INTO CountryLanguage VALUES (?, ?, ?, ?)");$stmt->bind_param('sssd', $code, $language, $official, $percent);

    what I didn't understand is --- how can this statement understand that in which column will d values be inserted???

  14. no it doesn't work. I've set $edate as array with multiple values like ----

     

    $edate= array ( 1 => '2014-07-17', 2 =>'2014-07-18', 3 =>'2014-07-19', 4 =>'2014-07-20', 5 =>'2014-07-21', 6 =>'2014-07-22', 7 =>'2014-07-23', 8 =>'2014-07-24', 9 =>'2014-07-25', 10 =>'2014-07-26', 11 =>'2014-07-27', 12 =>'2014-07-28', 13 =>'2014-07-29', 14 =>'2014-07-30', 15 =>'2014-07-31', 16 =>'2014-08-01', 17 =>'2014-08-02', 18 =>'2014-08-03', 19 =>'2014-08-04', 20 =>'2014-08-05', 21 =>'2014-08-06', 22 =>'2014-08-07', 23 =>'2014-08-08', 24 =>'2014-08-09', 25 =>'2014-08-10', 26 =>'2014-08-11', 27 =>'2014-08-12', 28 =>'2014-08-13', 29 =>'2014-08-14', 30 =>'2014-08-15', 31 =>'2014-08-16', 32 =>'2014-11-20',);

×
×
  • Create New...