SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: Need a server side PHP script

  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Eire
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need a server side PHP script

    I'm in need of a server side PHP script that will allow a viewer to enter in numerical amounts and get a total at the end of the list.

    I don't know code beyond html so the simpler the better. Does anyone know of one, or have one, that can be used for this purpose? Thanks.
    Raven Bren
    NS 4.75, 800x600-1024x768, T1 cable, Win "98

  2. #2
    SitePoint Member seven - two's Avatar
    Join Date
    Aug 2001
    Posts
    21
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    all php is server side

    should be simple enough to write one on your own with a lil reference to the manual at the PHP website, I have found it really useful.

    Hope that helps,
    ¤7wo
    ¤7wo

  3. #3
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Need a server side PHP script

    Do you have an example of the page you're talking about? A sample form to see how much data you're working with would be helpful.
    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Eire
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seven-two, I said I didn't know much about anything but html...LOL. Thanks for the link, I'll take a look at it.

    VPHost, I made up a sample page of the info that would be used for this. Just did this now in 5 mins so very rough, bear with me. Text may be lenghtened and changed a bit, but this is what I'd like it for. Hope this helps.

    http://3moons.net/CastleRaven/award/score_test.html
    Raven Bren
    NS 4.75, 800x600-1024x768, T1 cable, Win "98

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What should happen at this point?

    1) this page is submitted, a page appears with info about your score, generic text based on what range the score is in, and other helpful info?

    2) the user gets a number. end of story. have a nice day


    For Answer 1) you're in the right place, and a little bit of php should fill the bill.

    For Answer 2) you need to look at javascript(or some other client side script) to do this. Still shouldn't be more than about a half a dozen lines of code, but I don't do javascript.


    PS: I know you said this is draft, but I think "Min" should be expaned to "Minus" where appropriate. Took me a few seconds to figure it out.
    Last edited by Slade; Aug 4, 2001 at 21:01.
    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.

  6. #6
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Eire
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually I would prefer option 1. they would get a page stating that their score is good enough, blah blah blah, or saying not at this time.

    What do you suggest I do?
    Raven Bren
    NS 4.75, 800x600-1024x768, T1 cable, Win "98

  7. #7
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I suggest...

    that you look here http://aktzero.com/formcount/

    I built and tested it enough to know that it worked for me. I will try and help you with it if I can, but no warranty.

    Your mileage may vary, and there may be weather tomorrow.

    PS: aktzero is my personal site, but please don't look there, I've not had time to do anything to it
    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.

  8. #8
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Eire
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is great! I'm trying it and it seems to be working so far. I'm confused about one thing though, where do I place the "result.php" script? Do I enter it in the page with the "theform" script or on the page that they will be directed to, or a file in itself?

    Does it go in the <body> of a page or in the in the <head> .
    Raven Bren
    NS 4.75, 800x600-1024x768, T1 cable, Win "98

  9. #9
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The way the script is set up, all the files should be in the same directory. In the case of the example, in award/. That is probably the easiest thing to do.

    Look at the source for the theform.html on my site and you should easily be able to pick out the important parts, ie the <form ...> and the <input type =text...> blocks. It looks like you got most of this.

    However, for this script to work as easily as it was meant to, I suggest you change all the input text boxes names to item plus a number. That is the only way the script will find and count them.

    item1 item2...

    also, after you finish that, go back in the result.php and change the $numitems to your number of items.
    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.

  10. #10
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Eire
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I understand theform.html, and will change the imput text to numbers. But what do I do with the result.php. Is it a seperate file in the directory?

    Never mind, I just figured out where it goes. Can I have some items add and some subtract?
    Last edited by Raven_Bren; Aug 5, 2001 at 12:41.
    Raven Bren
    NS 4.75, 800x600-1024x768, T1 cable, Win "98

  11. #11
    SitePoint Zealot
    Join Date
    Aug 2001
    Location
    North Carolina
    Posts
    153
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yikes!

    Hmm... Yeah, not too bad...

    For the items you want to subtract, name them something else, like sitem1, sitem2, sitem3.

    add this(after the first for loop that looks like this):
    PHP Code:
    $numsitems 7// set this to your number of sitems

    for($i=1$i<$numsitems+1$i++)
    {
       
    $v "sitem" $i;
       if(!
    is_numonly(${$v}))
          
    $allgood false;
       
    $total -= ${$v};

    Note:I did not test this, but it should work. You should make sure it works.
    Andrew Thompson
    VPHost.com, part of the Untapped Resources Network.

  12. #12
    SitePoint Enthusiast
    Join Date
    Jun 2000
    Location
    Eire
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    VPHost, It works and workd beautifully! Thank you so very much for the script and your help. It was very good of you.

    I would like to add your cridits to that page. If you don't want to off the information here, please email me with it.

    I'd like a link to whatever site you wish and your name and any other info that you wish added, as in a statement or such.


    Again thank you ever so much for everything!
    Last edited by Raven_Bren; Aug 9, 2001 at 11:40.
    Raven Bren
    NS 4.75, 800x600-1024x768, T1 cable, Win "98

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •