PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.

Share tech news, updates, or what's on your mind.

Sign up to Post

I have a simple PHP password application that checks for strength of a password before changing it.  In the link below I am trying to use the part that checks that the password is not a dictionary word.  The password I'm checking doesn't seem like it should be a dictionary word, but I keep getting that it is.  The link is:  

Test password is MzRZ=2wdu;x?NLk

Code snippet I'm using is:

 $word_file= '/usr/share/dict/words';
   $lc_pass = strtolower($newPass);
   $denum_pass = strtr($lc_pass,'5301!','seoll');

   if (is_readable($word_file)) {
        if ($fh = fopen($word_file,'r')) {
            $found = false;
            while (! ($found || feof($fh))) {
                $word = preg_quote(trim(strtolower(fgets($fh,1024))),'/');
                if (preg_match("/$word/",$lc_pass) ||
                 preg_match("/$word/",$denum_pass)) {
                    $found = true;
            if ($found) {
                $message[] = "Your new password is based on a dictionary word.";
                return false;

Open in new window

Free Tool: Site Down Detector
LVL 12
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hello. I am trying to add information into a database  via a php form page and then redirect onto another page after the submit button has been pressed and the table populated.

This works as intended when I am testing on my local server but when I try it on a live server I get the following errors (I turned error reporting on) and the page where it's supposed to be redirected to (welcome.php) doesn't appear.  However, the sql table (in the live server) is being populated with the form info.  


Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/orango5/public_html/form_studentjoin.php:1) in /home/orango5/public_html/private/initialize.php on line 6

The code on initilize.php line 6 is:


Open in new window

Warning: Cannot modify header information - headers already sent by (output started at /home/orango5/public_html/form_studentjoin.php:1) in /home/orango5/public_html/form_studentjoin.php on line 41

The code on studentjoin.php line 41 is:
header('Location: welcome.php?id=' . $new_id);

Open in new window

I considered using something else for the redirect -
echo "<script>location.href='welcome.php';</script>";
but I want to be able to pass through the id am not sure how to do this with that javascript.

If it helps the code which I am using for the form (form_studentjoin.php) is below:

<?php require_once('private/initialize.php'); ?>

Open in new window

I have a site built on PHP/MySql using windows IIS.
This site is using basic authentication linked to Active Directory and it's also using https.
I've been asked to change it to digest authentication but it creates a big problem with Chrome.
Chrome keeps asking for login/password for every bit (images, iframes) of the page.
It works well on IE.
How do I solve this problem?
Many thanks
I have this function:

	public function action_login()
		// Already logged in
		Auth::check() and Response::redirect('admin');

		$val = Validation::forge();

		if (Input::method() == 'POST')
			$val->add('email', 'Email or Username')
			$val->add('password', 'Password')

			if ($val->run())
				if ( ! Auth::check())
					if (Auth::login(Input::post('email'), Input::post('password')))
						// assign the user id that lasted updated this record
						foreach (\Auth::verified() as $driver)
							if (($id = $driver->get_user_id()) !== false)
								// credentials ok, go right in
								$current_user = Model\Auth_User::find($id[1]);
								Session::set_flash('success', e('Welcome, '.$current_user->username));
						$this->template->set_global('login_error', 'Login failed!');
					$this->template->set_global('login_error', 'Already logged in!');

		$this->template->title = 'Login';
		$this->template->content = View::forge('admin/login', array('val' => $val), false);

Open in new window

Right now this wont let me acess any pages unles i am in a logged in state. however i want to build a cron that would hit a page within the admin but i cant do so since it will need an email and password, is there anything i can add so that if a user hits this page:

it will be accessible without a username or password
      // connect to database
$db = mysqli_connect('localhost', 'root', '12345', 'hotel booking');

// variable declaration
$username = "";
$Email    = "";
$Phonenumber = "";
$country = "";
$bookdate ="";
$meals ="";
$numberofguest ="";
$Room ="";
$Foodmenu ="";
$errors = array();

// call the register() function if register_btn is clicked
if (isset($_POST['register_btn'])) {

function register(){
      // call these variables with the global keyword to make them available in function
      global $db, $errors, $username, $Email , $Phonenumber , $country, $bookdate, $meals, $numberofguest, $Room, $Foodmenu;

      // receive all input values from the form. Call the e() function
    // defined below to escape form values

      $username    = e($_POST['username']);
      $Email       = e($_POST['Email']);
      $Phonenumber = e($_POST['Phonenumber']);
      $country     = e($_POST['country']);
    $bookdate    = e($_POST['bookdate  ']);
      $meals       = e($_POST['meals']);
      $numberofguest = e($_POST['numberofguest']);
      $Room = e($_POST['Room']);
      $Foodmenu = e($_POST['Food menu']);
      // form validation: ensure that the form is correctly filled
      if (empty($username)) {
            array_push($errors, "username is required");
      if (empty($Email)) {
            array_push($errors, "Email is required");
      if (empty($Phonenumber)) {
            array_push($errors, "Phonenumber is required");
      if …
Next line of code is from x.php:

$note = $log_username.' posted on: <br /><a href="user.php?u='.$account_name.'#status_'.$id.'">'.$account_name.'&#39;s Profile </a>';

Open in new window

and in browser it looks like:  

AAA posted on:
BBB's Profile

What have I  add  in code above to call a function in js script when clicked on href (which is equal to BBB's Profile)?

And how to add this script  on x.php?
I am using a PHP based CMS which stores my content Pages in the MySQL Database. I have hundred's of CMS pages and it is growing. Now I want to add search feature in my website.
Instead of using MYSQL Full Text search  what are the alternative options which are easy to implement and the search results should be fast and relevant.

Note: When user search any keyword  I want to display the CMS page Title and some content in the search result page. And after user clicks on the page title, user will be redirected to that CMS page.

Looking forward for suggestions.

Here are the pop ups that i am getting, if i click Ok, i am getting like parameter incorrect.:  Here are the pop ups that i am getting, if i click Ok, i am getting like parameter incorrect.Whenever I plug in my charger, a small tap is popping continuously saying php update available, then i click OK, but it's again coming like update available. i am using Lenovo-idea pad-1470 series. can anybody help me please?
I'm interested to know what languages are the best to learn or learn more of.  
I have a pretty good understanding of PHP.  I also know some Javascript and am taking a course through Udemy to further understand it.  Right now I have time to learn/study a little.  What would be the best things to know and understand? Node, API, advanced CSS???  What are your thoughts?
i want to use rowspan in array data used to show by foreach can i use rowspan.
here it is my foreach code
      foreach($DataArray as $row) {
     echo '<tr>' ;
     foreach($row as $cell) {
     echo '<td>' . $cell . '</td>';

Open in new window

and my array is
array('state'=>'Uttrakhand','state'=>'Uttrakhand','district_name' => 'ALMORA','district_code'=>8,'block_name'=>'BHIKIYASAIN','block_id'=>47,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2),
array('state'=>'Uttrakhand','district_name'=>'ALMORA','district_code'=>8,'block_name'=>'CHAUKHUTIYA','block_id'=>48,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2),
array('state'=>'Uttrakhand','district_name'=>'ALMORA','district_code'=>8,'block_name'=>'DHAULADEVI','block_id'=>49,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2),
array('state'=>'Uttrakhand','district_name'=>'ALMORA','district_code'=>8,'block_name'=>'DWARAHAT','block_id'=>50,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2),
array('state'=>'Uttrakhand','district_name'=>'ALMORA','district_code'=>8,'block_name'=>'HAWALBAG','block_id'=>51,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2),
array('state'=>'Uttrakhand','district_name'=>'ALMORA','district_code'=>8,'block_name'=>'LAMGARAH','block_id'=>52,'school-sample' =>5,'school-acheived'=>1,'AWS-reached'=>5,'AWS-acheived'=>2),

Open in new window

Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

What is the best technology to create a new shopping website? Like JSP, bootstrap, aspx, angular, PHP etc…
i'm doing project on job portal using php and mysql. I have the module create resume and upload resume for job seekers. Is it possible for recruiters to view the created resumes like uploaded resume.
I have 11 servers... all running nginx + php7 and one load balancer (nginx as well)... how do I keep the code synced across all servers... I dont want to go in and save in each and every server the same code, what approach would be the "standard" for this? ->, etc...
I want to implement Sphinix Search in my Drupal Website. Currently I am running my drupal website on a windows Operating system and I have installed Xampp for PHP and MySQL. Currently I did not find any good step-by-step tutorial to integrate this search in PHP website on windows machine. I need autocomplete functionality and the search must work for 1 languages i.e. english and arabic.

At initial stage I will integrate this search in a simple PHP based website which has form and a textbox with search button. Ater everything works fine, I will deploy it in my Drupal website.

Looking forward for urgent help

I hav to Query a MySQL Database with a SELECT including a Stored Function.

Funktion like

CREATE DEFINER = 'root'@'localhost'
FUNCTION <DATABASE>.get_name_and_id(name varchar(32), tid INT)
  RETURNS varchar(255) CHARSET utf8

SELECT .... INTO ...

RETURN CONCAT(name, '_', tid);

Open in new window

This Function ist working very well in MySQL Console ...
Like this ...
SELECT get_name_and_id("peter", 234) AS name_id;

Open in new window

If i select with PHP7 an PDO i got an Error
Fatal error: Uncaught Error: Call to a member function fetchAll() on boolean in ...

PHP like this ...
$sql = "SELECT id, name, get_name_and_id(name, id) AS name_id from <TABLE>;";
$stmt = $this->pdo->query($sql);
$list = $stmt->fetchAll(PDO::FETCH_CLASS, $model);

Open in new window

The Model is working well ...
The Code do not generate an Error if i do this SQL Statement ...
$sql = "SELECT id, name, "AAA" AS name_id from <TABLE>;";

Open in new window

I hope anyone has an Idea ;-)

Thanx Talki
I am using next code to register on my page.  And i will also attach login code in a minute. From both of them I need to get change password "php" code.

From login php i need input password field -  logic  where i have to check my existing password and from signup php i need just  two input fields for new password and  conformation of it.

And "submit" button.

Thank you

// error_reporting(E_ALL);
//ini_set('display_errors', 1);
// If user is logged in, header them away
	header("location: message.php?msg=NO to that weenis");
// Ajax calls this NAME CHECK code to execute
	$username = preg_replace('#[^a-z0-9]#i', '', $_POST['usernamecheck']);
	$sql = "SELECT id FROM users WHERE username='$username' LIMIT 1";
    $query = mysqli_query($db_conx, $sql); 
    $uname_check = mysqli_num_rows($query);
    if (strlen($username) < 3 || strlen($username) > 16) {
	    echo '<strong style="color:#F00;">3 - 16 characters please</strong>';
	if (is_numeric($username[0])) {
	    echo '<strong style="color:#F00;">Usernames must begin with a letter aha</strong>';
    if ($uname_check < 1) {
	    echo '<strong style="color:#009900;">' . $username . ' is OK</strong>';
    } else {
	    echo '<strong style="color:#F00;">' . $username . ' is 

Open in new window

how can i set a due date from a start date coming from a database table? i'm using php
How to convert file content into byte array using php?

$content = file_get_contents($file['uri']);
$byteArr = unpack("N*", $content);

this didn't work for me.
Hi, I am trying to create a "Database" or "blog" to simply add 'comments' or 'posts' from users, but I don't want to create a database. I would prefer using something like xml, php or similar. I am using html with bootstrap. I just want the user to post a comment, and I will save it to a specified file. The information to be written and retrieved from that file would be : date, username, and comment.

I would like to save it , and retrieve it for displaying purposes only (kind of a blog)

I already have a page that sends those user comment to my EMAIL, so I have the input fields already

Tnx for any help and I am open to your suggestions on how to accomplish this task
Free Tool: Path Explorer
LVL 12
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

I embed a video inmy php page

I have this code

<div class="videoWrapper">
    <!-- Copy & Pasted from YouTube -->
    <iframe width="560" height="349" src="" frameborder="0" allowfullscreen></iframe>

.videoWrapper {
      position: relative;
      padding-bottom: 56.25%; /* 16:9 */
      padding-top: 25px;
      height: 0;
.videoWrapper iframe {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;

<script async src=""></script>

The video is embedded like this:

      <div class="videoWrapper">
    <!-- Copy & Pasted from YouTube -->
    <iframe width="560" height="349" src="" frameborder="0" allowfullscreen></iframe>

When load the page it looks ok

But inspecting the page I get this console error

unreachable code after return statement


Anf google adwords disapprives ny ad becaus the pgp pag has ann error

Any ideas?
I trade options.  At present I am entering each trade into a spreadsheet .  I can manipulate each individual trade rather easily but when I want to summarize data I have to determine each piece of data I need and what cell it is in and then manually create a summary function.  

Spreadsheets are good for certain things.  Databases are good at storing data for manipulation.

I want to store my trades in a database .  I chose MySql  because it is free.  I am using OpenOffice  calc as my spreadsheet .  I want to be able to export data from MySql  to OpenOffice  Calc .

I want to be able to create forms so I can view the data in the database .  

 I want to avoid using Microsoft products because I don't want to pay the license fees.  I am the only one who will use the data so I want to keep costs low.

From looking at many web pages I gather people are using PHP or Django to display and manipulate MySql  data and create forms.  

I am willing to spend some time to study but I am not going to be an expert programmer.  I have experience using SQL server and using SQL expressions.  I have some experience programming active server pages and ADO.

I have 2 computers both running Windows 7 pro.  They are networked together.  I plan to have one computer running MySql  and the other will be a client machine.

So what I want to do is:
Export data from MySql  to OpenOffice  Calc
Create forms so I can view data in the MySql  database
Print some reports.

I want to get a graph that displays multiple line charts using google charts, but the attached script is not rending anything. It shows blank web page.nAAT_Pole_Trend.php
I am quite new to google charts. When I do view page source I get the following below. I don't know what I am doing wrong here.

<!doctype html>
    <script src=""></script>
    <script src=""></script>
    <div id="chart" style="width: 900px; height: 500px"></div>
      google.charts.load('current', {'packages':['corechart']});
     function drawChart(){
        var data = new google.visualization.DataTable();
            data.addColumn('number','Completed Jobs');
            data.addColumn('number','Poles Received');


        var options = {
            title: 'Pole Trend - NBN QLD',
            legend: { position: 'bottom' },
            width: 900,
            height: 500,
            vAxis: {title: 'Number of Poles'},
            hAxis: {format: 'Y-m-d', …
I am creating postage labels and recording them into a pdf file using FPDF and PDF_Label - all work fine, see code sample below ...
$text = sprintf("%s\n%s\n%s\n%s %s %s\n%s", "   6         022, "Name","Address", "Location", "State", "PostCode", "Country");

As you can see, I am using sprintf to format text for the label and using Add_Label from PDF_Label class to create the label.

I would like to BOLD the "Name" portion within the sprintf, if possible. As far as I can tell this can't be done. Tried using html tags inside it - no good, just prints the tags.

Any help or suggestions appreciated.
Hi Dev Experts,

I have this problem on my application on how to create multiple canvasses. There is no problem with this but on the Fabric.js API that I used.

In my case I created a div which will be filled with images as representation for my canvasses on button click.  I also created five canvasses which visibility are hidden and  will be shown when the user click  the list of image canvas.

My problem is that how can i create or assign a new  variable to fabric.js like this if you can create only one variable for all your objects ?
var canvas = new fabric.Canvas('mycanvas');//mycanvas is an id of one canvas but must come from five canvasses

Open in new window

Thank you in advance for you help and time !!!
I'm using jRecorder to record voice with SWF. The component basicly working in PHP properly. But I should adapt this to Classic-ASP

There is buttons, when I try click to "Send Data", it sends data to "INC_AcceptFile.asp?filename=test.wav" but unfortunatelly I couldn't save the file.

jRecorder Github page:

        host : 'INC_AcceptFile.asp?filename=test.wav' ,  //replace with your server path please
        callback_started_recording:     function(){callback_started(); },
        callback_stopped_recording:     function(){callback_stopped(); },
        callback_activityLevel:          function(level){callback_activityLevel(level); },
        callback_activityTime:     function(time){callback_activityTime(time); },
        callback_finished_sending:     function(time){ callback_finished_sending() },
        swf_path : 'JS/jRecorder.swf',

Open in new window

PHP Codes (works)

         exit('No file');
       $upload_path = dirname(__FILE__). '/';
       $filename = $_REQUEST['filename'];
       $fp = fopen($upload_path."/".$filename.".wav", "wb");
       fwrite($fp, file_get_contents('php://input'));

Open in new window

My codes that I trying

set xmlhttp = Server.CreateObject("Msxml2.ServerXMLHTTP.6.0") "GET", ???? , false 
With Server.CreateObject("Adodb.Stream")
    .Type = 1 '1 for binary stream
    .Write xmlhttp.responseBody
    .SaveToFile Server.Mappath("data/hello.wav"), 2 ' 2 for overwrite
End With
set xmlhttp = nothing 

Open in new window







PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.