Jump to content

File help


emery

Recommended Posts

I have this code

 

it is supposed to make a file with the random number and name inside it, but instead it makes a file with just the random number and the extention isn't there ".num" :(

<?php
$loca = $_POST['loca'];
$name = $_POST['name'];
if ( $loca == "" ) {
echo "Error - Contact emery.cairns@gmail.com or STOP HACKING";
die;
} else {
if ( $name == "" ) {
echo "Error - Contact emery.cairns@gmail.com or STOP HACKING";
die;
} else {
}
}
$rand = rand(100000, 999999);
$myFile = $rand + ".num";
$fh = fopen($myFile, 'w') or die("Error with regerstration - please contact emery.cairns@gmail.com or try again");
$stringData = $rand + "\n";
fwrite($fh, $stringData);
$stringData = $name + "\n";
fwrite($fh, $stringData);
fclose($fh);
echo "Hello ";
echo $name ;
echo " ...  Your account number is ";
echo $rand;
$string = "\n\r Please write this number down, \n\r you may only get 1 from the webpage";
echo nl2br($string);
setcookie("dsc", $rand, time()+9999999999999999999);
?>

Link to comment
https://forums.phpfreaks.com/topic/255535-file-help/
Share on other sites

  Quote

ok, but why does it add another "0" to the end of my RaND number when its in the file, ECHO $RAND doesn't print the extra 0

 

where exactly in the text file? you use rand() several times to add data into the file. can you post the file contents.

Link to comment
https://forums.phpfreaks.com/topic/255535-file-help/#findComment-1310188
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.