Hi
Thank you fot the advixce which I accept.
Please, note that my server, JustHost, uses MySQL databases.
However, at this moment I am not building a working webpage. I simply need something that looks like a webpage. Later, I can change, update, look at all the security issues. My question was whether that code might be a start, and if it would work. It is also my way of learning what it is all about in the little time that I have available.
Meanwhile. I found some other code which I have been looking at. If I were to try it, what code would I have to put in the “Submit” button for this code to be called and executed?
Any help would be welcome
Thank you
qim
<?php
//STEP 1 Connect To Database
$connect = mysql_connect(“HOST”,“USER”,“PASSWORD”);
if (!$connect)
{
die(“MySQL could not connect!”);
}
$DB = mysql_select_db(‘pintotou_agents’);
if(!$DB)
{
die(“My SQL could not select Database!”);
}
// STEP 2
$uname = $_POST[‘username’];
$pword = $_POST[‘password’];
$uname = htmlspecialchars($uname);
$pword = htmlspecialchars($pword);
$uLength = strlen($uname);
$pLength = strlen($pword);
if ($uLength >= 10 && $uLength <= 20) {
$errorMessage = “”;
}
else {
$errorMessage = $errorMessage . “Username must be between 10 and 20 characters” . “<BR>”;
}
if ($pLength >= 8 && $pLength <= 16) {
$errorMessage = “”;
}
else {
$errorMessage = $errorMessage . “Password must be between 8 and 16 characters” . “<BR>”;
}
if ($errorMessage == “”) {
}
$user_name = “root”;
$pass_word = “”;
$database = “login”;
$server = “127.0.0.1”;
$db_handle = mysql_connect($server, $user_name, $pass_word);
$db_found = mysql_select_db($database, $db_handle);
if ($db_found) {
}
$SQL = “SELECT * FROM login WHERE L1 = $uname”;
$result = mysql_query($SQL);
$num_rows = mysql_num_rows($result);
if ($num_rows > 0) {
$errorMessage = “Username already taken”;
}
else {
$SQL = “INSERT INTO login (L1, L2) VALUES ($uname, $pword)”;
$result = mysql_query($SQL);
mysql_close($db_handle);
header (“Location: page1.php”);