<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1018242" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1018242</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106997</link>
    <description> &lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I have some experience with Flash scripting, yes. Not much &#039;raw&#039; experience, but rather using Flash 5 and click and point to select the code and actions needed.&lt;/p&gt;
&lt;p&gt;What you&#039;re trying to do with PHP/Perl sounds simple. You don&#039;t *have* to have a database backend, a flat-file backend will be fine. Well, it does depend on the number of uses you have too. How many gamers are we talking here?&lt;/p&gt;
&lt;p&gt;Sure, I&#039;m more than willing to help you out - keep your dollars in your pocket, though - if I can help you out through TWF then the whole community benefits which is worth more than any dollar, IMO. And it gives others a chance to chip in with their $.02. I learned a lot from these style of communities and I&#039;m a great believer in them.&lt;/p&gt;
&lt;p&gt;Right then, back to business... what are the next steps here. I&#039;m not sure that the program you have is necessarily &#039;broken&#039;. I&#039;m sure what you have can be tweaked rather easily. Send me a copy to &lt;a href=&quot;mailto:wil@stephens.org&quot; class=&quot;bb-email&quot;&gt;wil@stephens.org&lt;/a&gt; and I&#039;ll take a look at it from there. Have you got a working url for the flash as well?&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
 </description>
     <pubDate>Tue, 16 Apr 2002 09:46:27 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1106997 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I&#039;m confused too!</title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106976</link>
    <description> &lt;p&gt;I&#039;ve looked around for something, but this script was the closest I could find.  I thought I had it figured, but I just realized that I don&#039;t think there is a way to get the database to show highscores...&lt;/p&gt;
&lt;p&gt;As a preface (I&#039;m creating a multi-level game in Macromedia Flash)&lt;/p&gt;
&lt;p&gt;Here&#039;s my objectives for a perl (or php) script:&lt;/p&gt;
&lt;p&gt;A simple database that contains username, password, email address (optional) and level.&lt;/p&gt;
&lt;p&gt;To access the database for the following purposes,&lt;/p&gt;
&lt;p&gt;-Write to database from macromedia flash SWF file to create a database of the above mention data (registration).&lt;/p&gt;
&lt;p&gt;-Read database from flash SWF file (login) to so that the flash file can send the user to the correct level (game).&lt;/p&gt;
&lt;p&gt;-ReWrite to existing database to change the level variable.&lt;/p&gt;
&lt;p&gt;-Read database from flash or html to display users sorted by level variable.&lt;/p&gt;
&lt;p&gt;I know my host supports PHP because I ran a phpinfo.php3 on it and it gave all the info on it.  But, I&#039;ve never used telnet and can&#039;t figure out how to create a database.  So, after not finding any php that work with flash for this purpose, I gave up on that.  The closest perl script I&#039;ve been able to find to do this is the one I posted previously, but it appears ill-suited and flawed.&lt;/p&gt;
&lt;p&gt;My question to you, Wil, is do you have any familiarity with Flash Actionscript.  It was written based on javascripting language.  This is the type of thing that would probably be easy for you on the perl end, but if you don&#039;t know flash, it may not be so easy.&lt;/p&gt;
&lt;p&gt;How hard would it be for you to write something like this from scratch.  (and do you accept donations via paypal)  &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Mon, 15 Apr 2002 20:23:19 +0000</pubDate>
 <dc:creator>zen</dc:creator>
 <guid isPermaLink="false">comment 1106976 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106974</link>
    <description> &lt;p&gt;OK. Now I&#039;m totally confused as to what you&#039;re trying to do &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;Did you get that level bit sorted or have you abandoned the idea? Can I ask where did you get the script from - I might know of better alternatives lying around, or I can help you fix this one up to work again.&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
 </description>
     <pubDate>Mon, 15 Apr 2002 19:51:51 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1106974 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106855</link>
    <description> &lt;p&gt;That is what I will do.&lt;/p&gt;
&lt;p&gt;I will just make a separate copy of the cgi script for every level in the game.  When the user first registers, it will write their data to a database assigned to level-1 using the script for registering at level-1.  Because of this, I no longer have to write a variable &#039;lev&#039; because every entry in that database will be level-1.  When the user starts the next level, I will pass the username and password to the flash file for that level, so that it can write those variables if the user completes level-2 using the script for level-2.  Then the level-2 database will contain only the names of level-2 users.  When a user leaves the game and returns to log in, I will include a field that asks which level they wish to resume at, and have flash access the appropriate login-script for that level.  This also gives the advantage of login in at a lower level if they wish.&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 16:27:46 +0000</pubDate>
 <dc:creator>zen</dc:creator>
 <guid isPermaLink="false">comment 1106855 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106853</link>
    <description> &lt;p&gt;Okay, I now realize that I will probaby not be able to use this script this way..&lt;/p&gt;
&lt;p&gt;So far, I have been able to successfully use the script to write four things into the database: username, password, email, and level.  The first 2 were a part of the script when I got it. I am also successfully at recieving username &amp;amp; password back into flash.&lt;/p&gt;
&lt;p&gt;Aside from the problem that I cannot get the script to send email and lev back to flash, I now recognize that the script was not made to change an entry after it is made.  In other words, it appears to me by looking at this script that I cannot use the script to make lev=2 after it has already been written as lev=1.&lt;/p&gt;
&lt;p&gt;I think the only way that I can solve this problem is to set it up so that a user can register at level 1 (after the completed the intro level (0)) and when they complete level 1, the will be forwarded to a flash scene that uses a second (very similar to registratioN) scene that access a copy of the script with a different name that will write a new database for lev=2 users.  So, if I do it that way, I can get around the fact that this script cannot change the database, but...&lt;/p&gt;
&lt;p&gt;I still need to get the lev varable back out of the database.&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 16:01:06 +0000</pubDate>
 <dc:creator>zen</dc:creator>
 <guid isPermaLink="false">comment 1106853 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106849</link>
    <description> &lt;p&gt;I tried that and now the flash sits there trying to log in.&lt;/p&gt;
&lt;p&gt;Perhaps I pasted it wrong.  I will try again.&lt;/p&gt;
&lt;p&gt;What does flash look like.  Well, for right now, I have the flash setup so that after you hit the login button (with the code) it forwards to a scene where it shows you all the data in the file ( this is for me so I can tell if it&#039;s working ), but right now it only gets back the username and password.&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 15:39:30 +0000</pubDate>
 <dc:creator>zen</dc:creator>
 <guid isPermaLink="false">comment 1106849 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106848</link>
    <description> &lt;p&gt;OK. What about where the information is returned to when the user logs in again. What does your flash/non flash buttons look like then?&lt;/p&gt;
&lt;p&gt;Did you try what I posted above? That might work on extracting the &#039;lev&#039; out of the database. If not, I&#039;ll try something different.&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 15:27:15 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1106848 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>here&#039;s the stuff</title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106843</link>
    <description> &lt;p&gt;Wil,&lt;br /&gt;
I don&#039;t want to take advantage, but you seem so willing to help and I am so lost when it comes to programming!&lt;/p&gt;
&lt;p&gt;Here is the script minus the header:&lt;/p&gt;
&lt;p&gt;use strict;&lt;br /&gt;
use CGI qw(:standard);&lt;br /&gt;
use CGI::Carp qw(fatalsToBrowser);&lt;/p&gt;
&lt;p&gt;my $acc_file         = &#039;accounts&#039;;&lt;br /&gt;
my @required_fields = qw(username password);&lt;/p&gt;
&lt;p&gt;unless ( -f $acc_file) {&lt;br /&gt;
	(open(ACC, &quot;&amp;gt;$acc_file&quot;) &amp;amp;&amp;amp; close(ACC) &amp;amp;&amp;amp; chmod 0600, $acc_file) || die &quot;cannot create user database&quot;;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;my $query = CGI-&amp;gt;new();&lt;br /&gt;
my $error;&lt;br /&gt;
$error = &#039;not enough parameters&#039; unless $query-&amp;gt;param(&#039;action&#039;);&lt;/p&gt;
&lt;p&gt;print CGI-&amp;gt;header( -type=&amp;gt;&#039;text/plain&#039; );&lt;/p&gt;
&lt;p&gt;if ($query-&amp;gt;param(&#039;action&#039;) eq &#039;new&#039;) {&lt;br /&gt;
    if (open(ACC, &quot;$acc_file&quot;)) {&lt;br /&gt;
        while (my $username = CGI-&amp;gt;new(\*ACC)-&amp;gt;param(&#039;username&#039;)) {&lt;br /&gt;
            if ($username eq $query-&amp;gt;param(&#039;username&#039;)) {&lt;br /&gt;
                ($error = &#039;username already exists&#039;);&lt;br /&gt;
                last;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
        close(ACC);&lt;br /&gt;
    } else {&lt;br /&gt;
        $error = &#039;unable to open user database&#039;;&lt;br /&gt;
    }&lt;/p&gt;
&lt;p&gt;    if ( !$error&lt;br /&gt;
	 &amp;amp;&amp;amp; (@required_fields == grep { $query-&amp;gt;param($_) } @required_fields) ) {&lt;br /&gt;
        $query-&amp;gt;delete(&#039;action&#039;);&lt;br /&gt;
        if (open(ACC, &quot;&amp;gt;&amp;gt;$acc_file&quot;)) {&lt;br /&gt;
            $query-&amp;gt;save(\*ACC);&lt;br /&gt;
            close(ACC);&lt;br /&gt;
        } else {&lt;br /&gt;
            $error = &#039;unable to open user database&#039;;&lt;br /&gt;
        }&lt;br /&gt;
    } else {&lt;br /&gt;
        $error ||= &quot;not enough parameters&quot;;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;if ($query-&amp;gt;param(&#039;action&#039;) eq &#039;check&#039;) {&lt;/p&gt;
&lt;p&gt;    my $found = undef;&lt;br /&gt;
    if (open (ACC, $acc_file)) {&lt;br /&gt;
        while ( my $query1 = CGI-&amp;gt;new(\*ACC)) {&lt;br /&gt;
                (my $username = $query1-&amp;gt;param(&#039;username&#039;)) || last;&lt;br /&gt;
                ($username eq $query-&amp;gt;param(&#039;username&#039;))&lt;br /&gt;
                and ($query1-&amp;gt;param(&#039;password&#039;) eq $query-&amp;gt;param(&#039;password&#039;))&lt;br /&gt;
		and $found++;&lt;br /&gt;
        }&lt;/p&gt;
&lt;p&gt;        close(ACC);&lt;br /&gt;
	$error = $found ? undef : &#039;incorrect username/password&#039;;&lt;br /&gt;
    } else {&lt;br /&gt;
        $error = &#039;unable to open user database&#039;;&lt;br /&gt;
    }&lt;/p&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;my $status = $error || &#039;Ok&#039;;&lt;br /&gt;
print &quot;status=$status&quot;;&lt;/p&gt;
&lt;p&gt;also in that folder goes the .htaccess file which looks like this:&lt;/p&gt;
&lt;p&gt;    Order allow,deny&lt;br /&gt;
    Deny from all&lt;/p&gt;
&lt;p&gt;The script writes to a file called accounts&lt;/p&gt;
&lt;p&gt;and the button in flash after I modified it: &lt;/p&gt;
&lt;p&gt;on (release) {&lt;br /&gt;
    loadVariablesNum (&quot;http://www.mydomain.com/cgi-bin/access.cgi?action=&quot; + _root.query +&quot;&amp;amp;username=&quot; + _root.username + &quot;&amp;amp;password=&quot; + _root.password + &quot;&amp;amp;email=&quot; + _root.email + &quot;&amp;amp;lev=&quot; + _root.lev, 0);&lt;br /&gt;
    gotoAndPlay (2);&lt;br /&gt;
    _root.status = 5;&lt;br /&gt;
}&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 15:19:48 +0000</pubDate>
 <dc:creator>zen</dc:creator>
 <guid isPermaLink="false">comment 1106843 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106842</link>
    <description> &lt;p&gt;Aha. Bingo. Now I get it. Oh my god, that&#039;s a silly way of doing things. Basically, what the script is doing is keep all your name/value variables in the hash %query and then what it&#039;s doing is read the file and split the name/value pairs (that&#039;s why they&#039;re deliminated by a =) and load them into the env. var. %query1. My gosh, that&#039;s ugly.&lt;/p&gt;
&lt;p&gt;Anyway, you want to set the var. &quot;lev&quot; (not &quot;level&quot; as this is how it&#039;s written in the file) to be the value in the database. An ugly way to do this would be just to edit it to:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;my $found = undef; &lt;br /&gt;if (open (ACC, $acc_file)) { &lt;br /&gt;while ( my $query1 = CGI-&amp;gt;new(\*ACC)) { &lt;br /&gt;(my $username = $query1-&amp;gt;param(&amp;#039;username&amp;#039;)) || last; &lt;br /&gt;($username eq $query-&amp;gt;param(&amp;#039;username&amp;#039;)) &lt;br /&gt;and ($query1-&amp;gt;param(&amp;#039;password&amp;#039;) eq $query-&amp;gt;param(&amp;#039;password&amp;#039;)) &lt;br /&gt;and $found++; &lt;br /&gt;$query-&amp;gt;param(&amp;#039;lev&amp;#039;) = $query1-&amp;gt;param(&amp;#039;lev&amp;#039;);&lt;br /&gt;} &lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;Try that and see what it does.&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 15:15:49 +0000</pubDate>
 <dc:creator>Wil</dc:creator>
 <guid isPermaLink="false">comment 1106842 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>yes</title>
    <link>https://www.webmaster-forums.net/server-side-scripting/programming-noob-needs-perl-help#comment-1106837</link>
    <description> &lt;p&gt;Yes, it&#039;s writting one file, not individual files.  I just thought it was curious that it would use the = as a seperator or delimitor (or whatever the technical term is) when it&#039;s using those to equate the variable name with the variable.&lt;/p&gt;
&lt;p&gt;Yes, I have will have it set so that when the user registers, lev=1, and when the user completes a level, flash will access the script and change it.  Oh, hehe, I haven&#039;t done that part yet and I&#039;m starting to scratch my head.  hehe... how will I do that?&lt;/p&gt;
&lt;p&gt;Anyway, thankyou soooo much for your amazingly fast responses!!!!&lt;/p&gt;
 </description>
     <pubDate>Sun, 14 Apr 2002 14:55:26 +0000</pubDate>
 <dc:creator>zen</dc:creator>
 <guid isPermaLink="false">comment 1106837 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
