yay my first working script
- pureone_36
- Novice


- Joined: Jul 17, 2004
- Posts: 24
- Loc: earth
- Status: Offline
well im please to say my first step towards finishing off my site has happen and i would like to share my finished script.
theres 4
the 2 html scripts
the 2 php scripts
they are there basic because ive jus finished them and its taken me a week to get up and running ive been doing php for 2 weeks or maybe 3 not sure but i love it.
well here is the sign up script
by the way i do not really intend to use this on a remote host so the txt files can be put some were else on the computer to be located
and once they have signed up they can then log in
im happy so hopefully some people can learn from this
tell me what you think
theres 4
the 2 html scripts
the 2 php scripts
they are there basic because ive jus finished them and its taken me a week to get up and running ive been doing php for 2 weeks or maybe 3 not sure but i love it.
well here is the sign up script
by the way i do not really intend to use this on a remote host so the txt files can be put some were else on the computer to be located
Code: [ Select ]
<html>
<body><center>
<form name="overfile" method="submit"
action="over.php"><input name="username" type="text" value="create a user name" /><br/><input name="password" type="password" value=""/><input type="submit"></form></center></body>
</html>
<body><center>
<form name="overfile" method="submit"
action="over.php"><input name="username" type="text" value="create a user name" /><br/><input name="password" type="password" value=""/><input type="submit"></form></center></body>
</html>
- <html>
- <body><center>
- <form name="overfile" method="submit"
- action="over.php"><input name="username" type="text" value="create a user name" /><br/><input name="password" type="password" value=""/><input type="submit"></form></center></body>
- </html>
Code: [ Select ]
<?php
{
$filename = 'database.txt';
$user = $_REQUEST["username"];
$somecontent = $_REQUEST["password"];
$testline = md5($user) . ";" . md5($somecontent) . "\n";
}
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $testline) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($user,) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
{
$filename = 'database.txt';
$user = $_REQUEST["username"];
$somecontent = $_REQUEST["password"];
$testline = md5($user) . ";" . md5($somecontent) . "\n";
}
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
// In our example we're opening $filename in append mode.
// The file pointer is at the bottom of the file hence
// that's where $somecontent will go when we fwrite() it.
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
// Write $somecontent to our opened file.
if (fwrite($handle, $testline) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($user,) to file ($filename)";
fclose($handle);
} else {
echo "The file $filename is not writable";
}
?>
- <?php
- {
- $filename = 'database.txt';
- $user = $_REQUEST["username"];
- $somecontent = $_REQUEST["password"];
- $testline = md5($user) . ";" . md5($somecontent) . "\n";
- }
- // Let's make sure the file exists and is writable first.
- if (is_writable($filename)) {
- // In our example we're opening $filename in append mode.
- // The file pointer is at the bottom of the file hence
- // that's where $somecontent will go when we fwrite() it.
- if (!$handle = fopen($filename, 'a')) {
- echo "Cannot open file ($filename)";
- exit;
- }
- // Write $somecontent to our opened file.
- if (fwrite($handle, $testline) === FALSE) {
- echo "Cannot write to file ($filename)";
- exit;
- }
- echo "Success, wrote ($user,) to file ($filename)";
- fclose($handle);
- } else {
- echo "The file $filename is not writable";
- }
- ?>
and once they have signed up they can then log in
Code: [ Select ]
<table width="20%" border="3" cellspacing="3" cellpadding="5" align="center">
<tr><td width="5%"><BR><CENTER><h3>login here submit a username and password</h3>
<center><form name="logme" method="post" action="checkmd5.php"> <input name="username" type="text" value="" /><br /><input name="password" type="password" value="" /><center><input type="submit"></form></center></center>
<tr><td width="5%"><BR><CENTER><h3>login here submit a username and password</h3>
<center><form name="logme" method="post" action="checkmd5.php"> <input name="username" type="text" value="" /><br /><input name="password" type="password" value="" /><center><input type="submit"></form></center></center>
- <table width="20%" border="3" cellspacing="3" cellpadding="5" align="center">
- <tr><td width="5%"><BR><CENTER><h3>login here submit a username and password</h3>
- <center><form name="logme" method="post" action="checkmd5.php"> <input name="username" type="text" value="" /><br /><input name="password" type="password" value="" /><center><input type="submit"></form></center></center>
Code: [ Select ]
<?php
// This script is intended to accept a username and password and then
// check that against a database file
// First define the name of the database file here, so it is easy to change
$databasefile = "database.txt";
// Here we define the target locations for success and failure
$successurl = "http://www.google.com";
$failedurl = "http://www.yahoo.com";
// Here we set a variable that controls if error messages will be shown
$showerrors = TRUE;
// Then set a control variable that will signal failure or success
// We will assume failure so only when there is a match access is allowed
$match = FALSE;
// Now we start doing a whole bunch of checks, before we start the real work
// First check if the username and password parameters are available at all.
// These parameters are expected to be POSTED from an html form, so we will
// look in the $_POST array for them.
$username = $_REQUEST["username"];
$password = $_REQUEST["password"];
if ($username == "" || $password == "")
{
// The username or password was not provided, show error message
if ($showerrors) print("Username or password were not provided.<br />");
}
else
{
// The username and password were provided, now check if the database
// file actually exists.
if (!file_exists($databasefile))
{
// The database file does not exist, show error message
if ($showerrors) print("Database file " . $databasefile . " not found.<br />");
}
else
{
// The database file does exist, so read it
$lines = file($databasefile);
// Count the number of lines in the lines array
$linecount = count($lines);
// Check if there is at least one line
if ($linecount < 1)
{
// No lines were found in the lines array, show error message
if ($showerrors) print("No lines found in database file " . $databasefile . ".<br />");
}
else
{
// At least one line was found in the lines array, go through them
for ($i = 0; $i < $linecount; $i++)
{
// Split the current line into parts on the semicolon
$parts = explode(";",$lines[$i]);
// There are supposed to be TWO parts, the username and password
$partcount = count($parts);
if ($partcount != 2)
{
// The number of parts was NOT two, show error message
if ($showerrors) print("The number of parts in line " . $i . " is " . $partcount . ".<br />");
}
else
{
// The number of parts IS two, strip spaces from the parts
$parts[0] = trim($parts[0]);
$parts[1] = trim($parts[1]);
// Now we finally can compare the input to these parts
if ($parts[0] == md5($username) && $parts[1] == md5($password))
{
$match = TRUE;
// Break out of the for loop to stop going through the lines
break;
}
}
} // The for loop ends here
// Check if there was a match
if ($match == FALSE)
{
// There was no match, go to failed url
header("Location: " . $failedurl);
}
else
{
// There was a match, go to the success url
header("Location: " . $successurl);
}
}
}
}
?>
// This script is intended to accept a username and password and then
// check that against a database file
// First define the name of the database file here, so it is easy to change
$databasefile = "database.txt";
// Here we define the target locations for success and failure
$successurl = "http://www.google.com";
$failedurl = "http://www.yahoo.com";
// Here we set a variable that controls if error messages will be shown
$showerrors = TRUE;
// Then set a control variable that will signal failure or success
// We will assume failure so only when there is a match access is allowed
$match = FALSE;
// Now we start doing a whole bunch of checks, before we start the real work
// First check if the username and password parameters are available at all.
// These parameters are expected to be POSTED from an html form, so we will
// look in the $_POST array for them.
$username = $_REQUEST["username"];
$password = $_REQUEST["password"];
if ($username == "" || $password == "")
{
// The username or password was not provided, show error message
if ($showerrors) print("Username or password were not provided.<br />");
}
else
{
// The username and password were provided, now check if the database
// file actually exists.
if (!file_exists($databasefile))
{
// The database file does not exist, show error message
if ($showerrors) print("Database file " . $databasefile . " not found.<br />");
}
else
{
// The database file does exist, so read it
$lines = file($databasefile);
// Count the number of lines in the lines array
$linecount = count($lines);
// Check if there is at least one line
if ($linecount < 1)
{
// No lines were found in the lines array, show error message
if ($showerrors) print("No lines found in database file " . $databasefile . ".<br />");
}
else
{
// At least one line was found in the lines array, go through them
for ($i = 0; $i < $linecount; $i++)
{
// Split the current line into parts on the semicolon
$parts = explode(";",$lines[$i]);
// There are supposed to be TWO parts, the username and password
$partcount = count($parts);
if ($partcount != 2)
{
// The number of parts was NOT two, show error message
if ($showerrors) print("The number of parts in line " . $i . " is " . $partcount . ".<br />");
}
else
{
// The number of parts IS two, strip spaces from the parts
$parts[0] = trim($parts[0]);
$parts[1] = trim($parts[1]);
// Now we finally can compare the input to these parts
if ($parts[0] == md5($username) && $parts[1] == md5($password))
{
$match = TRUE;
// Break out of the for loop to stop going through the lines
break;
}
}
} // The for loop ends here
// Check if there was a match
if ($match == FALSE)
{
// There was no match, go to failed url
header("Location: " . $failedurl);
}
else
{
// There was a match, go to the success url
header("Location: " . $successurl);
}
}
}
}
?>
- <?php
- // This script is intended to accept a username and password and then
- // check that against a database file
- // First define the name of the database file here, so it is easy to change
- $databasefile = "database.txt";
- // Here we define the target locations for success and failure
- $successurl = "http://www.google.com";
- $failedurl = "http://www.yahoo.com";
- // Here we set a variable that controls if error messages will be shown
- $showerrors = TRUE;
- // Then set a control variable that will signal failure or success
- // We will assume failure so only when there is a match access is allowed
- $match = FALSE;
- // Now we start doing a whole bunch of checks, before we start the real work
- // First check if the username and password parameters are available at all.
- // These parameters are expected to be POSTED from an html form, so we will
- // look in the $_POST array for them.
- $username = $_REQUEST["username"];
- $password = $_REQUEST["password"];
- if ($username == "" || $password == "")
- {
- // The username or password was not provided, show error message
- if ($showerrors) print("Username or password were not provided.<br />");
- }
- else
- {
- // The username and password were provided, now check if the database
- // file actually exists.
- if (!file_exists($databasefile))
- {
- // The database file does not exist, show error message
- if ($showerrors) print("Database file " . $databasefile . " not found.<br />");
- }
- else
- {
- // The database file does exist, so read it
- $lines = file($databasefile);
- // Count the number of lines in the lines array
- $linecount = count($lines);
- // Check if there is at least one line
- if ($linecount < 1)
- {
- // No lines were found in the lines array, show error message
- if ($showerrors) print("No lines found in database file " . $databasefile . ".<br />");
- }
- else
- {
- // At least one line was found in the lines array, go through them
- for ($i = 0; $i < $linecount; $i++)
- {
- // Split the current line into parts on the semicolon
- $parts = explode(";",$lines[$i]);
- // There are supposed to be TWO parts, the username and password
- $partcount = count($parts);
- if ($partcount != 2)
- {
- // The number of parts was NOT two, show error message
- if ($showerrors) print("The number of parts in line " . $i . " is " . $partcount . ".<br />");
- }
- else
- {
- // The number of parts IS two, strip spaces from the parts
- $parts[0] = trim($parts[0]);
- $parts[1] = trim($parts[1]);
- // Now we finally can compare the input to these parts
- if ($parts[0] == md5($username) && $parts[1] == md5($password))
- {
- $match = TRUE;
- // Break out of the for loop to stop going through the lines
- break;
- }
- }
- } // The for loop ends here
- // Check if there was a match
- if ($match == FALSE)
- {
- // There was no match, go to failed url
- header("Location: " . $failedurl);
- }
- else
- {
- // There was a match, go to the success url
- header("Location: " . $successurl);
- }
- }
- }
- }
- ?>
im happy so hopefully some people can learn from this
tell me what you think
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
July 25th, 2004, 6:49 pm
- veedee
- Graduate


- Joined: Jul 09, 2004
- Posts: 110
- Status: Offline
- Nem
- Guru


- Joined: Feb 13, 2004
- Posts: 1243
- Loc: UK
- Status: Offline
- pureone_36
- Novice


- Joined: Jul 17, 2004
- Posts: 24
- Loc: earth
- Status: Offline
im not going to change the title
but jus for the record this is my first useful working script
everyone has bloody done a simple script but this is my first complex
maybe i should of stated that
my first real simple script was
<?php
if $remote_addr == <myip>
header("location : http://youraregay.com")
else
print("welcome who ever")
but jus for the record this is my first useful working script
everyone has bloody done a simple script but this is my first complex
maybe i should of stated that
my first real simple script was
<?php
if $remote_addr == <myip>
header("location : http://youraregay.com")
else
print("welcome who ever")
- veedee
- Graduate


- Joined: Jul 09, 2004
- Posts: 110
- Status: Offline
- pureone_36
- Novice


- Joined: Jul 17, 2004
- Posts: 24
- Loc: earth
- Status: Offline
bah
i tell you my second script was a cookie one but it never worked!
so heres another script i made last night
changes ip to binary
i tell you my second script was a cookie one but it never worked!
so heres another script i made last night
Code: [ Select ]
<?php
$no1 = $_POST["no1"];
$no2 = $_POST["no2"];
$no3 = $_POST["no3"];
$no4 = $_POST["no4"];
{
if (($no1 == "") && ($no2 == "")
&& ($no3 == "") && ($no4 == ""))
print(" duh! ");
else
{
print(" the ip you submited in binary form is :") ."\n";
echo decbin($no1) ."\n";
echo decbin($no2) ."\n";
echo decbin($no3) ."\n";
echo decbin($no4) ."\n";
}
}
?>
$no1 = $_POST["no1"];
$no2 = $_POST["no2"];
$no3 = $_POST["no3"];
$no4 = $_POST["no4"];
{
if (($no1 == "") && ($no2 == "")
&& ($no3 == "") && ($no4 == ""))
print(" duh! ");
else
{
print(" the ip you submited in binary form is :") ."\n";
echo decbin($no1) ."\n";
echo decbin($no2) ."\n";
echo decbin($no3) ."\n";
echo decbin($no4) ."\n";
}
}
?>
- <?php
- $no1 = $_POST["no1"];
- $no2 = $_POST["no2"];
- $no3 = $_POST["no3"];
- $no4 = $_POST["no4"];
- {
- if (($no1 == "") && ($no2 == "")
- && ($no3 == "") && ($no4 == ""))
- print(" duh! ");
- else
- {
- print(" the ip you submited in binary form is :") ."\n";
- echo decbin($no1) ."\n";
- echo decbin($no2) ."\n";
- echo decbin($no3) ."\n";
- echo decbin($no4) ."\n";
- }
- }
- ?>
changes ip to binary
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 6 posts
- Users browsing this forum: No registered users and 101 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum
