Php Script Download

  

Some scripts have demo facility to test how it works. Picture Gallery script Create gallery and Upload images. Site Admin can manage galleries and photos Plus mysqladmin script View database, table, structure, records etc and delete table or drop table by using this simple PHP – PDO script Newsletter management script Subscribing confirming. Download the FREE PHP scripts listed below along with the full source codes and customize them so that they serve you best. Post your comments about the scripts, share them with other developers or suggest a PHP script for inclusion into our FREE library. File Upload and Download with PHP. In This Tutorial We learn How to process Upload and Download system using PHP and MySQL. Some observationsscript time limit and memory limit to upload large file. PHP Scripts Marketplace is a professional script development firm offering brand free ready made PHP scripts with 50% discount offer including 100% reselling rights. Get over 4,100 PHP Scripts and Codes on CodeCanyon. Buy PHP Script & PHP Code from only $12 on CodeCanyon. Save time, buy Code! 5 Steps to Create Simple Secure Login Script in PHP and MySql. This is a Simple to Advanced Login Script System using PHP and MySQL. In this script, a form will be displayed with two fields, username, and password. When the user is submitting with valid username and password, then he can access authenticated page. I'm making a simple download script, where my users can download their own images etc. But I'm having some weird problem. When I've downloaded the file, it's having the contents from my index.php.

28

This is a Simple to Advanced Login Script System using PHP and MySQL. In this script, a form will be displayed with two fields, username, and password. When the user is submitting with valid username and password, then he can access authenticated page. Otherwise, users again have to fill in the form. This is a continuation from the last article Simple User Registration Script in PHP and MySql. If you want to follow next article these are the links.
Here you will learn about Simple Login System & also an advanced system. Simple Login Script System is targetted towards beginners and helps you to learn the script easily. Advanced Login Script System is more secure than the simple Login Script and it is targetted towards intermediate, advanced users even beginners also can easily understand it. I’ve also created video tutorials for both the Login Systems. And also I’ve created a video course, I highly encourage you to join my course. So that, you will learn more advanced topics in user login & registration system.

(i). Simple User Login Script in PHP & MySQL
(ii). Advanced User Login, Registration, Forgot(reset) Password in PHP & MySQL

(i). Steps to create Simple Login Script in PHP and MySQL

  1. First step we will connect to the database.
  2. Then we will select the database.
  3. We are checking, if the form is submitted or not. In this step we have two logic’s.
    • What if the form is submitted.
      1. If the form is submitted, we are assigning the posted values to variables and checking the values are existing in the database or not.
      2. If the values submitted in the form and the values in the database are equal, then we will create a session for the user.
      3. If the values are not equal then it will display an error message.
      4. And then we checks for the session, if the session exists we will great him with the username, otherwise the form will be displayed.
    • What if not the form is submitted.
      1. When the user comes first time, he will be displayed with a simple form.
      2. User Name, Password and a submit button.

Below is the Video on Simple User Login Registration Script in PHP

Subscribe on Youtute

Do you want to Build Secure Members Area for your Website?

Marathi Font. At our portal we provide all type of Marathi font to download at free. User can also download Marathi keyboard layout used in Marathi Typing. Free download Shivaji font, Kiran font, Kruti Dev font, Saras, Lekhani, Liza, Lok, Maya, Nutan, Priya, Sharda, Richa etc font free. Shivaji font for microsoft word. How to download and install Shivaji font – Marathi font July 17, 2010 June 2, 2012 admin Marathi font, marathi typing 138 Comments Many of us want to type in marathi in MS word, Wordpad, Notepad or any windows application where we need Marathi font. Shivaji01 Font Download - free fonts download - free fonts online. Download Free Fonts. Collection of most popular free to download fonts for Windows and Mac. This free fonts collection also offers useful content and a huge collection of TrueType face and OpenType font families categorized in alphabetical order.

I've good News for you! Created a Video Course with 5 Hours of Content to create secure members area section

If you are already following from previous article, you should already have database table created. If you don’t have create the table.

2
4
6
8
10
<h2 class='form-signin-heading'>Please Login</h2>
<span class='input-group-addon'id='basic-addon1'>@</span>
<input type='text'name='username'class='form-control'placeholder='Username'required>
<label for='inputPassword'class='sr-only'>Password</label>
<input type='password'name='password'id='inputPassword'class='form-control'placeholder='Password'required>
<button class='btn btn-lg btn-primary btn-block'type='submit'>Login</button>
<a class='btn btn-lg btn-primary btn-block'href='register.php'>Register</a>

3. Adding styles to Login Form

And the styles for the form, if you have added styles in previous article. Skip this step.

2
4
6
8
10
<link rel='stylesheet'href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css' >
<!-- Optional theme -->
<link rel='stylesheet'href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css' >
<link rel='stylesheet'href='styles.css' >
<!-- Latest compiled and minified JavaScript -->
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>
2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
padding-top:40px;
background-color:#eee;
max-width:330px;
margin:0auto;
.form-signin .form-signin-heading,
margin-bottom:10px;
.form-signin .checkbox {
}
position:relative;
-webkit-box-sizing:border-box;
box-sizing:border-box;
font-size:16px;
.form-signin .form-control:focus {
}
margin-bottom:-1px;
border-bottom-left-radius:0;
.form-signin input[type='password'] {
border-top-left-radius:0;
}

If you are following from previous user registration article, no need to create this file. Other wise create connect.php file.

2
4
6
8
$connection=mysqli_connect('localhost','root','Rvm@i[9)0?~=');
die('Database Connection Failed'.mysqli_error($connection));
$select_db=mysqli_select_db($connection,'test');
die('Database Selection Failed'.mysqli_error($connection));

5. PHP Logic for User Login

And this is the PHP code for logging in user

2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
session_start();
//3. If the form is submitted or not.
if(isset($_POST['username'])andisset($_POST['password'])){
$username=$_POST['username'];
//3.1.2 Checking the values are existing in the database or not
$query='SELECT * FROM `user` WHERE username='$username' and password='$password';
$result=mysqli_query($connection,$query)ordie(mysqli_error($connection));
//3.1.2 If the posted values are equal to the database values, then session will be created for the user.
$_SESSION['username']=$username;
//3.1.3 If the login credentials doesn't match, he will be shown with an error message.
}
//3.1.4 if the user is logged in Greets the user with message
$username=$_SESSION['username'];
';
';
//3.2 When the user visits the page first time, simple login form will be displayed.

Logout.php

2
4
session_start();
header('Location: login.php');

Complete Code of login.php

2
4
6
8
10
12
14
16
18
20
22
24
26
28
30
32
34
36
38
40
42
44
46
48
50
52
54
56
58
60
62
64
66
68
70
session_start();
//3. If the form is submitted or not.
if(isset($_POST['username'])andisset($_POST['password'])){
$username=$_POST['username'];
//3.1.2 Checking the values are existing in the database or not
$query='SELECT * FROM `user` WHERE username='$username' and password='$password';
$result=mysqli_query($connection,$query)ordie(mysqli_error($connection));
//3.1.2 If the posted values are equal to the database values, then session will be created for the user.
$_SESSION['username']=$username;
//3.1.3 If the login credentials doesn't match, he will be shown with an error message.
}
//3.1.4 if the user is logged in Greets the user with message
$username=$_SESSION['username'];
';
';
//3.2 When the user visits the page first time, simple login form will be displayed.
<html>
<title>User Login Using PHP&MySQL</title>
<!--Latest compiled andminified CSS-->
<link rel='stylesheet'href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<!--Optional theme-->
<link rel='stylesheet'href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css'>
<link rel='stylesheet'href='styles.css'>
<!--LatestcompiledandminifiedJavaScript-->
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js'></script>
<body>
<div class='container'>
<?phpif(isset($fmsg)){?><div class='alert alert-danger'role='alert'><?phpecho$fmsg;?></div><?php}?>
<div class='input-group'>
<span class='input-group-addon'id='basic-addon1'>@</span>
<input type='text'name='username'class='form-control'placeholder='Username'required>
<label for='inputPassword'class='sr-only'>Password</label>
<input type='password'name='password'id='inputPassword'class='form-control'placeholder='Password'required>
<button class='btn btn-lg btn-primary btn-block'type='submit'>Login</button>
<aclass='btn btn-lg btn-primary btn-block'href='register.php'>Register</a>
</div>
</body>
</html>

If you want to learn other things you can read other posts – registration, login, user login with activation check, and sending forgotten password by email, Check Username Availability .

Sunfire View and Download Pontiac 2005 Sunfire owner's manual online. 2005 Sunfire Automobile pdf manual download.

(ii). Steps to create Advanced Login Script System in PHP and MySQL

In the above simple login script, we have some flaws. That is I’m using plain text passwords and it is easy to do SQL injections and lot more. Because that is targetted to beginners for learning purpose.

Here in this advanced login system, you will learn a lot of advanced things and some of the features are below.

  • Login with User Name or E-Mail
  • Securing Login from SQL injections
  • Encrypting Users Password
  • Login using PHP Sessions
  • Only Active Users Can Login

In this script we will start by checking the session, if the user already logged in he will be redirected to index.php page that is members area. After the form submission, we check post superglobal isset and not empty. In this code, I’m using DB connection from above code, database table and HTML form from our above code.

Here I’m just working on improving PHP logic from above code.

Below is the Video on Advanced & Secure PHP User Login Registration Script With All Features

Subscribe on Youtute

Do you want to Build Secure Members Area for your Website?

I've good News for you! Created a Video Course with 5 Hours of Content to create secure members area section

If the post superglobal is set and not empty, if it’s true I’m assigning the submitted values to variables using this code and encrypting password to md5 hashing instead of plain text password.

2
4
$username=mysqli_real_escape_string($connection,$_POST['username']);
}

After that, I’m writing an SQL query to check the user details in database tables with submitted user information. Executing the query and also counting the number of rows in result set. If the number of rows is equal to one then we will set the session and redirect the user to members area page. Otherwise, we will display an error message. I’m already displaying these messages in above the form HTML code, if you are following from above you will already have it.

2
4
6
8
10
$sql='SELECT * FROM `user` WHERE username='$username' AND password='$password';
$count=mysqli_num_rows($res);
if($count1){
header('location: members/index.php');
$fmsg='User does not exist';

And next important cocept is user will be able to login with username or email. For that I’ll modify the SQL query little bit. So, that we will check the submitted value if it’s email we will check it with email column. If it’s not email we will check it in username column. And I’m creating SQL query over couple of conditions and statments.

2
4
6
if(filter_var($username,FILTER_VALIDATE_EMAIL)){
}else{
}

Checking the user, if his account is activated then only we will allow hime to login otherwise he won’t be able to login. For that I’m using active column, if the user activates his account by verifying his email. Then only his account status becomes active, that means active column becomes to 1.

Here is the improved code with above discussed condition.

2
4
6
if(filter_var($username,FILTER_VALIDATE_EMAIL)){
}else{
}

Complete code of Advanced Login Script System in PHP & MySQL

Php Script Download Database

2
4
6
8
10
12
14
16
18
20
$username=mysqli_real_escape_string($connection,$_POST['username']);
$sql='SELECT * FROM `user` WHERE ';
$sql.='email='$username';
$sql.='username='$username';
$sql.=' AND password='$password' AND active=1';
$res=mysqli_query($connection,$sql);
$_SESSION['username']=$username;
}else{
}

Next Steps After User Login

Password Encryption

Instead of md5 hashing algorithm, use password_verify PHP function in conjection with password_hash PHP fucntion. This password_hash should be used while registering users and while login you can use password_verify PHP function.

I hope this article helped you to learn user login using PHP and MySQL . To get latest news and updates follow us on twitter & facebook, subscribe to newsletter. If you have any feedback please let us know by using comment form.

Do you want to Build Secure Members Area for your Website?

I've good News for you! Created a Video Course with 5 Hours of Content to create secure members area section

simple login form in phpphp login scriptsimple login form in php with mysql databasesimple php login scriptsimple login page in phpsimple login phplogin php mysqlphp login codephp simple loginphp login form with mysql database code

Enter Your Email Address To Download Now


Shares

Download User Login RegistrationScript For Free

Enter Your Email Address To Download Now

Active5 years, 2 months ago

I'm making a simple download script, where my users can download their own images etc.

But I'm having some weird problem.

When I've downloaded the file, it's having the contents from my index.php file no matter what filetype I've downloaded. My code is like so:

$r is the result from my database, where I've stored size, type, path etc. when the file is uploaded.

UPDATE

Php script download file from url

When I'm uploading and downloading *.pdf files it's working with success. But when I'm trying to download *.zip and text/rtf, text/plain it's acting weird.

By weird I mean: It downloads the full index.php file, with the downloaded file contents inside of it.

ANSWER

I copied this from http://php.net/manual/en/function.readfile.php and it's working now. It seems that : ob_clean(); did the trick! Thanks for the help everyone.

Sendmail Php Script Download

skolind
skolindskolind
9446 gold badges22 silver badges44 bronze badges
Database

2 Answers

Try this function , or implement these headers to your code

Free Php Script Download Manager

SagarPPanchal
6,7786 gold badges29 silver badges54 bronze badges
Erdinç ÇorbacıErdinç Çorbacı

I copied this from http://php.net/manual/en/function.readfile.php and it works now. ob_clean(); did the trick.

skolindskolind

Php Download Script W3schools

9446 gold badges22 silver badges44 bronze badges

Not the answer you're looking for? Browse other questions tagged php or ask your own question.