Need help with PhP Home work.. Due in a few days!!!!

Discussion in 'PHP' started by stupid21, Mar 26, 2010.

  1. #1
    OK ive basicly got my index page made for my homework.


    I need it so that the small images that you can choose for a background, i need it so that the person can check the box of the image that they want and it will post it over to my .php page as a header.


    Ive tryed a few codes but none work..

    Heres the page

    http://roecomputer.com/stevie4/test2/index2.html


    Here is the code that i have so far

    THIS IS THE INDEX PAGE


    THIS IS THE .PHP PAGE THAT I NEED THE HEADER SENT TO

     
    stupid21, Mar 26, 2010 IP
  2. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    These are the code lines that i tryed but they wont work.


    Index page to choose header








    THIS IS THE .PHP PAGE CODE THAT I TRYED TO GET IT TO PULL IT FROM THE INDEX PAGE

     
    stupid21, Mar 26, 2010 IP
  3. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #3
    Right click on the PHP page and view source and post it here.
     
    ThePHPMaster, Mar 26, 2010 IP
  4. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4


    Here it is. Let me know if you need to see the HTML page to. Cause i need help with it to post the picture over to the php page also.
     
    stupid21, Mar 26, 2010 IP
  5. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Here is the HTML Page

     
    stupid21, Mar 26, 2010 IP
  6. YoGem

    YoGem Active Member

    Messages:
    676
    Likes Received:
    8
    Best Answers:
    2
    Trophy Points:
    90
    #6
    Wait... I think there's a bit of confusion... you want people to choose an image as header? That's it? You can do the same on a single page, just changing the form from get to post, read the answer using $_POST, remove any action and use in your form
    action=""
    Code (markup):
    and echoing the result using
     if (isset($_POST['value']) {$image_toshow = $_POST['value']; echo "<img src=\"$image_toshow\">"; }
    PHP:
    Edit: Try giving as value, not numbers but the image.
     
    Last edited: Mar 27, 2010
    YoGem, Mar 27, 2010 IP
  7. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7

    No i need them to be able to selecet a header on the .html page that they type their name in on. THen i need it to send it over to my php page that i have all my stuff on and i need the header that they chose to be at the top of the page.
     
    stupid21, Mar 29, 2010 IP
  8. K.Meier

    K.Meier Well-Known Member

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #8
    You should only post your form code and the PHP related code and not the whole website. It's a pain to look at the code and it would make it a lot easier for all of us to help you.
     
    K.Meier, Mar 29, 2010 IP
  9. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9


    This is all i have so far and i dont even know if this would work. I dont have a php code to get it yet. Thats what i was needing help with.


     
    stupid21, Mar 29, 2010 IP
  10. K.Meier

    K.Meier Well-Known Member

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #10
    You are using GET in the form to send the data between files, can it also be POST?
     
    K.Meier, Mar 29, 2010 IP
  11. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Your guess is as good as mine.
     
    stupid21, Mar 29, 2010 IP
  12. K.Meier

    K.Meier Well-Known Member

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #12
    LOL, okay :p

    File Name: test2.php
    <form method="post" action="test2.php">
    
    <label>
    <h2>Choose A Header</h2>
    </label>
    
    <img src="http://i301.photobucket.com/albums/nn55/stevieterry/GOOD1.jpg" width=60 height=60 />
    <input type="radio"
    name = "header"
    value="http://i301.photobucket.com/albums/nn55/stevieterry/GOOD1.jpg" />
    
    <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader2.jpg" width=60 height=60 />
    <input type="radio"
    name = "header"
    value="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader2.jpg" />
    
    <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" width=60 height=60 />
    
    <input type="radio"
    name = "header"
    value="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" />
    
    <input value="Submit" name="choose" type="submit" />
    </form>
    <br><br><br>
    
    <?php
    if(isset($_POST["choose"])) {
    	
    	echo 'Your header: <br /><img src="'.$_POST['header'].'" width=60 height=60 />';
    }
    
    else {
    	echo "You have not choosen a header yet";
    }
    ?>
    HTML:
     
    K.Meier, Mar 29, 2010 IP
  13. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #13
    Should that go in the html page?
     
    stupid21, Mar 29, 2010 IP
  14. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    It didnt work. It showed this at the bottom of the page also

    else { echo "You have not choosen a header yet";}


    and when i do choose one and it takes me to the .php page it says "You have not choosen a header yet " so i think its working some what.

    I tryed all the code on the html page first....

    then moved the php code of it to the php page...
     
    stupid21, Mar 29, 2010 IP
  15. K.Meier

    K.Meier Well-Known Member

    Messages:
    281
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #15
    Please, think with me here. I'm helping you but I'm not doing any of your work! You can't use PHP in a .html file, you should know that by now. Its up to you how to use it. This is a working example, now try and implement it into your site.
    Use this PHP code that I wrote, on your php site and make sure you use the proper file name action form.
     
    K.Meier, Mar 29, 2010 IP
  16. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    I dont understand what im doing wrong. I made a new document and just put those 2 piece's of code in it and it worked... But it wont work on my full page. I think my code's arent working together i must have a mistake somewere.
     
    stupid21, Mar 29, 2010 IP
  17. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #17
    Heres the index page




    <html>
    <head>
    <embed src="http://roecomputer.com/stevie4/test2/Darude%20-%20Sandstorm.mp3" hidden="true" border="0" width="310" height="45" autostart="true" autoplay="true" loop="true" volume="75%">
    <link rel = "stylesheet"
          type = "text/css"
          href = "whatsName.css" />
    <style type="text/css">
    a { text-decoration:none }
    </style>
    </head>
    <center>
    <body>
    <body bgcolor="#000000" text="ffffff" link="#66cc00" vlink="#9999ff" alink="#cc0000">
    
    <a href="http://roecomputer.com/stevie4/test2/index2.html"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/indexcust3.jpg" border="0"></a>
    <br />
    <form method = "get"
          action = "hiUser.php">
      <fieldset>
        <label>
          <h2>Enter Your Name</h2>
        </label>
    
    <br />
    
        <input type = "text"
               name = "userName"
               value = "" />
        
      </fieldset>
    </form>
    </tr>
    
    
    <tr>
    
    <form method="post" action="hiUser.php">
    <fieldset>
    <label>
    <h2>Choose A Header</h2>
    </label>
    
    <img src="http://i301.photobucket.com/albums/nn55/stevieterry/GOOD1.jpg" width=60 height=60 />
    <input type="radio"
    name = "header"
    value="http://i301.photobucket.com/albums/nn55/stevieterry/GOOD1.jpg" />
    
    <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader2.jpg" width=60 height=60 />
    <input type="radio"
    name = "header"
    value="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader2.jpg" />
    
    <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" width=60 height=60 />
    
    <input type="radio"
    name = "header"
    value="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" />
    
    </fieldset>
    <tr>
    <td>
    <BUTTON TYPE=SUBMIT>
    <STRONG>To The Index!</STRONG></BUTTON>
    </td>
     </tr>
    
    </form>
    <br><br><br>
    
    
    
    
    
    
    
    
    </fieldset>
    </tr>
    
    
    
    
    
    </center>
    
    <body>
    <center>
    <table width="133" border="0" cellspacing="0" cellpadding="3"><tr><td align="center"><a href="http://www.website-hit-counters.com" target="_blank"><img src="http://www.website-hit-counters.com/cgi-bin/image.pl?URL=334288-0083" alt="website hit counter" title="website hit counter" border="0" ></a></td></tr><tr><td align="center"><font style="font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 9px; color: #330006; text-decoration: none;"><a href="http://www.website-hit-counters.com" target="_blank" style="font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 9px; color: #555556; text-decoration: none;" title="website hit counters"></a></font></td></tr></table>
    </center>
    </body>
     
    </form>
    </body>
    </html>
    HTML:
     
    stupid21, Mar 29, 2010 IP
  18. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #18
    ANd here is the php code


    
    <html>
    <head>
    <body>
    
    <embed src="http://roecomputer.com/stevie4/test2/Instrumentals%20-%20Dr.%20Dre%20Ft%20Eminem%20-%20Forgot%20About%20Dre%20.mp3" hidden="true" border="0" width="310" height="45" autostart="true" autoplay="true" loop="true" volume="75%">
    
    </body>
    <body>
    
    <h3><a href="http://roecomputer.com/stevie4/test2/index2.html">Change Your Settings</a></h3>
    
    
    </head>
    
    
     
    <?php 
    $userName = filter_input(INPUT_GET, "userName");
    
      print "<h3>Hi there, $userName!</h3>";
    
    
    ?>
    
    
    
    
    
    <a href="http://s301.photobucket.com/albums/nn55/stevieterry/?action=view&current=ipadresss.jpg" target="_blank"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/ipadresss.jpg" border="0" alt="Photobucket"></a>
    <?php echo $_SERVER['REMOTE_ADDR']; 
    ?>
    
    
    
    <?php
    if(isset($_POST["choose"])) {
        
        echo 'Your header: <br /><img src="'.$_POST['header'].'" width=500 height=200 />';
    }
    
    else {
        echo "You have not choosen a header yet";
    }
    ?>
    
    
    </body>
    
    
    
    
    <center>
    
    
    <a href="http://roecomputer.com/stevie4/test2/chp1.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/ch1.jpg" border="0"></a>
    <br />
    <a href="http://roecomputer.com/stevie4/test2/chp2.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/ch2.jpg" border="0"></a>
    <br />
    <a href="http://roecomputer.com/stevie4/test2/chp3.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/ch3.jpg" border="0"></a>
    <br />
    <a href="http://roecomputer.com/stevie4/test2/chp4.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/ch4.jpg" border="0"></a>
    <br />
    <a href="http://roecomputer.com/stevie4/test2/other.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/other.jpg" border="0"></a>
    <br />
    <a href="http://roecomputer.com/stevie4/test2/extra.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/extr.jpg" border="0"></a>
    </center>
    
    
    
    
    
    
    
    
    
    </body>
    <br />
    
    
    </center>
    <body>
    <center>
    <table width="133" border="0" cellspacing="0" cellpadding="3"><tr><td align="center"><a href="http://www.website-hit-counters.com" target="_blank"><img src="http://www.website-hit-counters.com/cgi-bin/image.pl?URL=334288-0083" alt="website hit counter" title="website hit counter" border="0" ></a></td></tr><tr><td align="center"><font style="font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 9px; color: #330006; text-decoration: none;"><a href="http://www.website-hit-counters.com" target="_blank" style="font-family: Geneva, Arial, Helvetica, sans-serif; font-size: 9px; color: #555556; text-decoration: none;" title="website hit counters"></a></font></td></tr></table>
    </center>
    </body>
    </body>
    </html>
    
    HTML:
     
    stupid21, Mar 29, 2010 IP
  19. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #19
    The code that K.Meier gave me does work so thank you very much for that. I just cant seem to get it to work onto my page though. It worked fine on a new document.
     
    stupid21, Mar 29, 2010 IP
  20. stupid21

    stupid21 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #20
    Ok i got the header to show thank you so much.
    Only thing is, with the button that u made, it dont show the user's name they they put in once it goes over to the php page.
     
    stupid21, Mar 29, 2010 IP