Jump to content

EDukeeey

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Everything posted by EDukeeey

  1. Perfect! Thankyou all very much for helping me with this, I will learn a bit more before going any further with this so that I know more about what I am doing. thanks again
  2. How would I make it echo the full thing? (e.g. BHDK rather than BH) Also, sorry for so many questions, I am new to php and my friend wanted this created.
  3. Thankyou, it fixed it. However now what is returned is What can I do to change it from the numbers to letters?
  4. I think I may need to learn a bit more for this. Thankyou very much for the code, I tried to implement it into a page using <?php $ltrs = "ABCDEFGHJKLMPQRS"; $name = $_POST['name']; $one = rand(0, strlen($ltrs)-2); $str = $ltrs[$one]; $ltrs = substr($ltrs, 0, $one).substr($ltrs, $one+1); // remove this letter, it can't be used again $two = rand($one, strlen($ltrs)-1); // must come after $one $str .= $ltrs[$two]; $ltrs = substr($ltrs, 0, $two).substr($ltrs, $two+1); // remove this letter, it can't be used again $three = rand(0, strlen($ltrs)-2); $str = $ltrs[$three]; $ltrs = substr($ltrs, 0, $three).substr($ltrs, $three+1); // remove this letter, it can't be used again $four = rand($three, strlen($ltrs)-1); // must come after $three $str .= $ltrs[$four]; return $str; $code = $one.$two.$three.$four; ?> <html> <head> <title>Random Code Generator</title> </head> <body> <?php echo "Ref. Name:" .$name. "<br />"; // prints name echo "Code:" .$code. "<br />"; // prints code ?> </body> </html> $name is a variable from a form which is connected to the php doc. But the page just returned blank. Any more help would be very much appreciated. Sorry for any nooby mistakes I may have made.
  5. Hello, I am attempting to develop a simple php script which will generate a 4 letter sequence when a button is pressed. However the sequence has a few rules it has to follow. For example: the letters have to be A B C D E F G H J K L M P Q and R The second letter must be a letter AFTER the first The fourth letter must be a letter AFTER the third There can't be 2 of the same number. I am a bit confused on how I will do this as I am quite new to php, I though about generating the first as $1, then generating the second as $2, then if $1 > $2, then I would regenerate $2 until it wasn't. Then repeating that for $4. However I am not sure on the coding which would be involved in doing this. If someone could give me a few pointers or a link to a website which would help me it would be much appreciated.
×
×
  • 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.