Full-service Internet Marketing & Web Development
Recent Posts

Recommended Reads
|
How to Restore a MySQL BackupBrett Batie, July 23 -- Filed under Programming |
This tutorial goes over all the necessary steps to restore a MySQL backup via the shell or command line.
Determine The Basics About Your Database
We need some basic information about the MySQL installation before we get started restoring the backup.
First, lets determine the location of the mysql databases. It is generally located at /var/mysql/data but it is always good to double check. Issue the following command to see where it is:
This will output something like the following and tells us that the mysql databases are located at /usr/local/var. This location will be used for the remainder of the tutorial so please be sure to replace it with the location that you received from the above command.
Remove The Old Database(s)
If MySQL is not corrupted and your backup files are set to drop the table before inserting the new data. You can skip this section. If you are not sure it will not hurt to complete the following steps but we will need to take the database offline for a few minutes.
First we need to shutdown mysql with the following command:
Now we need to backup the current mysql data directory and create a new one. This can be done with the following 2 commands:
Next, we will install the basic mysql table by running the mysql_install.sh script. Generally, it is located at /usr/local/mysql/bin/mysql_install_db. If it is not there you can use the following command to find it.
Note: you may need to update your locate database if the script is not found with the above command. To update your database issue one of the following commands and then repeat the above command.
Now that we have found the script we can run it
Restore the Backup
The first step is to take your backup file and uncompress it.
If mysql.sql was not listed in the backup you can either manually reset the permissions or copy it from the backup you just made.
Now lets set the ownership of the directory and all files in the directory. Make sure to use the appropriate group and user with the below command.
Now create any databases that you are going to restore with a command like the following (repeat the command for every database that you will restore):
Restore the backup with the below command and repeat the command for every sql file/database that you will restore.
Startup MySQL
Determine The Basics About Your Database
We need some basic information about the MySQL installation before we get started restoring the backup.
First, lets determine the location of the mysql databases. It is generally located at /var/mysql/data but it is always good to double check. Issue the following command to see where it is:
cat /etc/my.cnf | grep 'innodb_data_home_dir'
This will output something like the following and tells us that the mysql databases are located at /usr/local/var. This location will be used for the remainder of the tutorial so please be sure to replace it with the location that you received from the above command.
innodb_data_home_dir = /usr/local/var/
Remove The Old Database(s)
If MySQL is not corrupted and your backup files are set to drop the table before inserting the new data. You can skip this section. If you are not sure it will not hurt to complete the following steps but we will need to take the database offline for a few minutes.
First we need to shutdown mysql with the following command:
mysqladmin -uroot -pYourPassword shutdown
Now we need to backup the current mysql data directory and create a new one. This can be done with the following 2 commands:
mv /usr/local/var /usr/local/var-old
mkdir /usr/local/var
mkdir /usr/local/var
Next, we will install the basic mysql table by running the mysql_install.sh script. Generally, it is located at /usr/local/mysql/bin/mysql_install_db. If it is not there you can use the following command to find it.
locate mysql_install_db
Note: you may need to update your locate database if the script is not found with the above command. To update your database issue one of the following commands and then repeat the above command.
FreeBSD and Mac OSX
/usr/libexec/./locate.updatedb
For CentOS or RH cores
updatedb
/usr/libexec/./locate.updatedb
For CentOS or RH cores
updatedb
Now that we have found the script we can run it
/usr/local/bin/./mysql_install_db
Restore the Backup
The first step is to take your backup file and uncompress it.
tar -xvzf /usr/local/var/yourBackup.tgz
If mysql.sql was not listed in the backup you can either manually reset the permissions or copy it from the backup you just made.
cp /usr/local/var-old/mysql/user* /usr/local/var/mysql/
Now lets set the ownership of the directory and all files in the directory. Make sure to use the appropriate group and user with the below command.
chown -R mysql:mysql /usr/local/var/
Now create any databases that you are going to restore with a command like the following (repeat the command for every database that you will restore):
echo 'create database YourNewDatabase' | mysql -uroot -pYourPassword
Restore the backup with the below command and repeat the command for every sql file/database that you will restore.
mysql -uroot -pyourPassword YourDatabase < backup.sql
Startup MySQL
mysqld_safe &
|
Email Mailserver Blacklist Check - New ToolAdrian Singer, July 21 -- Filed under Traffic |
Whether you are an individual user sending email to friends & colleagues, or use a commercial email-sending service like Constant Contact, it is important to regularly check your sending ip address hasn't been black listed.
Today we released a simple tool that lets you easily test if your mail server is black listed with any popular black-list DNS service:
Email mail server Blacklist Checker

-
Don't know your sending mail server ip address? Send an email to yourself, then view the message headers.
View 1 Comment(s)
Today we released a simple tool that lets you easily test if your mail server is black listed with any popular black-list DNS service:
Email mail server Blacklist Checker

-
Don't know your sending mail server ip address? Send an email to yourself, then view the message headers.
View 1 Comment(s)
|
PPC + Youtube video on your landing page = Free Organic TrafficDawn Rossi, July 20 -- Filed under Traffic |
Everyone knows video helps conversions. But most people who incorporate a video on their landing pages, use Amazon S3 to host the video, or use one of the dozen video sites like Viddler, Vimeo, Veoh etc.

Back in 2007, Adrian wrote about how we were migrating all of our videos from YouTube to ScreenCast.
Back then (maybe) it made sense... YouTube didn't have High Quality and we were doing primarily screen-cast type videos.
But nowadays, if you're not hosting your landing-page videos on YouTube, you're missing out big time!
5 reasons to use YouTube for your landing page videos
1. YouTube is where your traffic is

2. YouTube now offers full high definition
3. YouTube is the longest standing video service. Owned by Google, it's future is rock solid while some of the other video-hosting sites are facing financial difficulties.
4. YouTube channels and subscriptions actually work. Offer great content and you'll build a loyal following.
5. PPC traffic to Youtube videos on your landing page equals free traffic.
This is Key:
If you embed a YouTube video on your landing page (use &autoplay=1 to get the video to automatically play as son as the page loads), every page view translates to 1 view on YouTube.
The more views your video gets, the higher it will rank in YouTube and Google organic searches! Tag your video with the right keywords and include them in the video title. Pretty soon, you'll find you're getting lots of free clicks from Google search results.
You can even turn-off your PPC traffic later on and the traffic will continue.
View 1 Comment(s)

Back in 2007, Adrian wrote about how we were migrating all of our videos from YouTube to ScreenCast.
Back then (maybe) it made sense... YouTube didn't have High Quality and we were doing primarily screen-cast type videos.
But nowadays, if you're not hosting your landing-page videos on YouTube, you're missing out big time!
5 reasons to use YouTube for your landing page videos
1. YouTube is where your traffic is

2. YouTube now offers full high definition
3. YouTube is the longest standing video service. Owned by Google, it's future is rock solid while some of the other video-hosting sites are facing financial difficulties.
4. YouTube channels and subscriptions actually work. Offer great content and you'll build a loyal following.
5. PPC traffic to Youtube videos on your landing page equals free traffic.
This is Key:
If you embed a YouTube video on your landing page (use &autoplay=1 to get the video to automatically play as son as the page loads), every page view translates to 1 view on YouTube.
The more views your video gets, the higher it will rank in YouTube and Google organic searches! Tag your video with the right keywords and include them in the video title. Pretty soon, you'll find you're getting lots of free clicks from Google search results.
You can even turn-off your PPC traffic later on and the traffic will continue.
View 1 Comment(s)
|
How to check MySQL Replication databases are in SyncDawn Rossi, July 20 -- Filed under Programming |
In a previous post, Kyle covered How to fix MySQL Replication, by using a script that looks up records in the master/slave, inserting any missing records as well as updating any ones that don't exactly match.
But how can you tell your replicated MySQL databases are no longer in sync?
Since some queries are never safe to run in a replicated environment (i.e. DELETE FROM table LIMIT 1), without having the proper experience, it's easy to develop replication inconsistencies that could lead to fatal errors.
The easiest way to monitor replicated databases are in-sync is by using MySQL built-in CHECKSUM function, that calculates a checksum for each table based on the values, number of rows and number of columns in the table.
Calculating a table checksum is a very quick operation!
If a table on the master generates a different checksum than the same table on the slave, it means the two are not in sync and you should look deeper.
The code below handles verifying two databases (master/slave or master/master), printing a list of all tables where the checksum doesn't match:
$dbname="YOUR-DATABASE-NAME";
// Connect to master database
mysql_connect("MASTER-DB","USERNAME","PASSWORD");
mysql_select_db($dbname);
// Get all tables
$Result = @mysql_query("show tables");
$cnt = @mysql_num_rows($Result);
while ($cnt)
{
$cnt--;
if (!($Row = @mysql_fetch_array($Result))) continue;
$tablename = $Row[0];
$Result1 = @mysql_query("checksum table $tablename");
$Row1 = @mysql_fetch_row($Result1);
$arr_tables_db[$tablename] = $Row1[1];
}
mysql_connect("SLAVE-DB","USERNAME","PASSWORD");
mysql_select_db($dbname);
// Get all tables
$Result = @mysql_query("show tables");
$cnt = @mysql_num_rows($Result);
while ($cnt)
{
$cnt--;
if (!($Row = @mysql_fetch_array($Result))) continue;
$tablename = $Row[0];
$Result1 = @mysql_query("checksum table $tablename");
$Row1 = @mysql_fetch_row($Result1);
$arr_tables_db3[$tablename] = $Row1[1];
}
// Now display mismatches
foreach ($arr_tables_db as $name => $checksum)
{
if ($checksum != $arr_tables_db3[$name])
{
echo "- $name\r\n";
}
}
I strongly recommend setting this up on a cronjob, so that you identify any replication issues as quickly as possible.
Be sure to also read my post about a Better MySQL Replication monitor. Don't trust MySQL built-in "Seconds behind slave" reading, it's not reliable.
But how can you tell your replicated MySQL databases are no longer in sync?
Since some queries are never safe to run in a replicated environment (i.e. DELETE FROM table LIMIT 1), without having the proper experience, it's easy to develop replication inconsistencies that could lead to fatal errors.
The easiest way to monitor replicated databases are in-sync is by using MySQL built-in CHECKSUM function, that calculates a checksum for each table based on the values, number of rows and number of columns in the table.
Calculating a table checksum is a very quick operation!
If a table on the master generates a different checksum than the same table on the slave, it means the two are not in sync and you should look deeper.
The code below handles verifying two databases (master/slave or master/master), printing a list of all tables where the checksum doesn't match:
$dbname="YOUR-DATABASE-NAME";
// Connect to master database
mysql_connect("MASTER-DB","USERNAME","PASSWORD");
mysql_select_db($dbname);
// Get all tables
$Result = @mysql_query("show tables");
$cnt = @mysql_num_rows($Result);
while ($cnt)
{
$cnt--;
if (!($Row = @mysql_fetch_array($Result))) continue;
$tablename = $Row[0];
$Result1 = @mysql_query("checksum table $tablename");
$Row1 = @mysql_fetch_row($Result1);
$arr_tables_db[$tablename] = $Row1[1];
}
mysql_connect("SLAVE-DB","USERNAME","PASSWORD");
mysql_select_db($dbname);
// Get all tables
$Result = @mysql_query("show tables");
$cnt = @mysql_num_rows($Result);
while ($cnt)
{
$cnt--;
if (!($Row = @mysql_fetch_array($Result))) continue;
$tablename = $Row[0];
$Result1 = @mysql_query("checksum table $tablename");
$Row1 = @mysql_fetch_row($Result1);
$arr_tables_db3[$tablename] = $Row1[1];
}
// Now display mismatches
foreach ($arr_tables_db as $name => $checksum)
{
if ($checksum != $arr_tables_db3[$name])
{
echo "- $name\r\n";
}
}
I strongly recommend setting this up on a cronjob, so that you identify any replication issues as quickly as possible.
Be sure to also read my post about a Better MySQL Replication monitor. Don't trust MySQL built-in "Seconds behind slave" reading, it's not reliable.
|
jQuery for Real time Server-side Form ValidationDawn Rossi, July 17 -- Filed under Programming |
jQuery is a JavaScript Library that includes document traversing, drag&drop, date picker, tabs animating, and Ajax interactions for rapid web development. It's widely deployed and used by Google, Digg, Mozilla as well as many other huge sites.
As part of this post, I'll demonstrate how to use jQuery for real time server-side form validation.
The Challenge
Most HTML forms use simple Javascript to validate user input, before the form is submitted to the server.
A javascript function runs inside the browser and validates that a date field is valid, a username field doesn't contain invalid characters etc.
Providing user input passes these simple client-side validation tests, the form is submitted to the server, where the server performs additional validations on the entered data.
Some examples where this approach is lacking:
* A username may be valid on the client side, but already taken by the time the form is submitted.
* Information on the server-end is required to validate a password
* USPS lookup is necessary to validate an address / zip code etc.
jQuery
Since data on the server side is required for some validations, we need a way to ping the server and validate fields as the user is typing text in the form.
jQuery to the rescue!
Start by including jQuery in your html code:
<script type="text/javascript" src="https://softwareprojects.com/script/jquery.js"></script>
Designating a field as required is easy - simply add a hidden input tag with the name of require_FIELDNAME:
Enter your name: <input name=fullname type=text>
<input type=hidden name=require_fullname>
Integrating server-side validation with a form field and displaying an error message if validation fails, can be done with a single call:

$(document).ready(function () {
$('#username').bind('blur',function(e){
$.get("/validate_username.php", {login: $(this).val()}, function(data){
$('#username_message').html(data);
}, 'html');
});
});
Complete Example
This example features server-side validation of a password and username (check for invalid characters and verify username is available), displaying an inline error message if validation fails.
Here's how the end result looks like:

HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery Demo</title>
<link rel="stylesheet" href="style2.css" type="text/css" media="screen" />
<script type="text/javascript" src="https://softwareprojects.com/script/jquery.js"></script>
<script language="javascript">
<!--
$.ajaxSetup ({
cache: false
});
// Validate subdomain using validateusername.php
// Display result into s_dom div tag
$(document).ready(function () {
$('#subdomain').bind('blur',function(e){
$.get("/validateusername.php", {login: $(this).val()}, function(data){
$('#s_dom').html(data);
}, 'html');
});
// Validate password using validatepassword.php
// Display result into s_password div tag
$('#password').bind('blur',function(e){
$.get("/validatepassword.php", {password: $(this).val()}, function(data){
$('#s_password').html(data);
}, 'html');
});
// Validate password2 using validatepassword.php
// Display result into s_password2 div tag
$('#password2').bind('blur',function(e){
$.get("/validatepassword.php", {password: $(this).val()}, function(data){
$('#s_password2').html(data);
}, 'html');
});
});
//-->
</script>
</head>
<body>
<div id="page">
<!--main start-->
<div class="main">
<div class="rbody">
<div >
<div class="roundbodytop">
<div class="innerbody">
<div class="leftside3">
<p align="center"><img src="copy/images/homebusinessprofitblueprint2.png" width="694" height="82" /></p>
<p align="center" class="mainRedTitle"></p>
<p align="center"> <span class="mainRedTitle"><strong>Congratulations
<?=$name?>! Your Account Is Now Active. The Final Step Is To Personalize Your System Information Below.</strong></span>
</p>
<p align="center" class="blacktitle"><strong>Please
choose a password and system subdomain below.*
The subdomain will be part of your personal link to
your system.* </strong></p>
<p>*</p>
<form id="form1" name="form1" method="post" action="thankyou1.php">
<table width="100%" border="0" cellpadding="0">
<tr>
<td width="22%"><div align="right" class="text14"><strong>System Details</strong></div></td>
<td width="78%">*</td>
</tr>
<tr>
<th><span class="red">*</span> Password :</th>
<td><input name="password" type="password" class="InputBoxFront" size="40" maxlength="100" id="password" />
<span class="red" id="s_password"><? if (isset($_POST['save'])) {
if ($_POST['password']== '') {
echo "This field must be filled in";
$all_ok=false;
}
} ?></span> </td>
</tr>
<tr>
<th><span class="red">*</span> Password verification :</th>
<td><input name="password2" type="password" class="InputBoxFront" size="40" maxlength="100" id="password2" /> <span class="red" id="s_password2"></span>
<span class="red"><? if (isset($_POST['save'])) {
if ($_POST['password2']== '') {
echo "This field must be filled in";
$all_ok=false;
} else {
if ($_POST['password2'] != $_POST['password']) {
echo "Passwords must match";
$all_ok=false;
}
}
} ?></span> </td>
</tr>
<tr>
<th><span class="red">*</span> System subdomain choice :</th>
<td><input name="subdomain" type="text" class="InputBoxFront" size="10" maxlength="100" id="subdomain" />
.homebusinessprofitblueprint.com
<span class="red"><? if (isset($_POST['save'])) {
if ($_POST['subdomain']== '') {
echo "This field must be filled in";
$all_ok=false;
}
} ?></span><div id="s_dom" class="red"></div> </td>
</tr>
<tr>
<td colspan="2" align="center">*</td>
</tr>
<tr>
<td colspan="2" align="center"><div align="center">
<a href="javascript:OnUpdate();"><img src="images/homebut3.png" border="0" /></a>
</div></td>
</tr>
</table>
</form>
<p>*</p>
<p>*</p>
</div>
</div>
</div>
</div>
</div>
<SCRIPT>
function OnUpdate()
{
// Basic Javascript validation
if (document.getElementById('form1').password.value=="")
{
alert("Password is required");
return;
}
if (document.getElementById('form1').password2.value=="")
{
alert("Please repeat the password");
return;
}
if (document.getElementById('form1').subdomain.value=="")
{
alert("Subdomain is required");
return;
}
if (document.getElementById('form1').password.value!=
document.getElementById('form1').password2.value)
{
alert("The passwords should be the same");
return;
}
// Server-side validation
// Username
$.get("/validateusername.php", {login: $('#subdomain').val()}, function(data)
{
if (data!="")
{
alert("Invalid subdomain");
return;
}
}, 'html');
// Password
$.get("/validatepassword.php", {password: $('#password').val()}, function(data)
{
if (data!="")
{
alert("Invalid password");
return;
}
}, 'html');;
document.getElementById('form1').submit();
}
</SCRIPT>
The validateusername.php file:
// Connect to your database
mysql_connect("host","username","password");
// Check if we already have a customer with this username
$Result = mysql_query("SELECT * FROM customers where login='".mysql_real_escape_string($login)."' limit 1");
if (!empty($login) && $login != 'www')
{
if (mysql_num_rows($Result)>0)
{
echo "Username already exists";
}
else
if (preg_match("/[^A-Za-z0-9_-]/",$login))
{
echo "Invalid username. Please only use A-Z, a-z and 0-9 characters";
}
}
else
{
echo 'Incorrect username';
}
The validatepassword.php file:
if (preg_match("/[^A-Za-z0-9_-!]/",$password))
{
echo 'Invalid password. Please only use A-Z, a-z, 0-9, "-" or "!"';
}
View 3 Comment(s)
As part of this post, I'll demonstrate how to use jQuery for real time server-side form validation.
The Challenge
Most HTML forms use simple Javascript to validate user input, before the form is submitted to the server.
A javascript function runs inside the browser and validates that a date field is valid, a username field doesn't contain invalid characters etc.
Providing user input passes these simple client-side validation tests, the form is submitted to the server, where the server performs additional validations on the entered data.
Some examples where this approach is lacking:
* A username may be valid on the client side, but already taken by the time the form is submitted.
* Information on the server-end is required to validate a password
* USPS lookup is necessary to validate an address / zip code etc.
jQuery
Since data on the server side is required for some validations, we need a way to ping the server and validate fields as the user is typing text in the form.
jQuery to the rescue!
Start by including jQuery in your html code:
<script type="text/javascript" src="https://softwareprojects.com/script/jquery.js"></script>
Designating a field as required is easy - simply add a hidden input tag with the name of require_FIELDNAME:
Enter your name: <input name=fullname type=text>
<input type=hidden name=require_fullname>
Integrating server-side validation with a form field and displaying an error message if validation fails, can be done with a single call:

$(document).ready(function () {
$('#username').bind('blur',function(e){
$.get("/validate_username.php", {login: $(this).val()}, function(data){
$('#username_message').html(data);
}, 'html');
});
});
Complete Example
This example features server-side validation of a password and username (check for invalid characters and verify username is available), displaying an inline error message if validation fails.
Here's how the end result looks like:

HTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>jQuery Demo</title>
<link rel="stylesheet" href="style2.css" type="text/css" media="screen" />
<script type="text/javascript" src="https://softwareprojects.com/script/jquery.js"></script>
<script language="javascript">
<!--
$.ajaxSetup ({
cache: false
});
// Validate subdomain using validateusername.php
// Display result into s_dom div tag
$(document).ready(function () {
$('#subdomain').bind('blur',function(e){
$.get("/validateusername.php", {login: $(this).val()}, function(data){
$('#s_dom').html(data);
}, 'html');
});
// Validate password using validatepassword.php
// Display result into s_password div tag
$('#password').bind('blur',function(e){
$.get("/validatepassword.php", {password: $(this).val()}, function(data){
$('#s_password').html(data);
}, 'html');
});
// Validate password2 using validatepassword.php
// Display result into s_password2 div tag
$('#password2').bind('blur',function(e){
$.get("/validatepassword.php", {password: $(this).val()}, function(data){
$('#s_password2').html(data);
}, 'html');
});
});
//-->
</script>
</head>
<body>
<div id="page">
<!--main start-->
<div class="main">
<div class="rbody">
<div >
<div class="roundbodytop">
<div class="innerbody">
<div class="leftside3">
<p align="center"><img src="copy/images/homebusinessprofitblueprint2.png" width="694" height="82" /></p>
<p align="center" class="mainRedTitle"></p>
<p align="center"> <span class="mainRedTitle"><strong>Congratulations
<?=$name?>! Your Account Is Now Active. The Final Step Is To Personalize Your System Information Below.</strong></span>
</p>
<p align="center" class="blacktitle"><strong>Please
choose a password and system subdomain below.*
The subdomain will be part of your personal link to
your system.* </strong></p>
<p>*</p>
<form id="form1" name="form1" method="post" action="thankyou1.php">
<table width="100%" border="0" cellpadding="0">
<tr>
<td width="22%"><div align="right" class="text14"><strong>System Details</strong></div></td>
<td width="78%">*</td>
</tr>
<tr>
<th><span class="red">*</span> Password :</th>
<td><input name="password" type="password" class="InputBoxFront" size="40" maxlength="100" id="password" />
<span class="red" id="s_password"><? if (isset($_POST['save'])) {
if ($_POST['password']== '') {
echo "This field must be filled in";
$all_ok=false;
}
} ?></span> </td>
</tr>
<tr>
<th><span class="red">*</span> Password verification :</th>
<td><input name="password2" type="password" class="InputBoxFront" size="40" maxlength="100" id="password2" /> <span class="red" id="s_password2"></span>
<span class="red"><? if (isset($_POST['save'])) {
if ($_POST['password2']== '') {
echo "This field must be filled in";
$all_ok=false;
} else {
if ($_POST['password2'] != $_POST['password']) {
echo "Passwords must match";
$all_ok=false;
}
}
} ?></span> </td>
</tr>
<tr>
<th><span class="red">*</span> System subdomain choice :</th>
<td><input name="subdomain" type="text" class="InputBoxFront" size="10" maxlength="100" id="subdomain" />
.homebusinessprofitblueprint.com
<span class="red"><? if (isset($_POST['save'])) {
if ($_POST['subdomain']== '') {
echo "This field must be filled in";
$all_ok=false;
}
} ?></span><div id="s_dom" class="red"></div> </td>
</tr>
<tr>
<td colspan="2" align="center">*</td>
</tr>
<tr>
<td colspan="2" align="center"><div align="center">
<a href="javascript:OnUpdate();"><img src="images/homebut3.png" border="0" /></a>
</div></td>
</tr>
</table>
</form>
<p>*</p>
<p>*</p>
</div>
</div>
</div>
</div>
</div>
<SCRIPT>
function OnUpdate()
{
// Basic Javascript validation
if (document.getElementById('form1').password.value=="")
{
alert("Password is required");
return;
}
if (document.getElementById('form1').password2.value=="")
{
alert("Please repeat the password");
return;
}
if (document.getElementById('form1').subdomain.value=="")
{
alert("Subdomain is required");
return;
}
if (document.getElementById('form1').password.value!=
document.getElementById('form1').password2.value)
{
alert("The passwords should be the same");
return;
}
// Server-side validation
// Username
$.get("/validateusername.php", {login: $('#subdomain').val()}, function(data)
{
if (data!="")
{
alert("Invalid subdomain");
return;
}
}, 'html');
// Password
$.get("/validatepassword.php", {password: $('#password').val()}, function(data)
{
if (data!="")
{
alert("Invalid password");
return;
}
}, 'html');;
document.getElementById('form1').submit();
}
</SCRIPT>
The validateusername.php file:
// Connect to your database
mysql_connect("host","username","password");
// Check if we already have a customer with this username
$Result = mysql_query("SELECT * FROM customers where login='".mysql_real_escape_string($login)."' limit 1");
if (!empty($login) && $login != 'www')
{
if (mysql_num_rows($Result)>0)
{
echo "Username already exists";
}
else
if (preg_match("/[^A-Za-z0-9_-]/",$login))
{
echo "Invalid username. Please only use A-Z, a-z and 0-9 characters";
}
}
else
{
echo 'Incorrect username';
}
The validatepassword.php file:
if (preg_match("/[^A-Za-z0-9_-!]/",$password))
{
echo 'Invalid password. Please only use A-Z, a-z, 0-9, "-" or "!"';
}
View 3 Comment(s)
|
How to manually process MySQL replication log filesMike Peters, July 15 -- Filed under Programming |
MySQL replication log files are simple text files, with a dump of all queries issued on the designated server.
At certain times, when MySQL slave servers fall behind, it may be useful to copy the log files over from the master to the slave machines and then manually process them.
To process a MySQL replication log file, copy the file from the master to the slave machine, then issue this command:
Replace 1234 with the last position the slave was able to read
Replace mysql-bin.000001 with the master file name
And replace USERNAME/PASSWORD with the slave database credentials
At certain times, when MySQL slave servers fall behind, it may be useful to copy the log files over from the master to the slave machines and then manually process them.
To process a MySQL replication log file, copy the file from the master to the slave machine, then issue this command:
mysqlbinlog /usr/tmp/mysql-bin.000001 --start-position=1234 | sed -e 's/SET \/\*\!\*\//SET AUTOCOMMIT=0/g' | mysql -uUSERNAME -pPASSWORD
Replace 1234 with the last position the slave was able to read
Replace mysql-bin.000001 with the master file name
And replace USERNAME/PASSWORD with the slave database credentials
| « Previous Posts | » Next Posts |
