Latest Posts in PHP

Re: in PHP
 
0
 

you close ur while loop too early, try this

<?php 

                while($row = mysqli_fetch_assoc($query_cat)) {
                    $h1       = $row["h1"];
                    $h2       = $row["h2"];
                    $span     = $row["span"];
                    $catslide = $row["cat_slider"];
                    $ct_name  = $row["cat_name"];
             //}   dont close here
        ?>
        ...
        <?php }} else { ?>//close here
in PHP
 
0
 

Hello the valuies are not echoing when I am out side the loop

<?php 
            if(isset($_GET["catid"])) {
                $catid = $_GET["catid"];
                $query_cat = mysqli_query($connection, "SELECT * FROM category WHERE cat_name='$catid'");
                while($row = mysqli_fetch_assoc($query_cat)) {
                    $h1       = $row["h1"];
                    $h2       = $row["h2"];
                    $span     = $row["span"];
                    $catslide = $row["cat_slider"];
                    $ct_name  = $row["cat_name"];
                }
        ?>
            <div class="col-sm-6">
                <h1><?php echo $h1; ?><span class="banner-head"><br><?php echo $h2; ?></span></h1>
                <p><?php echo $span; ?></p>
                <!--<button class="btn btn-default purple-btn" type="submit">downloads</button>-->
            </div>
            <div class="col-sm-6 banner-img">
                <img src="admin/img/postslider/<?php echo $catslide; ?>" alt="">
            </div>
        <?php } else { ?>
            <div class="col-sm-6">
                <h1>Download<span class="banner-head"><br><FREE IPHONE AND <br />ANDROID RINGTONES</span></h1>
                <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry</p>
                <!--<button class="btn btn-default purple-btn" type="submit">downloads</button>-->
            </div>
            <div class="col-sm-6 banner-img">
                <img src="images/mario-game.png" alt="">
            </div>
        <?php } ?>
in PHP
 
0
 

Hello there.. I am currently working with the referral program and I have a page wherein it displays all the personal information of a person who referred by the user login.. I have 2 functions for displaying the records.. Number 1 is just displaying the records when you go to the view page and Number 2 is a search function so you can easily see specific person you wanted to see.
The problem I encounter is, when I type in the search box, definitely my function to search is the one who responsible for displaying some specific records.. I add pagination so that if the record is more than 10, User can still able to view the other records by clicking page 2 but the problem is when I click the page 2 or search result page pagination. The records didn't display on page 2 and its pagination change into the original once I click page2 or the next and previous button` Here is my forum for search

<!-- Here goes the Search Area -->
        <div class="twelve columns">
            <div class="search">
                <div class="searchbox">
                    <div id="form-container"> 
                            <div id="searchtext">
                            <form name="formSearch" method="GET" action="view_referral.php" >
                            <button class="gobtn">Search</button>
                            <input type = "text" id="s" name="searchField" size="25" placeholder="Search referrals...">
                            <input type ="submit" name="searchButton" value="Search" style="display:none;">


                        </form>
                            </div>
                    </div>
                </div>
            </div>
        </div>



<!-- Here the Main Content goes -->
            <div class="twelve columns">
                <div class="content">
                    <span class="referralstatus">
                        <div class="totalreferral">
                            Total referrals<p><?php include('../function/func_countTotalReferredLeads.php');?></p>
                        </div>
                        <div class="totalhires">
                            Total Hires<p><?php include('../function/func_countHiredReferrals.php');?></p>
                        </div>
                        <div class="failed">
                            Failed<p><?php include('../function/func_countFailedReferrals.php');?></p>
                        </div>
                    </span>

                    <span class="profile">
                            <div class="refereeprofile">
                            <p align="center" class="refereetitle">REFERRAL INFORMATION</p>
                                <div class="employeeinfo">
                                    <div class="empn">
                                        <p align="left" class="employeename"><strong>Employee ID:<span class="empnn"><?php echo $empid; ?></span></p>
                                    </div>
                                    <div class="empid">
                                        <p align="left" class="employeeid"><strong>Employee Name:<span class="empdd"><?php echo $firstname .' '. $lastname;?></span></p>
                                    </div>
                                </div>



                                <div class="accessinfo">
                                    <div class="accd">
                                        <p align="left" class="accessdate"><strong>Access Date:  <?php echo $current_date;?></p>
                                    </div>
                                    <div class="acct">
                                        <p align="left" class="accesstime"><strong>Access Time: <?php echo $current_time;?></p>
                                    </div>
                                </div>
                            </div>

                            <div class="referentprofile"> 
                                <p>List of Referrals</p>
                                <table class="u-full-width">
                                    <tr>
                                    <td><strong>Lead No.<strong></td>
                                    <td><strong>Referral Name</strong></td>
                                    <td><strong>Date Referred</strong></td>
                                    <td><strong>Mobile Number</strong></td>
                                    <td><strong>Email Address</strong></td>
                                    <td><strong>Call Status</strong></td>
                                    <td><strong>Application Status</strong></td>
                                    </tr>
                                <?php

                            $_SESSION['SESS_PAGE'] = $_SERVER['PHP_SELF'];

                            // Change this during actual system run
                            if (empty($_GET['searchField'])){
                            include('../function/func_testPopulateLeads.php');
                                    }
                                    else {
                                        include('../function/func_testSearchByName.php');
                                        } 

                            ?>

                        </table>
                                </div>
                            <center>
                            <div style="text-align: center;">
                        <?php 
                        include('../function/func_pagination_new.php'); 
                        ?>
                        <?=$pagination?>
                    </div>
                    </center>    
                    </span>
                </div>
            </div>

        <!-- Here the Reminder goes -->
        <center>
            <div class="recordshown">

                <div class="twelve columns"> 

                    <p align="justify">
                    <?php echo 'Total Records Shown: ' . $_POST['data_num_row']; ?>  *** If you know any information from above that needs to be corrected, please contact us.</p>
                    <?php

                    $total_rows = $_SESSION['SESS_QRYTOTALROWS'];   
                    $data_num = $_POST['data_num_row'];
                if($data_num == 0)
                    {
                    echo '<div id="result">Message: No Record/s Found!</div>';
                    }
                elseif ($total_rows != 0)
                    {
                    echo '<div id="result">End of Results from Current Query...</div>';
                    } 
                elseif($data_num != 0)
                    {
                    echo '<div id="result">End of Results from Current Query...</div>';
                }                                   
                elseif ($total_rows > 15)                   
                    {
                    echo $pager->renderFullNav();
                    }
                else
                    {
                    echo '<div id="result">Message: No Record/s Found!</div>';
                    echo '<div id="result">*End of Result...</div>';
                    }
                ?>

                </div>
            </div>
            </center>

Here is my pagination

<?php
/* Setup page vars for display. */
    if ($page == 0) $page = 1;                  //if no page var is given, default to 1.
    $prev = $page - 1;                          //previous page is page - 1
    $next = $page + 1;                          //next page is page + 1
    $lastpage = ceil($total_pages/$limit);      //lastpage is = total pages / items per page, rounded up.
    $lpm1 = $lastpage - 1;  
                        //last page minus 1
    /*
        Now we apply our rules and draw the pagination object. 
        We're actually saving the code to a variable in case we want to draw it more than once.
    */
        $pagination = "";
        if($lastpage > 1)
        {   
            $pagination .= "<div class=\"pagination\">";
        //previous buttons
            if ($page > 1) 
                $pagination.= "<a class='buttons' href=\"$targetpage?page=$prev\">previous</a>";
            else
                //$pagination.= "<a class='disabled'><buttons disabled>previous</buttons></a>"; 
                $pagination.= "<a class='buttons'>previous</a>";

        //pages 
        if ($lastpage < 4 + ($adjacents * 2))    //not enough pages to bother breaking it up
        {   
            for ($counter = 1; $counter <= $lastpage; $counter++)
            {
                if ($counter == $page)
                    $pagination.= "<a class='current'><buttons style='background-color:#CEF6F5'>$counter</buttons></a>";
                else
                    $pagination.= "<a class='buttons' href=\"$targetpage?page=$counter\">$counter</a>";                   
            }
        }
        elseif($lastpage > 1 + ($adjacents * 2))    //enough pages to hide some
        {
            //close to beginning; only hide later pages
            if($page < 1 + ($adjacents * 2))     
            {
                for ($counter = 1; $counter < 3 + ($adjacents * 2); $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<a class='current'><buttons style='background-color:#CEF6F5'>$counter</buttons></a>";
                    else
                        $pagination.= "<a class='buttons' href=\"$targetpage?page=$counter\">$counter</a>";                   
                }
                $pagination.= "...";
                //$pagination.= "<a class='buttons' href=\"$targetpage?page=$lpm1\">$lpm1</a>";
                $pagination.= "<a class='buttons' href=\"$targetpage?page=$lastpage\">$lastpage</a>";     
            }
            //in middle; hide some front and some back
            elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
            {
                $pagination.= "<a class='buttons' href=\"$targetpage?page=1\"> 1 </a>";
                //$pagination.= "<a class='buttons' href=\"$targetpage?page=2\"> 2 </a>";
                $pagination.= "...";
                for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<a class='current'><buttons style='background-color:#CEF6F5'>$counter</buttons></a>";
                    else
                        $pagination.= "<a class='buttons' href=\"$targetpage?page=$counter\">$counter</a>";                   
                }
                $pagination.= "...";
                //$pagination.= "<a class='buttons' href=\"$targetpage?page=$lpm1\">$lpm1</a>";
                $pagination.= "<a class='buttons' href=\"$targetpage?page=$lastpage\">$lastpage</a>";     
            }
            //close to end; only hide early pages
            else
            {
                $pagination.= "<a class='buttons' href=\"$targetpage?page=1\">1</a>";
                //$pagination.= "<a class='buttons' href=\"$targetpage?page=2\">2</a>";
                $pagination.= "...";
                for ($counter = $lastpage - (2 + ($adjacents * 1)); $counter <= $lastpage; $counter++)
                {
                    if ($counter == $page)
                        $pagination.= "<a class='current'><buttons style='background-color:#CEF6F5'>$counter</buttons></a>";
                    else
                        $pagination.= "<a class='buttons' href=\"$targetpage?page=$counter\">$counter</a>";                   
                }
            }
        }

        //next buttons
        if ($page < $counter - 1) 
            $pagination.= "<a class='buttons' href=\"$targetpage?page=$next\">next</a>";
        else
            $pagination.= "<a class='buttons'>next</a>";
        $pagination.= "</div>\n";        
    }


    ?>

Here is my function searching specific name

<?php

        Place code to connect to your DB here.
    */
include('../include/dbconnection.php'); // include your code to connect to DB.


$firstname = $_SESSION['SESS_FIRSTNAME'];
$lastname = $_SESSION['SESS_LASTNAME'];
$bdate= $_SESSION['SESS_BDAY'];

$tbl_name="vtiger_leaddetails"; //your table name
// How many adjacent pages should be shown on each side?
$adjacents = 1;

    /* 
       First get total number of rows in data table. 
       If you have a WHERE clause in your query, make sure you mirror it here.
    */
 $query1 = "SELECT COUNT(*) as num FROM $tbl_name INNER JOIN 
       vtiger_leadscf
       ON vtiger_leaddetails.leadid = vtiger_leadscf.leadid
       INNER JOIN vtiger_leadaddress
       ON vtiger_leadaddress.leadaddressid = vtiger_leadscf.leadid
       INNER JOIN vtiger_crmentity
       ON vtiger_crmentity.crmid = vtiger_leadaddress.leadaddressid
       WHERE 
      (CONCAT(vtiger_leaddetails.firstname, ' ', vtiger_leaddetails.lastname) LIKE '%" . $_GET['searchField'] ."%' 
        AND vtiger_leadscf.cf_823 = '".$firstname."'
        AND vtiger_leadscf.cf_825 = '".$lastname."'
        AND vtiger_leadscf.cf_1057 = '".$bdate."'
        AND vtiger_crmentity.deleted <> 1
        AND vtiger_leadscf.cf_1039 is null
        )
ORDER BY
    vtiger_leadscf.cf_831 DESC
    " ;

$total_pages = mysql_fetch_array(mysql_query($query1));
$total_pages = $total_pages[num];

 $_SESSION['SESS_QRYTOTALROWS']=$total_pages;

/* Setup vars for query. */
    $targetpage = $_SESSION['SESS_PAGE'];   //your file name  (the name of this file)
    $limit = 8;                                 //how many items to show per page
    $page = $_GET['page'];
    if($page) 
        $start = ($page - 1) * $limit;          //first item to display on this page
    else
        $start = 0;     

$query = 
"SELECT 
    vtiger_leaddetails.lead_no,
    vtiger_leaddetails.firstname,
    vtiger_leadscf.cf_779,
    vtiger_leaddetails.lastname,
    vtiger_leadscf.cf_831,
    vtiger_leadaddress.mobile,
    vtiger_leaddetails.email,
    vtiger_leadscf.cf_885,
    vtiger_leaddetails.leadstatus
FROM 
    vtiger_leaddetails 
INNER JOIN 
    vtiger_leadscf
ON 
    vtiger_leaddetails.leadid = vtiger_leadscf.leadid
INNER JOIN 
    vtiger_leadaddress
ON 
    vtiger_leadaddress.leadaddressid = vtiger_leadscf.leadid
INNER JOIN vtiger_crmentity
ON vtiger_crmentity.crmid = vtiger_leadaddress.leadaddressid
WHERE 

     (CONCAT(vtiger_leaddetails.firstname, ' ', vtiger_leaddetails.lastname) LIKE '%" . $_GET['searchField'] ."%' 
    AND vtiger_leadscf.cf_823 = '".$firstname."'
    AND vtiger_leadscf.cf_825 = '".$lastname."'
    AND vtiger_leadscf.cf_1057 = '".$bdate."'
    AND vtiger_crmentity.deleted <> 1
    AND vtiger_leadscf.cf_1039 is null

    )

ORDER BY
    vtiger_leadscf.cf_831 DESC

LIMIT $start, $limit
" ;


$result = mysql_query($query)or die(mysql_error());
$_POST['data_num_row']=  mysql_num_rows($result);
while($row = mysql_fetch_assoc($result)) {
    $td_leadno = $row['lead_no'];
    $td_reffname = $row['firstname'];
    $td_refmname = $row['cf_779'];
    $td_reflname= $row['lastname'];
    $td_dateref = $row['cf_831'];
    $td_mobile = $row['mobile'];
    $td_email = $row['email'];
    $td_callstatus = $row['cf_885'];
    $td_leadstatus = $row['leadstatus'];

    echo '
    <tbody>
    <td>'.$td_leadno.'</td>
    <td>'.$td_reffname.' '.$td_refmname.' '.$td_reflname.'</td>
    <td>'.$td_dateref.'</td>
    <td>'.$td_mobile.'</td>
    <td>'.$td_email.'</td>
    <td>'.$td_callstatus.'</td>
    <td>'.$td_leadstatus.'</td>
    </tbody>
    ';
}
    ?>

The problem occurs in pagination when I type some specific names in the search box and for example if this name has more than 10 records, it should definitely have a pagination.. Can someone help me why when I type in the search box and for example it has 50 records. When I click the page 2 or next button. The records won't display and the pagination change to original output of it

in PHP
 
0
 

I created an add to cart function but not working properly
on submit i see these errors on the place of product details

Notice: Undefined variable: product_id in C:\wamp\www\connectdemo\product_details.php on line 218

etc etc....

product_details.php

     <?php
    session_start();    
    include_once("includes/layout/header.php");
    include_once("includes/connection.php");
    include_once("includes/functions.php");

    if(isset($_POST["addtocart"])) {
        $pid        = $_POST["productid"];
        $prod_name  = $_POST["productname"];
        $prod_price = $_POST["productprice"];

        if(isset($_POST['command']) == 'add' && $_POST['productid']>0 ) {
            $pid=$_POST['productid'];
            echo addtocart($pid,1, $prod_name, $prod_price);
            //exit();
        }
    }

?>

functions.php

    function addtocart($pid,$q,$pname,$pprice){
            if($pid<1 or $q<1) return;

    if(is_array($_SESSION['cart'])){
        if(product_exists($pid)) return;
        $max=count($_SESSION['cart']);
        $_SESSION['cart'][$max]['productid']=$pid;
        $_SESSION['cart'][$max]['qty']=$q;
    }
    else{
        $_SESSION['cart']=array();
        $_SESSION['cart'][0]['productid']=$pid;
        $_SESSION['cart'][0]['qty']=$q;
    }

    header("location:cart.php?pname=$pname&price=$pprice");
}
Re: in PHP
 
1
 

Depending on what your password requirements are and what your approach is. Once you hash a password the hash will contain only database safe characters. I would expect you do not need so much a filter but a password quality checker.

Re: in PHP
 
1
 

There seem to be no syntax errors. Why do you assume there is an error? Do you get any messages? Is the result not what you expected? What is different from what you expected?

in PHP
 
0
 

i want to know the error in this code

<?php

$firstname = $_POST    ['firstname'];
$lastname  = $_POST    ['lastname'];
$pass1     = md5($_POST['pass1']);
$pass2     = md5($_POST['pass2']);
$email     = $_POST    ['email'];

// filters name 
function filtername ($field) {
    $field = filter_var(trim($field), FILTER_SANITIZE_STRING);
    if (filter_var($field, FILTER_VALIDATE_REGEXP, array ("options"=> array ("regexp"=>"/^[Z-zA-Z\s]+/")))) {
        return $field;
    } else {
        return FALSE;
    }
}

// filters pass1 
function filterpass ($field) {
    $field = array('min_range' => 8,);
    if ($field < $min_range) {
        echo "password is mine range";
        return FALSE;
    } else {
        return $field;
    }
}

// filters email 
function filteremail ($field) {
    $field = filter_var(trim($field), FILTER_SANITIZE_EMAIL);
    if (filter_var($field, FILTER_VALIDATE_EMAIL)) {
        return $field;
    } else {
        return FALSE;
    }
}

/*
 * empty valedate input
 * fistname
 * lastname
 * pass1
 * pass2
 * email
 */

 $Errname = $Errpassword = $Erremail = "";
 $name = $password = $Email ="";

 if ($_SERVER ["REQUEST_METHOD"] == "POST") {

     // empty name 1
     if (empty ($firstname)) {
        echo $Errname = "sorry the firstname is empty"."<br />";
     } else {
         $name = filtername($firstname);
         if ($name == FALSE) {
             echo $Errname = "OOPS the valedate is false"."<br />";
         }
     }

     // empty name 2
     if (empty ($lastname)) {
        echo $Errname = "sorry the last name is emty"."<br />";
     } else {
         $name = filtername($lastname);
         if ($name == FALSE) {
             echo $Errname = "OPPS the valdeate last name is false"."<br />";
         }
     }

     // empty pass 1
     if (empty ($pass1)) {
        echo  "sorry the password is empty"."<br />";
     } 


     // empty pass 2
     if (empty ($pass2)) {
        echo "sorry the password is empty"."<br />";
     } 


     // empty email
     if (empty ($email)) {
        echo $Erremail = "sorry the Email is empty"."<br />";
     } else {
         $Email = filteremail($email);
         if ($Email == FALSE) {
             echo $Erremail = "OOPS the valseate email is false"."<br />";
         }
     }

     // check pass1 & pass2
     if ($pass1 !== $pass2) {
        echo "sorry the pass1 != pass2 ";
     }

 }

?>
in PHP
 
0
 

can i get some help with installing solve media captcha in yourls?

here is the guide for solvemedia, http://wsnippets.com/integrate-solve-media-captcha-php/

YOURLS blog on how to add recaptcha http://blog.yourls.org/tag/captcha/

what I've done so far is put the solvemedia scriptline in place where it tells you to put the same thing for recaptcha.
http://blog.yourls.org/wp-content/uploads/2015/05/tutorial1.png

instead i put <script type="text/javascript"
src="http://api.solvemedia.com/papi/challenge.script?k=your_challenge_key">
</script> on that line.

after that i included solvemedialib.php in place of captcha.php in their tutorial.

yourls here
https://github.com/YOURLS/YOURLS

i renamed sample-public-front-page.txt to index.php

the call to the function that shows the form and button is in /includes/functions-html.php

Re: in PHP
 
0
 

Short Answer: NO.
Long Answer: HTML is markup language and not programming language. Learn C/C++, Java, Python, C# et al to Program to USB. You need a desktop based programming language!

Re: in PHP
 
0
 

While this does not solve your question, compressing the base64 string might reduce errors caused by timeout of big files transfer.
Note that because base64 is string then your problem isn't JSON but how to reliably post big data!

That being said, make sure that your server supports image data max size limit. I would accept json field telling me of data size and send error if that size exceeds my limit.

http://stackoverflow.com/questions/22329481/compressing-base64-data-uri-images

PHP Tag Cloud