stupid21 Posted March 26, 2010 Share Posted March 26, 2010 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 <html> <head> <embed src="http://www.mididatabase.com/20091028/rap/jayz/Big_Pimpin.mid" 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.php"><img src="http://i301.photobucket.com/albums/nn55/stevieterry/indexcust3.jpg" border="0"></a> <br /> <form method = "get" action = "hiUser.php"> <fieldset> <label> Enter Your Name: </label> <br /> <input type = "text" name = "userName" value = "" /> </fieldset> </tr> </form> <form method = "post" action = "hiUser.php"> <tr> <fieldset> <label> Choose A Header: </label> <img src="http://i301.photobucket.com/albums/nn55/stevieterry/GOOD1.jpg" width=60 height=60 /> <input type="checkbox" class="styled" name = "sizeType" checked = "checked"/> <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader2.jpg" width=60 height=60 /> <input type="checkbox" class="styled" name = "sizeType" checked = "checked"/> <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" width=60 height=60 /> <input type="checkbox" class="styled" name = "sizeType" checked = "checked"/> </fieldset> </tr> <div> <button type = "submit"> show me </button> </div> </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> THIS IS THE .PHP PAGE THAT I NEED THE HEADER SENT TO <html> <head> <body> <embed src="http://www.mididatabase.com/20091028/rap/drdre/Forgot_About_Dre.mid" 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> <style type="text/css"> a { text-decoration:none } </style> </head> <body bgcolor="#000000" text="ffffff" link="#66cc00" vlink="#9999ff" alink="#cc0000"> <?php $userName = filter_input(INPUT_GET, "userName"); print "<h3>Hi there, $userName!</h3>"; ?> <?php $sizeType = filter_input(INPUT_POST, "sizeType"); $theStyle = <<<HERE "border-width:$sizeType; border-style:$sizeType; HERE; print "<div style = $theStyle>"; print $sizeType; print "</div>"; ?> <a href="http://s301.photobucket.com/albums/nn55/stevieterry/?action=view¤t=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']; ?> </body> <body bgcolor="Black"> <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> Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/ Share on other sites More sharing options...
xcandiottix Posted March 26, 2010 Share Posted March 26, 2010 ermmm.... Well. I can click all three check boxes on your first page.... does that mean I get to pick all 3 headers? and The code on your second page doesn't have a $_POST anywhere on it. So, if you're sending data with JS to your php page... then your php page needs to extract which check box I checked. Seems like you have a lot of work to do. Suggest you research $_POST and how JS wokrs with php. -K.candiotti Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032109 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 Could you please help me with the code? I just took some code from a older program that i had and put it in there. Thats how i got the $_post. Can you please help me and show me how it should look so it will work. Cause i need it done soon. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032112 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 Here is the code that i added to it.... how can i change it so that it will work with mine? <?php $bits = $_POST['bitsOne']; $oct1 = $_POST['octet1']; $oct2 = $_POST['octet2']; $oct3 = $_POST['octet3']; $oct4 = $_POST['octet4']; echo "<h3>The Matrix is everywhere. It is all around us.</h3>"; echo '<br>Your network address is :'.$oct1.'.'.$oct2.'.'.$oct3.'.'.$oct4.' <b> </b>'; switch ($bits) { case 1: echo "<br>You Chose 1 Bits"; echo "<br>There are 126 Hosts Per Subnet"; echo "<br>There are 2 Maximum Subnets" ; echo "<br>Your subnet mask is: 255.255.255.128" ; break; ^^^ Thats a code from one of my older .php pages Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032113 Share on other sites More sharing options...
xcandiottix Posted March 26, 2010 Share Posted March 26, 2010 you just want whatever banner that someone checkmarks on your first page to show up on the top of the second page right? Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032115 Share on other sites More sharing options...
trq Posted March 26, 2010 Share Posted March 26, 2010 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. That makes little sense. How about describing your issue a little clearer. We are not hear to write code for people, especially if it is homework. Homework is specifically designed to re-iterate what you have learnt in class, have you tried actually going through your notes? Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032116 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 Yes xcandiottix. I just need the box that is checked to print the header over to the next page. And Thorpe I have been working on this for almost a week. Ive tryed every code that i know even read most of my PhP for beginner book. I still cant figure it out. Please just help me. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032121 Share on other sites More sharing options...
ignace Posted March 26, 2010 Share Posted March 26, 2010 First rename your checkboxes to radio buttons <input type="radio" .. Then make sure all input's have the same name: <input type="radio" name="header" value="1" .. <input type="radio" name="header" value="2" .. <input type="radio" name="header" value="3" .. Your user is now only able to select 1 header. In your PHP you write: if (isset($_POST['header'])) { $header = intval($_POST['header']); //echo $header; // outputs: 1, 2 or 3 //.. } The rest is up to you Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032122 Share on other sites More sharing options...
xcandiottix Posted March 26, 2010 Share Posted March 26, 2010 well... i don't remember off hand exactly how to work with the check boxes... but say you had a submit button below each banner. I would put something like this below each banner: I'm only going to do banner 1 as an example // Banner 1's image code here <form action="yoursecondpage.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="whichbanner" value="'banner1'"> <br><br><input type="submit" name="submit" value="Pick This One" /></p> </form> then on your php page $chosenbanner = $_POST['whichbanner'] // $chosenbanner is now equal to banner1 from the value field of the script above if ($chosenbanner == banner1){ //echo your banner image code for banner 1 here } and that should work. Try it on a fresh page with nothing else on it because there's wayyyy too much junk going on on your pages. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032123 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 xcandiottix i couldn't get it to work. This is what i put. IN THE INDEX PAGE <html> <body> // Banner 1's image code here <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" width=60 height=60 /> <form action="bobbySmith.php" method="post" enctype="multipart/form-data"> <input type="hidden" name="whichbanner" value="'banner1'"> <br><br><input type="submit" name="submit" value="Pick This One" /></p> </form> </body> </html> IN THE PHP PAGE <html> <body> <? $chosenbanner = $_POST['whichbanner'] if ($chosenbanner == banner1){ //echo "<img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg"/> "; } ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032129 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 ignace Yours worked to where people can only pick one. But it didnt print over to the .php page when i checked the picture. Heres what i had INDEX CODE <fieldset> <form method = "post" action = "hiUser.php"> <label> Choose A Header: </label> <img src="http://i301.photobucket.com/albums/nn55/stevieterry/GOOD1.jpg" width=60 height=60 /> <input type="radio" name = "header" value="1" /> <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader2.jpg" width=60 height=60 /> <input type="radio" name = "header" value="2" /> <img src="http://i301.photobucket.com/albums/nn55/stevieterry/PhPHeader.jpg" width=60 height=60 /> <input type="radio" name = "header" value="3" /> .PHP PAGE <?php if (isset($_POST['header'])) { $header = intval($_POST['header']); //echo $header; // outputs: 1, 2 or 3 //.. } ?> Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032132 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 Could this line of code be blocking the image from showing up maybe? <body bgcolor="#000000" text="ffffff" link="#66cc00" vlink="#9999ff" alink="#cc0000"> Im just guessing... Im really confused atm and its almost 6am here lol. I have to get this done though. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032136 Share on other sites More sharing options...
ignace Posted March 26, 2010 Share Posted March 26, 2010 try this: if (isset($_POST['header'])) { $header = intval($_POST['header']); echo 'You choose: ', $header; // outputs: 1, 2 or 3 //.. } Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032137 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 It still didnt work =[. Maybe im doing something wrong. See http://roecomputer.com/stevie4/test2/index2.html Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032139 Share on other sites More sharing options...
oni-kun Posted March 26, 2010 Share Posted March 26, 2010 It still didnt work =[. Maybe im doing something wrong. See http://roecomputer.com/stevie4/test2/index2.html http://roecomputer.com/stevie4/test2/hiUser.php?userName<script%20language="javascript">alert('Hey%20There!')</script>&header=2 Who the hell is teaching you PHP? If that's homework, You've got a lot to do. Filter_var, I wonder why that function exists.. doesn't do much. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032144 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 lol oni-kun that link was cool. My teacher is great. Im just very new to PhP this the first of my first year of learning it. Could you help me out? You seem to know alot. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032146 Share on other sites More sharing options...
Wolphie Posted March 26, 2010 Share Posted March 26, 2010 Who the hell is teaching you PHP? If that's homework, You've got a lot to do. Filter_var, I wonder why that function exists.. doesn't do much. http://php.net/manual/en/function.filter-var.php does a lot, actually. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032147 Share on other sites More sharing options...
oni-kun Posted March 26, 2010 Share Posted March 26, 2010 http://php.net/manual/en/function.filter-var.php does a lot, actually. No it doesn't. If he wants to practise proper security, then he should do it himself. lol oni-kun that link was cool. Use htmlspecialchars() on the $_POST query, as you're allowing HTML/JS (thus what we call XSS) on the server, this obviously doesn't matter in this test, but in production there can be major security flaws and problems down the road. Here are a few functions to look into: htmlspecialchars strip_tags mysql_real_escape_string (when working with DB transactions) Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032151 Share on other sites More sharing options...
Wolphie Posted March 26, 2010 Share Posted March 26, 2010 No it doesn't. If he wants to practise proper security, then he should do it himself. His use of it doesn't provide a lot of security no, and that function isn't really designed for security. It's designed and it is there for validation purposes and when used correctly, it's very useful, and powerful. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032154 Share on other sites More sharing options...
oni-kun Posted March 26, 2010 Share Posted March 26, 2010 His use of it doesn't provide a lot of security no, and that function isn't really designed for security. It's designed and it is there for validation purposes and when used correctly, it's very useful, and powerful. Powerful? I could mimick the function entirely in <12 lines. It's relying on a predefined security measure, such as Magic quotes, It's pointless. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032159 Share on other sites More sharing options...
ignace Posted March 26, 2010 Share Posted March 26, 2010 Who the hell is teaching you PHP? If you are amazed over this then you should have seen the things that a teacher wrote in front of class on his beamer in college. And let me tell you that they do not like it when you point out their mistake(s)... Hell I heard they had an internal team working on their website.. and yeah those bugs were present there to. Login was as simple as: ' OR 1=1 -- I even had once a teacher which was a head of a company that created websites for big clients and had their framework open-sourced. So when I took a peak at the code... Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032166 Share on other sites More sharing options...
stupid21 Posted March 26, 2010 Author Share Posted March 26, 2010 Can someone please help me with this. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1032333 Share on other sites More sharing options...
stupid21 Posted March 29, 2010 Author Share Posted March 29, 2010 Bump. Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1033805 Share on other sites More sharing options...
jcbones Posted March 29, 2010 Share Posted March 29, 2010 One last hint: You are using a black background: if (isset($_POST['header'])) { $header = intval($_POST['header']); echo '<span style="color:white;">You choose: ' . $header . '</span>; // outputs: 1, 2 or 3 //.. } Quote Link to comment https://forums.phpfreaks.com/topic/196575-need-help-with-php-home-work-due-in-a-few-days/#findComment-1033840 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.