frankienrg
Members-
Posts
21 -
Joined
-
Last visited
Never
Profile Information
-
Gender
Not Telling
frankienrg's Achievements
Newbie (1/5)
0
Reputation
-
Problem with PHP and form's textarea: $_POST not returning values
frankienrg replied to frankienrg's topic in PHP Coding Help
Gee, I was going mad. Such a stupid mistake. Lost a good 2hours of work! THANK YOU! Problem solved! -
The Form: <form action="pagina5.php" method="post"> <table align="center" width="500"> <tr><td align="right">Nome:</td><td><input type="text" maxlength="35" size="35" name="nome" /><td></tr> <tr><td align="right">E-mail:</td><td><input type="text" maxlength="40" size="35" name="email" /><td></tr> <tr><td align="right">Voto:</td><td><select name="voto"><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option selected="selected" value="5">5</option></select><td></tr> <tr><td align="center" colspan="2"> *Commento:</td></tr> <tr><td align="center" colspan="2"><textarea rows="7" cols="50" name="commento"></textarea></td></tr> <tr><td align="center" colspan="2"><input type="submit" name="invia" value="Invia"><input type="reset" value="Resetta"></td></tr> <tr><td align="center" colspan="2"><a href="gb.php">Torna Indietro</a></td></tr> <tr><td align="center" colspan="2"><br/><br/>* = Campi Obbligatori</td></tr> </table> </form> the script (pagina5.php): <? if (isset($_POST['invia'])) { if((!isset($_POST['commento'])) OR ($_POST['commento']="")) { echo "<p align='center'>Non hai compilato i campi richiesti!</p>"; echo "<p align='center'><br/><a href='gb.php'>Torna Indietro</a></p>"; } else { var_dump($_POST['nome']); var_dump($_POST['email']); var_dump($_POST['commento']); var_dump($_POST['voto']); //var_dump($x); echo "<p align='center'><br/><a href='gb.php'>Torna Indietro</a></p>"; } } ?> vardumps work correctly for any value except the textarea (commento). It skips the if (!isset) check, too. I tried using an ID, too, couldn't get it to work I'm at a lost here, please help, fellow coders.
-
script modifying float values gives integer
frankienrg replied to frankienrg's topic in PHP Coding Help
nevermind, found it $prezzo = number_format($prezzo, 2, '.', ''); $prezzo = $prezzo+number_format(($prezzo/$ricarico), 2, '.', ''); -
I know I may sound like a nab, but here I go: $ric=10; $price=$price+($price/$ric); Basically I want to add a 10% to the price value this is inside a "for", and price values is taken from a csv file. Said value is for example: $price=4,36 after the script takes place, the value goes to: $price=4796 While i aimed to obtain 4,80 (a 2 precision float). Can anyone help me? It's the first time I mess with float numbers. EDIT: Or at least direct me to a more efficient way to apply % on doubles, while preserving the original precision
-
Sorry to be reviving this topic, but I actually solved the problem, here's the script: $giornata = $_GET['mcc']; ##AREA CONFIGURABILE## $nome_file = "mcc".$giornata; $input = $nome_file.".rcs"; $output = $nome_file.".txt"; $ultima_riga = 2; // 0=SI 2=NO $chiave = array('72', '2A', '67', '66', '64', '34', '56', '42', '48', '34', '34', '46', '46', '35', '52', '38', '73', '78', '2A', '63', '33', '33', '66', '34', '66', '45', '45', '32'); ##FINE CONFIGURAZIONE## if (file_exists($input)) { $fs_read = fopen($input, "r+"); $fs_write = fopen($output, "w+"); $lBytes = filesize($input); $lBytes_28 = $lBytes % 28; $lDiff = ($lBytes)-($lBytes_28); while (ftell($fs_read) != $lDiff) { $fileData = fread($fs_read, 28); for ($i=0; $i<28; $i++) { $data = hexdec(bin2hex($fileData[$i])); $key = hexdec($chiave[$i]); $result = $data ^ $key; fwrite($fs_write, chr($result)); } } $fileData = fread($fs_read, $lBytes_28); for ($i=0; $i<($lBytes_28-$ultima_riga); $i++) { $data = hexdec(bin2hex($fileData[$i])); $key = hexdec($chiave[$i]); $result = $data ^ $key; fwrite($fs_write, chr($result)); } fclose($fs_read); fclose($fs_write); echo "File: <a href='$output'><b>$output</b></a>"; echo "<br /><b>Stats:</b><br />Lunghezza file: $lBytes<br/>Primo passaggio: $lDiff<br/>Secondo passaggio: $lBytes_28"; } else { echo "File: <a href='$input'><b>$input</b></a> non trovato<br />Istruzioni es.: convertitore.php?mcc=7"; } use it through GETs: decrypter.php?mcc=10 for the file named mcc10.rcs, it will get you a mcc10.txt.
-
Fatal error: Call to undefined function X]H() in mcc.php on line 15 last version... <?php $fs_read = fopen("mcc05.rcs", "r+"); $fs_write = fopen("mcc05.txt", "w+"); $lBytes = filesize("mcc05.rcs"); $lBytes_28 = $lBytes % 28; $lDiff = ($lBytes)-($lBytes_28); $chiave = array('2A', '68', '6C', '34', '35', '6A', '6E', '31', '32', '64', '66', '67', '46', '46', '44', '52', '38', '73', '78', '63', '33', '33', '64', '65', '72', '66', '76', '2A'); while (ftell($fs_read) != $lDiff) { $fileData = fread($fs_read, 28); $prefix = "0x"; for ($i=0; $i<28; $i++) { fwrite($fs_write, (chr($fileData($i) xor $prefix.$chiave($i)))); } } for ($i=0; $i<lBytes_28; $i++) { fwrite($fs_write, (chr($fileData($i) xor $prefix.$chiave($i)))); } fclose($fs_read); fclose($fs_write); ?>
-
ok, I think i got most out of it... <?php $fs_read = fopen("mcc05.rcs", "r+"); $fs_write = fopen("mcc05.txt", "w+"); $lBytes = filesize("mcc05.rcs"); $lBytes_28 = $lBytes % 28; $lDiff = ($lBytes)-($lBytes_28); $chiave = array('2A', '68', '6C', '34', '35', '6A', '6E', '31', '32', '64', '66', '67', '46', '46', '44', '52', '38', '73', '78', '63', '33', '33', '64', '65', '72', '66', '76', '2A'); while (ftell($fs_read) != $lDiff) { $fileData = fread($fs_read, 28); for ($i=0; $i<28; $i++) { fwrite($fs_write, (chr($fileData($i) xor “&H” & $chiave($i)))); } } $i = 0; for ($i=0; $i<(lBytes_28–1); $i++) { fwrite($fs_write, (chr($fileData($i) xor “&H” & $chiave($i)))); } $fclose($fs_read); $fclose($fs_write); ?> but i'm getting an error on this: fwrite($fs_write, (chr($fileData($i) xor “&H” & $chiave($i)))); I don't know how to convert this damn string: fs_write.Write(Chr(fileData(i) Xor “&H” & chiave(i))) from VB.NET to PHP. I think it's the only last step I have to do :S
-
well well, i thinks it's the way you pass the variable that doesn't work: the url should be: http://www.somedomain.com/index.php?linknum=8
-
well, thanks for the fast reply, but what I'm really looking for, is not the fix for my php adaption (because I already know that it wouldn't work). It is really a bad adaption. The purpose of me posting my semi-conversion is to give who wants to help me out, something to start with the conversion of the VB.NET code snippet i posted EDIT: btw, that's the error: [06-Apr-2010 10:35:45] PHP Parse error: syntax error, unexpected T_STRING in /home/horseden/public_html/meeee/mcc.php on line 9
-
how to? selecting multipe rows displaying as checkboxes?
frankienrg replied to shane85's topic in PHP Coding Help
simple as a pie: $checkboxes = array($check[0], $check[1], $check[2], $check[3]); // values for your checkboxes foreach ($checkboxes as $key => $checkbox) { echo '<input type="checkbox" id="', $checkbox . $key, '" name="locations[]" value="', $checkbox, '"', (in_array($checkbox, $check) ? ' checked="checked"' : ''), '>', '<label for="', $checkbox . $key, '">', $checkbox, '</label>'; } -
Hi everyone! I'm trying to convert this VB.NET function: Dim fs_read As New FileStream(“C:\MCC05.rcs”, FileMode.Open, FileAccess.Read) Dim fs_write As New StreamWriter(File.Create(fs_read.Name.Replace(“.rcs”, “.txt”))) Dim lBytes As Long = fs_read.Length Dim fileData(lBytes) As Byte Dim i As Integer Dim lbytes_27 As Long = lBytes Mod 27 ‘ sono i byte che restano fuori dividendo il file a gruppi di 27 byte Dim chiave As Array chiave = Split(“31;32;33;34;35;36;61;62;63;64;65;66;71;71;77;65;72;74;79;75;61;73;64;66;67;68;6A”, “;”) While Not fs_read.Position = lBytes – lbytes_27 fs_read.Read(fileData, 0, 27) For i = 0 To 26 fs_write.Write(Chr(fileData(i) Xor “&H” & chiave(i))) Next End While i = 0 fs_read.Read(fileData, 0, lbytes_27) For i = 0 To (lbytes_27 – 1) fs_write.Write(Chr(fileData(i) Xor “&H” & chiave(i))) Next fs_read.Close() fs_write.Close() into PHP code. That's what i made: <?php $fs_read = fopen("mcc05.rcs", "r+"); $fs_write = fopen("mcc05.txt", "w+"); $lBytes = $fs_read; $lBytes_28 = $lBytes % 28; $chiave = array('2A', '68', '6C', '34', '35', '6A', '6E', '31', '32', '64', '66', '67', '46', '46', '44', '52', '38', '73', '78', '63', '33', '33', '64', '65', '72', '66', '76', '2A'); while (ftell($fs_read) != ($lBytes – $lBytes_28)) { $fileData = fread($fs_read, 28); for ($i=0; $i<27; $i++ { fwrite($fs_write, (chr($fileData($i) xor “&H” & $chiave($i)))); } } $i = 0 for ($i=0; $i<(lBytes_28 – 1); $i++ { fwrite($fs_write, (chr($fileData($i) xor “&H” & $chiave($i)))); } $fclose($fs_read); $fclose($fs_write); ?> Obviously it doesn't work (give me an error at line 9), but I think it's still a BAD CODE, and even if I fixed the erros, it wouldn't work. I don't understand well VB code, so I think I lost something in the conversion! Will rep+ if some of you could translate the original VB.NET code to PHP, thanks!
-
[SOLVED] How to "grab" only CAPITAL words from strings
frankienrg replied to frankienrg's topic in PHP Coding Help
only uppercase words! your code works like a charm now! thx for your help! -
[SOLVED] How to "grab" only CAPITAL words from strings
frankienrg replied to frankienrg's topic in PHP Coding Help
seems like your code doesn't work if there's just one word in the string, fixed with this: $string = ""; //Here Goes the string $string_count = count(explode(' ', $string)); if ($string_count == 1) $output = $string; else { preg_match("~((?:[A-Z]+\s)+)~m", $string, $output); $output = $output[0]; } -
[SOLVED] How to "grab" only CAPITAL words from strings
frankienrg replied to frankienrg's topic in PHP Coding Help
this preg_match("~[A-Z\s]+~", $string1, $M); $string1 = $M[1]; returns nothing this preg_match_all("~((?:[A-Z]+\s)+)~m", $contents, $M); $M = $M[0]; this returns "Array". using the last code you provided, if i use preg_match, instead of preg_match_all, I get ALMOST perfect result... but not for one string.. $string5= "LUCIO"; after the preg_match returns nothing! -
[SOLVED] How to "grab" only CAPITAL words from strings
frankienrg replied to frankienrg's topic in PHP Coding Help
I guess I should make it more simple; I got: $string1= "JULIO CESAR Soares De Espinola"; $string2= "GROSSO Fabio"; $string3= "DE ROSSI Daniele"; $string4= "CAMBIASSO Esteban Matias"; $string5= "LUCIO"; $string6= "THIAGO MOTTA"; [code] What I want to do is to obtain this: [code] $final_string1= "JULIO CESAR"; $final_string2= "GROSSO"; $final_string3= "DE ROSSI"; $final_string4= "CAMBIASSO"; $final_string5= "LUCIO"; $final_string6= "THIAGO MOTTA"; [code] I want to obtain this with an automated function. Hope you can help me