Jump to content

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.