Thread: php help

    #1
  1. No Profile Picture
    All round clown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    21
    Rep Power
    0
    Hi all,

    I have just been given the job of creating a basic website, which is not a problem. A problem does arise when on one single page I have to create a form.

    This is what I have to achieve. Have a form which includes the following :

    Are you thinking of working
    Full-time - $full_time
    Part-time - $part_time

    ( maybe radio buttons )

    so i can give the user a choice

    How many hours per week on average do you think you would need to work :

    ( with a drop down box containing values 1-50) called $hours

    IF choice=full_time and $hours=>35
    print "well done! Your on the right track!"

    else

    print "That is not enough hours!!"

    IF choice=$part_time and $hours =>20
    print ""well done! Your on the right track!"

    else

    print ""That is not enough hours!!"

    There are also some text boxes below, which i have a grip on, but he also wants a submit button so he can be emailed the results of choices/forms if need be.

    I have just started using php, and don't
    know the paticular syntax required.

    Your help would be much appreciated.

    cheers
    Null

    [This message has been edited by null (edited October 01, 2000).]
  2. #2
  3. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Location
    England, UK
    Posts
    83
    Rep Power
    15
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    if ($choice=="full_time")
    {
    if ($hours=>35)
    {
    print "well done! Your on the right track!"
    }
    else
    {
    print "That is not enough hours!!"
    }
    }
    elseif ($choice=="part_time")
    {
    if ($hours=>20)
    {
    print "well done! Your on the right track!"
    }
    else
    {
    print "That is not enough hours!!"
    }
    }
    [/code]

    This should do it, if it doesn't work try changing <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>if ($hours=>35)[/code] and <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>if ($hours=>20)[/code] to <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>if ($hours=>"35")[/code] and <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>if ($hours=>"20")[/code]

    Let me know if it worked.

    Cheers

    Girish Gupta
    MusicGoesOn.com

    [This message has been edited by girish_gupta (edited October 01, 2000).]
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    Hopefully this will get you going. I just wrote it out, I didn't check it.

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    <html>
    <body>
    <form name="job" method="post" action="<?php echo $PHP_SELF; ?>">
    Are you thinking about working
    <BR><input type="radio" name="time" value="full" checked>Full time
    <BR><input type="radio" name="time" value="part">Part Time
    <BR>
    How many hours per week do you think you need to work?
    <BR>
    <select name="hours">
    <?php
    for($x=1;$x<=50;$x++)
    {
    echo "<option value="$x">$x</option>";
    }
    ?>
    </select>
    <BR>
    <input type="submit" value="Submit" name="submit">
    <?php
    if (isset($submit))
    {
    if (($time=="full" && $hours >= 35) | | ($time=="part" && $hours >= 20))
    {
    echo "You're on the right track!!";
    }
    else
    {
    echo "That's not enough hours!!";
    }

    $msg = "Someone filled out the form.n";
    $msg .= "They chose $time-time for $hours hours.";
    mail("to@you.com","Subject",$msg);
    }
    ?>
    </body>
    </html>
    [/code]

    ---John Holmes...

    [This message has been edited by SepodatiCreations (edited October 01, 2000).]
  6. #4
  7. No Profile Picture
    All round clown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    21
    Rep Power
    0
    Hi SepodatiCreations & girish_gupta,

    A big thanks for your code. Much appreciated!

    I have used SepodatiCreations code, but am getting some bizarre results. I know you didnt check it, but I was wondering if you knew why these things were happening ??

    Are you thinking about working
    Full time
    Part Time
    How many hours per week do you think you need to work?

    The following works fine -

    Are you thinking of working
    Full time
    Part time

    but the "for loop" (I think thats what you call it ) doesnt present the variables 1-50 as it should in the drop down selection box.
    I had to create the choices manually, ( which may be part of the problem. )My manual entries dont even appear in Netscaoe?

    I aslo get some code displayed (IE only ) on the screen next to the submit button -

    = 35) | | ($time=="part" && $hours >= 20)) { echo "You're on the right track!!"; } else { echo "That's not enough hours!!"; } $msg = "Someone filled out the form.n"; $msg .= "They chose $time-time for $hours hours."; mail("to@you.com","Subject",$msg); } ?>

    And when I click on the submit button, the following gets added to my url

    <?php echo $PHP_SELF; ?>

    Your help is appreciated :-)

    null
  8. #5
  9. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    I forgot the </form> after the submit button. Sorry about that. I really need to start testing these before I post them, I just didn't have time.

    Let me know of that fixes it.

    ---John Holmes...
  10. #6
  11. No Profile Picture
    All round clown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    21
    Rep Power
    0
    Hi John,

    Nope, the error is identical to as it was before I entered the </form> tag after the submit button... ??

    Any ideas ??

    Regards
    null
  12. #7
  13. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,643
    Rep Power
    4492
    What is the exact error again? I just copied and pasted that code into a file and it worked correctly. The only think I had to change is the &#0124; &#0124; in the if statement. there should not be a space between the two | characters. That will give you a parse error.

    Let me know and I'll try to help some more.

    ---jh
  14. #8
  15. No Profile Picture
    All round clown
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Posts
    21
    Rep Power
    0
    Hi John,

    Works a treat!!! I talked to the sysadmin at work and he mumbled about how he hadn't installed php properly on the server. Teamed up with the removal of the space, its great!!!!

    Thanks once again for your time!

    null

    P.S - like the website!



    [This message has been edited by null (edited October 02, 2000).]

Similar Threads

  1. Replies: 2
    Last Post: August 18th, 2004, 10:45 PM
  2. Replies: 4
    Last Post: January 28th, 2004, 08:29 AM
  3. PHP with UnixODBC
    By coder4hire in forum PHP Development
    Replies: 2
    Last Post: January 20th, 2004, 01:14 PM
  4. Passing string from PHP to Javascript
    By ka8oad in forum JavaScript Development
    Replies: 4
    Last Post: January 17th, 2004, 03:12 PM
  5. UnixODBC + PHP + Apache + Empress
    By coder4hire in forum Database Management
    Replies: 0
    Last Post: January 15th, 2004, 01:41 PM

IMN logo majestic logo threadwatch logo seochat tools logo