Jump to content

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


stupid21

Recommended Posts

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&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']; ?>

 

</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>

Link to comment
Share on other sites

ermmm....  :wtf:

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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

    //..

}

 

?>

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

 

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)

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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
    //..
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.