Reply to Re: formmail blues

Your name:

Reply:


Posted by shimmyshack on 06/26/07 03:38

On Jun 25, 5:51 pm, zircher <tzirc...@yahoo.com> wrote:
> I'm working on a little dice server e-mail utility for my gaming
> needs.
>
> The problem is that the content string that I send to formmail.php is
> not the content string that gets e-mailed to me.
>
> For example, the javascript generates...
>
> Roll #1: 2d10 [10,2] = 12
> Roll #2: 2d10 [3,7] = 10
> Roll #3: 2d10 [9,6] = 15
> Roll #4: 2d10 [9,5] = 14
> Roll #5: 2d10 [7,6] = 13
> Roll #6: 2d10 [1,6] = 7
> Roll #7: 2d10 [6,8] = 14
> Roll #8: 2d10 [2,6] = 8
> Roll #9: 2d10 [10,7] = 17
> Roll #10: 2d10 [5,1] = 6
>
> But the e-mail that I get has truncated data...
>
> Roll #1: 2d10 [10,2] =2
> Roll #2: 2d10 [3,7] =0
> Roll #3: 2d10 [9,6] =5
> Roll #4: 2d10 [9,5] =4
> Roll #5: 2d10 [7,6] =3
> Roll #6: 2d10 [1,6] =
> Roll #7: 2d10 [6,8] =4
> Roll #8: 2d10 [2,6] =
> Roll #9: 2d10 [10,7] =7
> Roll #10: 2d10 [5,1] =
>
> The dice server page uses to work properly. My guess is that my ISP
> has done something to PHP on the server. I know that since I had to
> change the formmail.php script to use $_POST. (Disabling global
> registers) Was there a version change in PHP that would cause it to
> incorrectly parse that text? Perhaps an HTML conversion that's
> getting in the way when $_POST is used versus global variables?
>
> Thoughts?
> --
> TAZ

without seeing the full markup I dont want to guess at why this is
happening, but it doesnt sound like you were using a very good host or
good php code, the way I would do this would be to have javscript
create the following, then set the value for a text box and post the
form

depending on the reason for submission you could use GET as well as
POST, use the correct one whether the app is cahging state, or whether
you are getting info based on that submission.

<script type="text/javascript">
function submitTheForm( strThrows )
{
document.form.throws.value = strThrows;
document.form.submit();
}

//throw dice, formulate strThrows,
var strThrows = '10,2|3,7|9,6|9,5|7,6|1,6|6,8|2,6|10,7|5,1';
//call function
submitTheForm( strThrows );
</script>

<form method="post" name="form">
<input type="hidden" name="throws" />
</form>


then the php would be

<?php

//now throw 0 is 10,2
//and throw 1 is 3,7

$arrayThrows = split( '|', $_POST['throws'] );

$arrayIndividualThrow = split( ',', $arrThrows[$n-1] );
you can then add
$arrayIndividualThrow[0] + $arrayIndividualThrow[1]
?>

or of course to use GET, you woudl just have the following:
<script type="text/javascript">
function submitTheForm( strThrows )
{
document.form.action = 'script.php?'+strThrows;
document.form.submit();
}

//throw dice, formulate strThrows,
var strThrows =
'1=10,2&2=3,7&3=9,6&4=9,5&5=7,6&6=1,6&7=6,8&8=2,6&9=10,7&10=5,1';
//call function
submitTheForm( strThrows );
</script>

<form method="post" name="form">
<input type="hidden" name="throws" />
</form>


then the php would be

<?php
//where $n is the number of the
//throw you are interested in
$arrayIndividualThrow = split( ',', $_GET[$n] );
//you can then add
$arrayIndividualThrow[0] + $arrayIndividualThrow[1]
?>

or just
var strThrows =
't[]=10,2&t[]=3,7&t[]=9,6&t[]=9,5&t[]=7,6&t[]=1,6&t[]=6,8&t[]=2,6&t[]=10,7&t[]=5,1';
so the php becomes
<?php
$arrayIndividualThrow = split( ',', $_GET['t'][$n] );
//where n is the throw you are interested in
$arrayIndividualThrow[0] + $arrayIndividualThrow[1]
?>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация