Hello,
I have code that will let me write data to a text file but I don't know how to make it so that the information being written is always in a certain format.
The code works fine but I need the domain names being submitted from a form to always be in the format of...
http://www.domain.com
Sometimes people might enter:
domain.com or
www.domain.com
I don't want to store the domains in that format. It needs to be http://www.domain.com
The code:
(?php
$filename = "banned.txt"; //Change this to the file storing the domains.
$registered = $_GET['domain']."\n";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open $filename";
exit;
}
if (fwrite($handle, $registered) === false) {
echo "Cannot write to $filename";
exit;
}
echo "$domain was saved in $filename";
fclose($handle);
}
else {
echo "The file $filename is not writable";
}
?)
I'm not sure how to do this.
Any ideas?
Thanks in advance.
Wayne