Archive for the ‘PHP mySQL Web Hosting’ category

Send Email from a PHP Script Using SMTP Authentication

March 30th, 2011

This post about “Sending Mail using SMTP and PHP“. Now you can send emails with SMTP authentication using this script. Every mail needed server authentication, So you have to buy mail server. It’s very useful you can implement this on your web projects.

This tutorial contains three files.

- Index.php //Run Mail Form
- SMTPconfig.php // SMTP Server Cofiguration
- SMTPClass.php // SMTP Mail Sending Class

SMTPconfig.php
You have to change SMTP server details.

<?php
//Server Address

$SmtpServer=”127.0.0.1″;
$SmtpPort=”25″; //default
$SmtpUser=”username”;
$SmtpPass=”password”;
?>

 

SMTPclass.php
SMTP mail sending class.

<?php

class SMTPClient
{

function SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body)
{

$this->SmtpServer = $SmtpServer;
$this->SmtpUser = base64_encode ($SmtpUser);
$this->SmtpPass = base64_encode ($SmtpPass);
$this->from = $from;
$this->to = $to;
$this->subject = $subject;
$this->body = $body;

if ($SmtpPort == “”)
{
$this->PortSMTP = 25;
}

else

{
$this->PortSMTP = $SmtpPort;
}
}

function SendMail ()
{
if ($SMTPIN = fsockopen ($this->SmtpServer, $this->PortSMTP))
{
fputs ($SMTPIN, “EHLO “.$HTTP_HOST.”\r\n”);
$talk["hello"] = fgets ( $SMTPIN, 1024 );
fputs($SMTPIN, “auth login\r\n”);
$talk["res"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpUser.”\r\n”);
$talk["user"]=fgets($SMTPIN,1024);
fputs($SMTPIN, $this->SmtpPass.”\r\n”);
$talk["pass"]=fgets($SMTPIN,256);
fputs ($SMTPIN, “MAIL FROM: <”.$this->from.”>\r\n”);
$talk["From"] = fgets ( $SMTPIN, 1024 );
fputs ($SMTPIN, “RCPT TO: <”.$this->to.”>\r\n”);
$talk["To"] = fgets ($SMTPIN, 1024);
fputs($SMTPIN, “DATA\r\n”);
$talk["data"]=fgets( $SMTPIN,1024 );
fputs($SMTPIN, “To: <”.$this->to.”>\r\nFrom: <”.$this->from.”>\r\nSubject:”.$this->subject.”\r\n\r\n\r\n”.$this->body.”\r\n.\r\n”);
$talk["send"]=fgets($SMTPIN,256);
//CLOSE CONNECTION AND EXIT …
fputs ($SMTPIN, “QUIT\r\n”);
fclose($SMTPIN);

//

}
return $talk;
}
}
?>

 

index.php

<?php

include(‘SMTPconfig.php’);
include(‘SMTPClass.php’);
if($_SERVER["REQUEST_METHOD"] == “POST”)
{
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['sub'];
$body = $_POST['message'];
$SMTPMail = new SMTPClient ($SmtpServer, $SmtpPort, $SmtpUser, $SmtpPass, $from, $to, $subject, $body);
$SMTPChat = $SMTPMail->SendMail();
}

?>
<form method=”post” action=”">

To:<input type=”text” name=”to” />
From :<input type=’text’ name=”from” />
Subject :<input type=’text’ name=”sub” />
Message :<textarea name=”message”></textarea>
<input type=”submit” value=” Send ” />
</form>

 

Download Source Code

 

Advice on web hosting.

February 25th, 2011

Most web hosting companies today – including ones that are ‘green’ – offer their customers unlimited bandwidth and disk space in their web hosting packages.  This helps make the choice marginally easier when you are considering the many different options available.  You would think that a package offering unlimited bandwidth and storage would cost an arm and leg every month, but actually they don’t.  This is one less thing a newer to the web hosting world can stop worrying about.  If they use a company offering unlimited bandwidth and space, they will be able to handle as much traffic as they want.

Choosing the most appropriate web hosting solution is crucial to your business and success. I would like to be more particular on choosing the most relevant web hosting service depending on your needs.

There are too many sprouting and fly-by-night web hosting providers lurking on the web so it’s very important that you know who to trust and do business with.

Part of the challenge is choosing the right web hosting package or solution that exactly fits your needs.

Among the types of web hosting include Shared Hosting, which is the most cost-effective and popular package for bloggers; Dedicated Hosting which is more suited for bigger sites and for those who want full control, more flexibility, and responsibility for their websites. VPS Hosting however offers greater power and performance. Managed Hosting is rather suited for those less technically inclined but it’s rather expensive. Reseller Hosting is good for those with the entrepreneurial spirit.

Making a wise decision can be overwhelming at times given these many options. If you are on the edge of uncertainty you can head on to web hosting review sites for added guidance. It always pays to be informed.

Concern point

Transfer speed is something else a newer to the web hosting world will need to take into consideration.  Because a single server can be the home to thousands of websites at one time, the transfer speed could be lower than what you hope for when it comes to the loading of your website.  Of course, you could pay for a dedicated server but that costs a considerable amount of money.  One option that is open to you is using a virtual private server.  A VPS offers the user the same benefits as a dedicated server but without the cost involved.  VPS dedicated servers can accommodate thousands of websites but because of the way they are set up the resources are allocated to each site without having to ‘borrow’ from another one.

Finally, you need to make sure that the web hosting package you choose can accommodate any special software you want to use.  MySQL and PHP are not supported by every company.  You need to make sure that the host can support these programs, even if it means e-mailing them before purchasing a web hosting agreement.

4 stuffs Your Web Host Doesn’t Want You to Know

February 4th, 2011

Looking for a web host for your website? Ever feel like some of the things being promised are far fetch Check this list to see if your host has done this to you! And if they have: run, don’t walk… Get far-far away! There are plenty of web hosts in the market to not waste your time and money with the bad ones.

1. WE OFFER TERABYTES OF SPACE… ALL FOR $1 … WE GUARANTEED!!

You’ve seen all the offers. Tens of thousands of gigabytes.  Thousands of terabytes.  All for just a few dollars. Think it’s too good to be true? Well, it is. How do you think the hosts afford all that space? It’s a simple trick that is known as “overselling” in the web hosting world. Hosts sell 100x-1000x more space then they actually have hoping you don’t use it. And what happens if you start using it? Well if you read their terms of service, most of these hosts control your account based on cup usage. At the same time, “file storage” isn’t allowed. So as soon as you upload more than 1 GB, or get more then a few thousand visitors on your site, you will find your site gone. Of course none of the hosts want you to know this, so they hide it in confusing fine print and terms of service agreements. I hate to say it, but mom & pop might have been right… if it’s too good to be true, it probably is a scam.

2. WE HAVE BEEN IN BUSINESS FOR DECADES.

I find it funny how several well known hosts claim to have been around for “decades”. Another one boldly states “In Business since 1988″. I hate to break it to you guys, but there wasn’t really such a thing as web hosting back then. I’ve been involved in the hosting industry almost since the beginning, and I know for a fact there weren’t any $5/mon. hosts around in the 1980′s. Before believing a hosts claim, check the who is on the domain and see when they registered it. The funny part is that most hosts that claim to be more than 10 years old haven’t been around more than a 1 year! Obviously they don’t want you to know this, so do your due diligence and make sure you don’t get scammed by a fly-by-night host.

3.  WE HAVE OUR OWN DATACENTER – THOUSANDS OF SQ FEET

Face it, no matter what web host you go to, their site has pictures of huge datacenters, thousands of servers! Unfortunately, most web hosts are just “re-sellers”. Just people with some spare time that rent some space on someone’s server for $20/mon. and try to re-sell the space to a 100+ people. Best way to check? Ask for the address and other information on their datacenter. The trick here is that many hosts will give you the information of their providers datacenter (who they are renting from!), but if you are persistent enough and dig around you should be able to dig up the truth.

4. OUR HOSTING IS ONLY $5/MO – BUT YOU HAVE TO SIGN UP UNTIL 2050.

I don’t know what it is these days, but web hosting used to follow the logic of “what you see is what you get”. Now you have everyone advertising plans for $5/mon, but when you get to their website you find out its $20/month! What’s the deal?? Well it turns out that you need to sign up for 2 years, 3 years or even 5 years to get the “$5/mon”. Is it just me, or is that not $5/mon.? That would be $300/5years, not $5/mo! The worst part is that you usually don’t realize a host is doing this until you get to the final part in the check out. Do your research! Make sure when they say $5/mon. they mean $5/mon.! Not $300 for 5 years divided by 60!

.htaccess Tips and Tricks

January 25th, 2011

.htaccess (hypertext access) is the default name of a directory-level configuration file that allows for decentralized management of web server configuration.

There are tons of things you can do from the htaccess file inside of your web hosting account.  From redirecting the users to controlling who can get in and who can get out, it is a very useful file to have on your hosting account.  To help out the new web hosting clients and to act as a reminder to the old pros around here, I thought I would go through five of the most popular .htaccess tips I know.

Redirect to a Maintenance Page

This is a great one to use if you need to make some quick web page edits, and you don’t want the public to see you edit your web site, while it is still live.

Options +FollowSymlinks

RewriteEngine On

RewriteBase /

RewriteCond %{REQUEST_URI} !/offline.html$

RewriteRule .* /offline.html [R=307,L]

This will redirect anybody who checks out any web page on your web site to the “offline.html” file.

Force the Use of “www” in Front of a Domain Name

If you want to keep the www in front of your domain name, no matter how somebody types it in, here is the ‘bit of .htaccess magic you will need:

Options +FollowSymlinks

RewriteEngine on

rewritecond %{http_host} ^mydomain.com [nc]

rewriterule ^(.*)$ http://www.mydomain.com/$1 [r=301,nc]

Once you have done so, both mydomain.com and www.mydomain.com will both send you to www.mydomain.com

Remove the “www” From in Front of a Domain Name

You can also force your domain to drop the www from the address when typed in, if you would rather have it the other way around. In that situation, you would need to add this to your .htaccess file:

RewriteEngine On

RewriteCond %{HTTP_HOST} ^www.mydomain.com$ [NC]

RewriteRule ^(.*)$ http://mydomain.com/$1 [R=301,L]

This will make both mydomain.com and www.mydomain.com send you to just mydomain.com.

Manually Create Custom Error Pages

Ever check out some of those customized error pages and wonder how it could be done? Just use these snippets of .htaccess code to tell people where to look for your error pages.

ErrorDocument 400 /errors/400.html

ErrorDocument 401 /errors/401.html

ErrorDocument 403 /errors/403.html

ErrorDocument 404 /errors/404.html

ErrorDocument 500 /errors/500.html

This tells the server to look inside the “errors” folder and that specific page for each of the different error types. That is not all of the error codes, but they are the ones that will be ‘hit by your users 99 percent of the time.

Block Visitor By IP Address

Need to keep somebody from checking out your web site?  This next tip will give you the ability to deny somebody based on what their IP address is:

order allow,deny

deny from 123.45.6.7

deny from 012.34.5.

allow from all

The above blocks access to the site from 123.45.6.7, and from any sub-domain under the IP block 012.34.5. (012.34.5.1, 012.34.5.2, 012.34.5.3, etc).

Before you go off and plant htaccess everywhere, read through this and make sure you don’t do anything redundant, since it is possible to cause an infinite loop of redirects or errors if you place something weird in the htaccess.

Also…some sites do not allow use of htaccess files, since depending on what they are doing, they can slow down a server overloaded with domains if they are all using htaccess files. I can’t stress this enough: You need to make sure you are allowed to use htaccess before you actually use it. Some things that htaccess can do can compromise a server configuration that has been specifically setup by the admin, so don’t get in trouble.

PHP mySQL Web Hosting

April 21st, 2010

What Is PHP ?

PHP is an abbreviation for Hypertext Pre-Processor. It is a free, open source scripting language and is very popular for creating dynamic web applications. Scripting languages like PHP are ideal for rapid web development. Scripts written in PHP run directly on the web server and can be used to create dynamic web pages by using data retrieved from a database or other data sources. A dynamic web page is created using information pulled from a database, like MySQL, when the visitor access your site. Dynamic web pages, through communication with a database, allow you to provide your visitors with a more personalized browsing experience, display up-to-the-minute inventory of your products, easily manage your blog and much more. PHP is popular for many reasons including its ease of use, stability and for being very secure.

What is MySQL ?

MySQL is extremely popular open source database software. MySQL uses Structured Query Language (SQL), a computer language designed for adding, retrieving and managing data within a database management system with logical, easy-to-use syntax. Using a database such as MySQL to manage data for your dynamic web site comes with many advantages including faster access speeds, enhanced security, increased stability and the ability to handle access by multiple simultaneous visitors. These features make MySQL a quick, flexible and reliable solution.

PHP MySQL web hosting

PHP pages are treated by your PHP web hosting server just as any other HTML encoded pages are treated. It is highly recommended that, if you plan to use PHP in your web design, you use a PHP hosting provider that has activated support for all files with the extension “.php” at the end.MySQL is a database that stores and organizes a large amount of information to be accessed by PHP’s instructions. So your MySQL host must be able to offer you the databases and interface you need, as well as MySQL hosting specific support.



PHP Freelancer