1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with PHP form

Discussion in 'PHP & Perl' started by whiteli0n, Jan 7, 2012.

  1. whiteli0n

    whiteli0n Junior Member

    Joined:
    Nov 10, 2011
    Messages:
    151
    Likes Received:
    51
    new to PHP and could really use som help. I figured this is a good a place as any to ask. All i really understand are the basics (as you will see from my code lol) but i am the dive in and do it person or else i wont learn :/. I think that my syntax is written correctly but i am to new to this language and programming in general to have a valid opinion. I do not know how to use AJAX yet so i basically having people fill out a form to get to one of two other forms. Does that make sense? Here is my code and i am open to any and all wisdom and knowledge this community can give. Thanks in advance everyone!

    Code:
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$_POST[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'in_or_out'[/COLOR][COLOR=#009900]][/COLOR] [COLOR=#339933]==[/COLOR] [COLOR=#0000ff]"inside"[/COLOR] [COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR] [COLOR=#000088]$inside[/COLOR] [COLOR=#339933]=[/COLOR] [COLOR=#000088]$_POST[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'in_or_out'[/COLOR][COLOR=#009900]][/COLOR][COLOR=#339933];[/COLOR] [COLOR=#009900]}[/COLOR] [COLOR=#b1b100]elseif[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$_POST[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'in_or_out'[/COLOR][COLOR=#009900]][/COLOR] [COLOR=#339933]==[/COLOR] [COLOR=#0000ff]"outside"[/COLOR] [COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR][COLOR=#000088]$outside[/COLOR] [COLOR=#339933]=[/COLOR] [COLOR=#000088]$_POST[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'in_or_out'[/COLOR][COLOR=#009900]][/COLOR][COLOR=#339933];[/COLOR] [COLOR=#009900]}[/COLOR][COLOR=#000000][B]?>[/B][/COLOR]
    </head>
    
    <body>
    <h4> Please answer the following questions to receive a hardware  recommendation or Fill out the contact us form for more complex  questions</h4>
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR][COLOR=#339933]![/COLOR][COLOR=#990000]isset[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$_POST[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'form'[/COLOR][COLOR=#009900]][/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]
    <form action="[COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]echo[/COLOR] [COLOR=#990000]htmlentities[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$_SERVER[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'PHP_SELF'[/COLOR][COLOR=#009900]][/COLOR][COLOR=#009900])[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]" method="post" name="form">
    <p>Indoor or Outdoor application: <select  name='in_or_out'><option value=''>Select  one</option><option name="inside"  value="inside">Inside</option><option name="outside"  value="outside">Outside</option>
    </select>
    </p>
    <input type="submit" name="submit" value="Submit">
    </form>
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#009900]}[/COLOR] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR][COLOR=#990000]isset[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$_POST[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'form'[/COLOR][COLOR=#009900]][/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR] 
    <form action="[COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]echo[/COLOR] [COLOR=#990000]htmlentities[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$_SERVER[/COLOR][COLOR=#009900][[/COLOR][COLOR=#0000ff]'PHP_SELF'[/COLOR][COLOR=#009900]][/COLOR][COLOR=#009900])[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]" method="post" name="form">
    <p>Indoor or Outdoor application: <select  name='in_or_out'><option value=''>Select  one</option><option name="inside" [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR][COLOR=#990000]isset[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$inside[/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900]{[/COLOR][COLOR=#b1b100]echo[/COLOR] [COLOR=#0000ff]"selected"[/COLOR][COLOR=#339933];[/COLOR] [COLOR=#009900]}[/COLOR][COLOR=#000000][B]?>[/B][/COLOR] value="inside">Inside</option><option name="outside" [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR][COLOR=#990000]isset[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$outside[/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR][COLOR=#b1b100]echo[/COLOR] [COLOR=#0000ff]"selected"[/COLOR] [COLOR=#339933];[/COLOR] [COLOR=#009900]}[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]  value="outside">Outside</option>
    </select>
    </p>
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#b1b100]if[/COLOR][COLOR=#009900]([/COLOR][COLOR=#990000]isset[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$outside[/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]
    <select name="application" >
    <option value="opt1">option1</option>
    <option value="opt2">option2</option>
    <option value="opt3">option3</option>
    </select>
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#009900]}[/COLOR] [COLOR=#b1b100]elseif[/COLOR][COLOR=#009900]([/COLOR][COLOR=#990000]isset[/COLOR][COLOR=#009900]([/COLOR][COLOR=#000088]$inside[/COLOR][COLOR=#009900])[/COLOR][COLOR=#009900])[/COLOR] [COLOR=#009900]{[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]
    <select name="application" >
    <option value="opt1">option1</option>
    <option value="opt2">option2</option>
    </select>
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#009900]}[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR] 
    
    <br /> 
    <input type="submit" name="submit" value="Submit">
    </form>
    
    [COLOR=#000000][B]<?php[/B][/COLOR] [COLOR=#009900]}[/COLOR] [COLOR=#000000][B]?>[/B][/COLOR]
    </body>
    </html>
     
  2. xpwizard

    xpwizard Junior Member

    Joined:
    Nov 6, 2010
    Messages:
    198
    Likes Received:
    122
    So what is it exactly you want help with?
     
  3. menusforyou

    menusforyou Registered Member

    Joined:
    Aug 26, 2009
    Messages:
    76
    Likes Received:
    103
    Occupation:
    Trying to make another 100 off Adsense
    Location:
    Pinellas County
    This is easy man....

    You dont need to spend hours with the code...

    You have three fields populated manually not dynamic based on the previous options picked.


    I suggest you use Dreamweaver CS3/4/5 and connect live to your hosting Db "MySQL" and build the forms within DW it says me time and plus there are alot of extensions that not only save it to the DB on submit but also mail it.

    Your form is almost correct but its what it posts to and your hosting smtp settings might be screwed up. Too much to answer from some PHP form fields.

    Hosting
    SMTP support
    Etc...

    PM Im a programmer in ASP/PHP
     
    • Thanks Thanks x 1
    Last edited: Jan 7, 2012
  4. menusforyou

    menusforyou Registered Member

    Joined:
    Aug 26, 2009
    Messages:
    76
    Likes Received:
    103
    Occupation:
    Trying to make another 100 off Adsense
    Location:
    Pinellas County
    This has nothing to do with IM or BH or WH this is better servered on a web design forum... Sorry.. But i will give you some advice as well as others I can build database driven sites as fast as it takes to upload a WP Blog LOL
     
  5. jazzc

    jazzc Moderator Staff Member Moderator Jr. VIP

    Joined:
    Jan 27, 2009
    Messages:
    2,468
    Likes Received:
    10,148
    @menusforyou,

    This is the Programming & Web Design section, his post is valid.
     
    • Thanks Thanks x 1
  6. whiteli0n

    whiteli0n Junior Member

    Joined:
    Nov 10, 2011
    Messages:
    151
    Likes Received:
    51
    LOL did you realize where you were?? What this ISNT is the advertising portion of the forum and thats what you were doing there but you did give me some good advice about dreamweaver so for that i had to thank you. Im not familiar with the Dreamweaver GUI yet and i just fid manual coding more 'fun' i guess. Gratifying is a good word, and i was working with a local file on MAMP im just too much of a newb :( Serisously though, thanks for your time dude

    THANK YOU to everyone who really tried to help you guys time is very much appreciated!! I actually studied a little javascript these past couple days and got it to do what i needed with a few simple functions. If anyone cares to see i will show you but i am sure you guys are well beyond greeenhorn ass :D
     
    Last edited: Jan 10, 2012