Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Closed Thread
PhP Homework Due In 2 Days! Please Help!
Old 02-11-2010, 01:02 PM PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
Ok i have to make a Class C subnet calculator for my PhP homework.

I have the html page made ( http://roecomputer.com/Stevie3/sub3.html )

I just need a code that will print the first 3 Octets that the person types in and it will calculate how many bits they selected / The number of hosts / and the Maximum Subnets


But the page that it is getting from i dont have any code for it yet.

Can someone please help me....

I tryed to use this code that i typed but its not working.

Quote:
<html>
<head>
<title>Answer</title>
</head>
<body>

<BODY bgcolor="#0099CC">



<?php
$bitsOne = filter_input(INPUT_GET,"bitsOne");
print "<h3>You Selected, $bitsOne , bits!</h3>";



$bits = (1,6)





if ( $bits == 1) {
print "You Chose 1 Bits";
"There are 126 Hosts Per Subnet";
"There are 2 Maximum Subnets";
}

if ( $bits == 2) {
print "You Chose 2 Bits";
"There are 62 Hosts Per Subnet";
"There are 4 Maximum Subnets" ;
}

if ( $bits == 3) {
print "You Chose 3 Bits";
"There are 30 Hosts Per Subnet";
"There are 8 Maximum Subnets"
}


if ( $bits == 4) {
print "You Chose 4 Bits";
"There are 14 Hosts Per Subnet";
"There are 16 Maximum Subnets";
}


if ( $bits == 5) {
print "You Chose 5 Bits";
"There are 6 Hosts Per Subnet";
"There are 32 Maximum Subnets" ;
}


if ( $bits == 6) {
print "You Chose 6 Bits";
"There are 2 Hosts Per Subnet";
"There are 64 Maximum Subnets" ;
}



?>

</body>
</html>

I just need a code like that ^ so it will print the first 3 Octets that the person types in and it will calculate how many bits they selected / The number of hosts / and the Maximum Subnets


Please help me!

Last edited by stupid21; 02-11-2010 at 01:42 PM..
stupid21 is offline
View Public Profile
 
 
Register now for full access!
Old 02-11-2010, 01:42 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
Also the code that i posted dont work...
I looked over it but i cant figure it out.

I just need it to Print what they type in the Octet boxes and need it to caculate from what they put in the Bits box...
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 03:28 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
While i cant be bothered to write a subnet calc to show you ( google it? )
http://sourceforge.net/projects/subntcalc/

A simple way to work out how many hosts for each network is

256 - (4th octet)

Thi scan be used for class b and a addresses, just use more math.

IE:

a /30 range would be.
255.255.255.252

256 - 255.255.255."252" = 4 ( 4 hosts )

ie:
10.0.0.0 /30 ( 4 hosts )

10.0.0.0 - network ( not usable )
.1 - usable
.2 - usable
.3 - broadcast ( not usable )
.4 - network ( of next /30 )
.5.
.6
.7
.8 /30
etc etc

Ipv6 on the other hand...... Good luck.

I hope this helps with your logic.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 02-11-2010 at 03:32 PM..
lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 03:54 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
Well i kinda know how to calculate it...
It just that i know dont how to put it into php and make it work and show up correctly
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 03:56 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
I dont get why you have $bits predefined?
$bitsOne isnt being called?


$bitsOne = filter_input(INPUT_GET,"bitsOne");
print "<h3>You Selected, $bitsOne , bits!</h3>";



$bits = (1,6)
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 03:57 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Also you may need a ;

at teh end of

$bits = (1,6)
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:04 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
OK does this work?




PHP Code:



<html>
<head>
<title>Answer</title>
</head>
<body>

<BODY bgcolor="#0099CC">



<?php
$bits 
filter_input(INPUT_GET,"bitsOne");
// Or if its coming from a webform
// $bits = $_POST['bitsone'];
print "<h3>You Selected, $bitsOne , bits!</h3>";

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";
        break;
    case 
2:
echo 
"<br>You Chose 2 Bits";
echo 
"<br>There are 62 Hosts Per Subnet";
echo 
"<br>There are 4 Maximum Subnets" ;
    case 
3:
echo 
"<br>You Chose 3 Bits";
echo
"<br>There are 30 Hosts Per Subnet";
echo
"<br>There are 8 Maximum Subnets";
    case 
4:
echo 
"You Chose 4 Bits";
echo
"<br><br>There are 14 Hosts Per Subnet";
echo
"<br>There are 16 Maximum Subnets";
        break;
    case 
5:
echo 
"<br>You Chose 5 Bits";
echo 
"<br>There are 6 Hosts Per Subnet";
echo 
"<br>There are 32 Maximum Subnets" ;
        break;
    case 
6:
echo 
"<br>You Chose 6 Bits";
echo 
"<br>There are 2 Hosts Per Subnet";
echo 
"<br>There are 64 Maximum Subnets" ;
        break;
}



?>

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE



Last edited by lynxus; 02-11-2010 at 04:07 PM..
lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:28 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
It gave me this error when i tryed to type in a subnet and use it

The server encountered an unexpected condition which prevented it from fulfilling the request.
The script had an error or it did not produce any output. If there was an error, you should be able to see it in the error log.
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 04:33 PM Re: PhP Homework Due In 2 Days! Please Help!
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
And the error log shows??
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
View Public Profile Visit chrishirst's homepage!
 
Old 02-11-2010, 04:34 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Check there are semicolons at the end of each echo. ;

How are you sending the script the data? from a web form or from the command line?
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:35 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
From the web...
I have them on a Bizland file manager website.
http://roecomputer.com/Stevie3/sub3.html is the website were you type in you octet ands the bits you want to barrow. I have that working i think... Its just when you type your stuff in i dont have the page done that calculates it and stuff
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 04:38 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
ok

2 things.

Change your form from:

<form method="get"
action="test.php">

to
<form method="POST"
action="test.php">


Then in the php script,
Change


<?php
$bits
= filter_input(INPUT_GET,"bitsOne");
// Or if its coming from a webform
// $bits = $_POST['bitsone'];
print "<h3>You Selected, $bitsOne , bits!</h3>";



to

<?php
$bits = $_POST['bitsone'];
print "<h3>You Selected, $bitsOne , bits!</h3>";

__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:42 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
Should i put $bits or $bitsOne senese thats what i named it in the script as.
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 04:43 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
leave it as $bits as thats what we call later on for the switch statement.

Its only called bitsone in your form , and that has no bearing on the php code as we chuck that data into the $bits var.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:45 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
also on your form html,
change

<input type="text"
name="bitsOne"
value=""/>

to

<input type="text"
name="bitsOne" id="bitsOne"
value=""/>
</td>

</td>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:49 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
SO far this is what i have but its not working

For my HTML page i have

Quote:
<html>
<head>

<title>How Many Bits</title>
<link rel="stylesheet"
type="text/css"
href="bitsOne.css"/>

</head>



<body>

<BODY bgcolor="#CC3300">

<h1>Class C Subnet Calculator</h1>

<form method="POST"
action="test.php">

<fieldset>


<table border="1"
cellspacing="8">

<tr>
<td>
<label>
Octet 1:
</label>

<input type="text"
name="octet1"
value=""/>




<label>
Octet 2:
</label>

<input type="text"
name="octet2"
value=""/>



<label>
Octet 3:
</label>

<input type="text"
name="octet3"
value=""/>



<label>
Octet 4:
</label>

<input type="text"
name="octet4"
value=""/>


<br />
<tr>
<td>
<label>
Please type How Many Bits:
</label>

<input type="text"
name="bitsOne" id="bitsOne"
value=""/>
</td>

</td>
</td>
</tr>

<tr>
<td>
<BUTTON TYPE=SUBMIT>
<IMG SRC="http://www.xuriel.com/blocksets/img/fire.gif" HEIGHT=55
WIDTH=105 ALT="Starflower" ALIGN="ABSMIDDLE">
<STRONG>Calculate!</STRONG></BUTTON>
</td>
</tr>



</fieldset>
</form>
</body>
</html>
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 04:50 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
and for my test.php i have

Quote:
<html>
<head>
<title>Answer</title>
</head>
<body>

<BODY bgcolor="#0099CC">



<?php
$bitsOne = $_POST['bitsOne'];
print "<h3>You Selected, $bitsOne , bits!</h3>";

$bitsOne = (1,6);





if ( $bitsOne == 1) {
print "You Chose 1 Bits";
"There are 126 Hosts Per Subnet";
"There are 2 Maximum Subnets";
}

if ( $bitsOne == 2) {
print "You Chose 2 Bits";
"There are 62 Hosts Per Subnet";
"There are 4 Maximum Subnets" ;
}

if ( $bitsOne == 3) {
print "You Chose 3 Bits";
"There are 30 Hosts Per Subnet";
"There are 8 Maximum Subnets"
}


if ( $bitsOne == 4) {
print "You Chose 4 Bits";
"There are 14 Hosts Per Subnet";
"There are 16 Maximum Subnets";
}


if ( $bitsOne == 5) {
print "You Chose 5 Bits";
"There are 6 Hosts Per Subnet";
"There are 32 Maximum Subnets" ;
}


if ( $bitsOne == 6) {
print "You Chose 6 Bits";
"There are 2 Hosts Per Subnet";
"There are 64 Maximum Subnets" ;
}



?>

</body>
</html>
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 04:50 PM Re: PhP Homework Due In 2 Days! Please Help!
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
OK!!!

Works here

http://217.174.254.30/shiznit/test.html

test.html
Code:
<html>
<head>

<title>How Many Bits</title>
<link rel="stylesheet"
type="text/css"
href="bitsOne.css"/>

</head>



<body>

<BODY bgcolor="#CC3300">

<h1>Class C Subnet Calculator</h1>

<form method="POST"
action="test.php">

<fieldset>


<table border="1"
cellspacing="8">

<tr>
<td>
<label>
Octet 1:
</label>

<input type="text"
name="octet1"
value=""/>



<label>
Octet 2:
</label>

<input type="text"
name="octet2"
value=""/>



<label>
Octet 3:
</label>

<input type="text"
name="octet3"
value=""/>


<label>
Octet 4:
</label>

<input type="text"
name="octet4"
value=""/>


<br />
<tr>
<td>
<label>
Please type How Many Bits:
</label>

<input type="text"
name="bitsOne" id="bitsOne"
value=""/>
</td>

 </tr>

<tr>
<td>
<BUTTON TYPE=SUBMIT>
<IMG SRC="http://www.xuriel.com/blocksets/img/fire.gif" HEIGHT=55
WIDTH=105 ALT="Starflower" ALIGN="ABSMIDDLE">
<STRONG>Calculate!</STRONG></BUTTON>
</td>
 </tr>



</fieldset>
</form>

</body>
</html>
test.php
Code:
<html>
<head>
<title>Answer</title>
</head>
<body>

<BODY bgcolor="#0099CC">



<?php
$bits = $_POST['bitsOne'];
print "<h3>You Selected, $bitsOne , bits!</h3>";

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";
        break;
    case 2:
echo "<br>You Chose 2 Bits";
echo "<br>There are 62 Hosts Per Subnet";
echo "<br>There are 4 Maximum Subnets" ;
    case 3:
echo "<br>You Chose 3 Bits";
echo"<br>There are 30 Hosts Per Subnet";
echo"<br>There are 8 Maximum Subnets";
    case 4:
echo "You Chose 4 Bits";
echo"<br><br>There are 14 Hosts Per Subnet";
echo"<br>There are 16 Maximum Subnets";
        break;
    case 5:
echo "<br>You Chose 5 Bits";
echo "<br>There are 6 Hosts Per Subnet";
echo "<br>There are 32 Maximum Subnets" ;
        break;
    case 6:
echo "<br>You Chose 6 Bits";
echo "<br>There are 2 Hosts Per Subnet";
echo "<br>There are 64 Maximum Subnets" ;
        break;
}



?>

</body>
</html>
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
View Public Profile Visit lynxus's homepage!
 
Old 02-11-2010, 04:50 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
Should i change my test.php to the one that you posted? with the echo's?
stupid21 is offline
View Public Profile
 
Old 02-11-2010, 04:53 PM Re: PhP Homework Due In 2 Days! Please Help!
Average Talker

Posts: 18
Name: Stevie
Trades: 0
Omg i love you.....

the only thing wrong is that its showing this
Quote:
You Selected, 2 , bits!


You Chose 2 Bits
There are 62 Hosts Per Subnet
There are 4 Maximum Subnets
You Chose 3 Bits
There are 30 Hosts Per Subnet
There are 8 Maximum SubnetsYou Chose 4 Bits

There are 14 Hosts Per Subnet
There are 16 Maximum Subnets

I just need it to show the Bits that they chose
stupid21 is offline
View Public Profile
 
Closed Thread     « Reply to PhP Homework Due In 2 Days! Please Help!

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.00669 seconds with 12 queries