Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Just a script thats not working.
Old 12-29-2003, 05:15 PM Just a script thats not working.
Chris_krasnichu's Avatar
Ultra Talker

Posts: 331
Location: Ontario, Canada
Trades: 0
Hello,
I'm having trouble with the script below:
Code:
<form action="safe.php?process=y" method="POST">
Text: <input type="text" name="text" size=40>
<input type="submit" value="Submit"><input type="reset" value="Clear"><BR>
Scrable Text:<input type="radio" name=type value=encript> Descrable Text<input type="radio" name=type value=decript>
</form>
<BR>
<BR>
<BR>
<?php
$get = $_GET['process'];
if ($get == 'y'){

$text = $_POST['text'];

function scramble($t)
{
if ($_POST['type'] == 'encript') {
 str_replace("a", "s", $t);
 str_replace("A", "S", $t);
 str_replace("b", "n", $t);
 str_replace("B", "N", $t);
 str_replace("c", "v", $t);
 str_replace("C", "V", $t);
 str_replace("d", "f", $t);
 str_replace("D", "F", $t);
 str_replace("e", "r", $t);
 str_replace("E", "R", $t);
 str_replace("f", "g", $t);
 str_replace("F", "G", $t);
 str_replace("g", "h", $t);
 str_replace("G", "H", $t);
 str_replace("h", "j", $t);
 str_replace("H", "J", $t);
 str_replace("i", "o", $t);
 str_replace("I", "O", $t);
 str_replace("j", "k", $t);
 str_replace("J", "K", $t);
 str_replace("k", "l", $t);
 str_replace("K", "L", $t);
 str_replace("l", "a", $t);
 str_replace("L", "A", $t);
 str_replace("m", "z", $t);
 str_replace("M", "Z", $t);
 str_replace("n", "m", $t);
 str_replace("N", "M", $t);
 str_replace("o", "p", $t);
 str_replace("O", "P", $t);
 str_replace("p", "q", $t);
 str_replace("P", "Q", $t);
 str_replace("q", "w", $t);
 str_replace("Q", "W", $t);
 str_replace("r", "t", $t);
 str_replace("R", "T", $t);
 str_replace("s", "d", $t);
 str_replace("S", "D", $t);
 str_replace("t", "y", $t);
 str_replace("T", "Y", $t);
 str_replace("u", "i", $t);
 str_replace("U", "I", $t);
 str_replace("v", "b", $t);
 str_replace("V", "B", $t);
 str_replace("w", "e", $t);
 str_replace("W", "E", $t);
 str_replace("x", "c", $t);
 str_replace("X", "C", $t);
 str_replace("y", "u", $t);
 str_replace("Y", "U", $t);
 str_replace("z", "x", $t);
 str_replace("Z", "X", $t);
 echo "<BR>$t";
 } elseif ($_POST['type'] == 'decript') {
  str_replace("s", "a", $t);
 str_replace("S", "A", $t);
 str_replace("n", "b", $t);
 str_replace("N", "b", $t);
 str_replace("v", "c", $t);
 str_replace("V", "C", $t); 
 str_replace("f", "d", $t);
 str_replace("F", "D", $t);
 str_replace("r", "e", $t);
 str_replace("R", "E", $t);
 str_replace("g", "f", $t);
 str_replace("G", "F", $t);
 str_replace("h", "g", $t);
 str_replace("H", "G", $t);
 str_replace("j", "h", $t);
 str_replace("J", "H", $t);
 str_replace("o", "i", $t);
 str_replace("O", "I", $t);
 str_replace("k", "j", $t);
 str_replace("K", "J", $t);
 str_replace("l", "k", $t);
 str_replace("L", "K", $t);
 str_replace("a", "l", $t);
 str_replace("A", "L", $t); 
 str_replace("z", "m", $t);
 str_replace("Z", "M", $t);
 str_replace("m", "n", $t);
 str_replace("M", "N", $t);
 str_replace("p", "o", $t);
 str_replace("P", "O", $t);
 str_replace("q", "p", $t);
 str_replace("Q", "P", $t);
 str_replace("w", "q", $t);
 str_replace("W", "Q", $t);
 str_replace("t", "r", $t);
 str_replace("T", "R", $t);
 str_replace("d", "s", $t);
 str_replace("D", "S", $t); 
 str_replace("y", "t", $t);
 str_replace("Y", "T", $t);
 str_replace("i", "u", $t);
 str_replace("I", "U", $t);
 str_replace("b", "v", $t);
 str_replace("B", "V", $t);
 str_replace("e", "w", $t);
 str_replace("E", "w", $t);
 str_replace("c", "x", $t);
 str_replace("C", "X", $t);
 str_replace("u", "y", $t);
 str_replace("U", "Y", $t);
 str_replace("x", "z", $t);
 str_replace("X", "z", $t);
 echo "<BR>$t";
}
}
scramble($text);
}
?>
Can you find anything wrong with this script?
It just wont encript.
__________________
Name: Chris Krasnichuk
Email Address:
Please login or register to view this content. Registration is FREE
Chris_krasnichu is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 12-29-2003, 08:16 PM
ACJavascript's Avatar
Humble Mod

Posts: 548
Location: CT, USA
Trades: 0
Hey,

I would put the scrablem($text) function call outside the function.

In order to replace the string as you are trying to do you need to put the new string in a variable. For instance.

$newT=str_replace("a", "s", $t);

echo("<BR>" . $newT);


Try that.
__________________

Please login or register to view this content. Registration is FREE
- 100 Satisfied Customers - Custom Programming and Web Development
ACJavascript is offline
Reply With Quote
View Public Profile Visit ACJavascript's homepage!
 
Old 12-29-2003, 10:28 PM
Chris_krasnichu's Avatar
Ultra Talker

Posts: 331
Location: Ontario, Canada
Trades: 0
ok thanks... I think see see what you mean.
__________________
Name: Chris Krasnichuk
Email Address:
Please login or register to view this content. Registration is FREE
Chris_krasnichu is offline
Reply With Quote
View Public Profile
 
Old 12-30-2003, 06:31 PM
Chris_krasnichu's Avatar
Ultra Talker

Posts: 331
Location: Ontario, Canada
Trades: 0
I'm still not able to make it work.
Heres the modded script:
Code:
<html>
<heaD>
<title></title>
</heaD>
<body>
<form action="safe.php?process=y" method="POST">
Text: <input type="text" name="text" size=40>
<input type="submit" value="Submit"><input type="reset" value="Clear"><BR>
Scrable Text:<input type="radio" name=type value=encript> Descrable Text<input type="radio" name=type value=decript>
</form>
<BR>
<BR>
<BR>
<?php
$get = $_GET['process'];
if ($get == 'y'){

$text = $_POST['text'];

function scramble($t)
{
if ($_POST['type'] == 'encript') {
$t = $t;
$new = str_replace("a", "s", $t);
$new .= str_replace("A", "S", $t);
$new .= str_replace("b", "n", $t);
$new .= str_replace("B", "N", $t);
$new .= str_replace("c", "v", $t);
$new .= str_replace("C", "V", $t);
$new .= str_replace("d", "f", $t);
$new .= str_replace("D", "F", $t);
$new .= str_replace("e", "r", $t);
$new .= str_replace("E", "R", $t);
$new .= str_replace("f", "g", $t);
$new .= str_replace("F", "G", $t);
$new .= str_replace("g", "h", $t);
$new .= str_replace("G", "H", $t);
$new .= str_replace("h", "j", $t);
$new .= str_replace("H", "J", $t);
$new .= str_replace("i", "o", $t);
$new .= str_replace("I", "O", $t);
$new .= str_replace("j", "k", $t);
$new .= str_replace("J", "K", $t);
$new .= str_replace("k", "l", $t);
$new .= str_replace("K", "L", $t);
$new .= str_replace("l", "a", $t);
$new .= str_replace("L", "A", $t);
$new .= str_replace("m", "z", $t);
$new .= str_replace("M", "Z", $t);
$new .= str_replace("n", "m", $t);
$new .= str_replace("N", "M", $t);
$new .= str_replace("o", "p", $t);
$new .= str_replace("O", "P", $t);
$new .= str_replace("p", "q", $t);
$new .= str_replace("P", "Q", $t);
$new .= str_replace("q", "w", $t);
$new .= str_replace("Q", "W", $t);
$new .= str_replace("r", "t", $t);
$new .= str_replace("R", "T", $t);
$new .= str_replace("s", "d", $t);
$new .= str_replace("S", "D", $t);
$new .= str_replace("t", "y", $t);
$new .= str_replace("T", "Y", $t);
$new .= str_replace("u", "i", $t);
$new .= str_replace("U", "I", $t);
$new .= str_replace("v", "b", $t);
$new .= str_replace("V", "B", $t);
$new .= str_replace("w", "e", $t);
$new .= str_replace("W", "E", $t);
$new .= str_replace("x", "c", $t);
$new .= str_replace("X", "C", $t);
$new .= str_replace("y", "u", $t);
$new .= str_replace("Y", "U", $t);
$new .= str_replace("z", "x", $t);
$new .= str_replace("Z", "X", $t);
 echo "<BR>$new";
 } elseif ($_POST['type'] == 'decript') {
$t = $t;
$new = str_replace("s", "a", $t);
$new .= str_replace("S", "A", $t);
$new .= str_replace("n", "b", $t);
$new .= str_replace("N", "b", $t);
$new .= str_replace("v", "c", $t);
$new .= str_replace("V", "C", $t); 
$new .= str_replace("f", "d", $t);
$new .= str_replace("F", "D", $t);
$new .= str_replace("r", "e", $t);
$new .= str_replace("R", "E", $t);
$new .= str_replace("g", "f", $t);
$new .= str_replace("G", "F", $t);
$new .= str_replace("h", "g", $t);
$new .= str_replace("H", "G", $t);
$new .= str_replace("j", "h", $t);
$new .= str_replace("J", "H", $t);
$new .= str_replace("o", "i", $t);
$new .= str_replace("O", "I", $t);
$new .= str_replace("k", "j", $t);
$new .= str_replace("K", "J", $t);
$new .= str_replace("l", "k", $t);
$new .= str_replace("L", "K", $t);
$new .= str_replace("a", "l", $t);
$new .= str_replace("A", "L", $t); 
$new .= str_replace("z", "m", $t);
$new .= str_replace("Z", "M", $t);
$new .= str_replace("m", "n", $t);
$new .= str_replace("M", "N", $t);
$new .= str_replace("p", "o", $t);
$new .= str_replace("P", "O", $t);
$new .= str_replace("q", "p", $t);
$new .= str_replace("Q", "P", $t);
$new .= str_replace("w", "q", $t);
$new .= str_replace("W", "Q", $t);
$new .= str_replace("t", "r", $t);
$new .= str_replace("T", "R", $t);
$new .= str_replace("d", "s", $t);
$new .= str_replace("D", "S", $t); 
$new .= str_replace("y", "t", $t);
$new .= str_replace("Y", "T", $t);
$new .= str_replace("i", "u", $t);
$new .= str_replace("I", "U", $t);
$new .= str_replace("b", "v", $t);
$new .= str_replace("B", "V", $t);
$new .= str_replace("e", "w", $t);
$new .= str_replace("E", "w", $t);
$new .= str_replace("c", "x", $t);
$new .= str_replace("C", "X", $t);
$new .= str_replace("u", "y", $t);
$new .= str_replace("U", "Y", $t);
$new .= str_replace("x", "z", $t);
$new .= str_replace("X", "Z", $t);
 echo "<BR>$new";
}
}
scramble($text);
}
?>
</body>
</html>
Could someone help.
__________________
Name: Chris Krasnichuk
Email Address:
Please login or register to view this content. Registration is FREE
Chris_krasnichu is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Just a script thats not working.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.16146 seconds with 12 queries