IPB
Your FREE membership includes:
  • A friendly community where you can come to chat
  • Receive completely FREE quality web hosting!
  • Get reviews and suggestions for your websites!
  • Take part in competitions where you can win prizes from cash, vouchers, or win special unadvertised hosting

Welcome Guest ( Log In | Register )


Shortcut links:
Profile
Personal Photo
Rating
 
Options
Options
Personal Statement
willsc8forwings doesn't have a personal statement currently.
Personal Info
willsc8forwings
Advanced Member
Age Unknown
Gender Not Set
Location Unknown
Birthday Unknown
Interests
No Information
Statistics
Joined: 18-November 06
Profile Views: 76*
Last Seen: 1st January 2008 - 02:09 AM
Local Time: Dec 2 2008, 12:23 PM
215 posts (0 per day)
Contact Information
AIM No Information
Yahoo No Information
ICQ No Information
MSN No Information
Contact Private
* Profile views updated each hour

willsc8forwings

Advertising Team


Topics
Posts
Comments
Friends
My Content
14 May 2007
never mind ends up it was deleted completly. Not a bad thing because I had nothing I wanted saved on it biggrin.gif
6 May 2007
What would the PHP script be to send a password to someone who has registered a username? I have registration.php done, but not sure how to do this
OR
How could I set it so that a member can pick their password on the registration screen?
5 May 2007
For some reason my site keeps going off and on. Does anyone have any idea on when it will stop?
3 May 2007
I have an html page right now, and I was woundering how to make it so that when someone clicks on a link, there is no page refresh. Anyone know how? laugh.gif
1 May 2007
just thought I would make one wink.gif

Create a page called form.php, in this place:
CODE
<form method="post" action="calc.php" name="caclulator">
<table border="0" cellpadding="2" cellspacing ="0">
<tr>
<td colspan="4" align="center">
<h3>Simple Math Calculator</h3>
<tr><td>
<input type="text" name="form1" />
<td>
<select name="func">
<option value="add">+</option>
<option value="sub">-</option>
<option value="mult">x</option>
<option value="div">/</option>
</select>
<td>
<input type="text" name="form2">
<td>
<input type="submit" name="submit" value="submit">
</table>
</form>


We have made a table, and in that table we have created the input form called form1 and form2, and in the middle there is the toption list whether to pick add, subtract multiply divide or add. Easy.
Then the submit button.. for submitting the information tongue.gif

Okay, we should all know what the next page is gonna be called because :

QUOTE
<form method="post" action="calc.php" name="caclulator">



Kinda gave it away with: action="calc.php" so, create the new page and call it calc.php.

In that page place:
CODE
<?php
$num1 = $_POST['form1'];
$num2 = $_POST['form2'];
$function = $_POST['func'];
$submit = $_POST['submit'];
?>


Okay, we've used "<?php" to open the script, and then setting the values num1, num2 and function. Function being the type of math we're using. We're using "$_POST" because, on the HTML page called form.html we set the method to post. this php basically says: $num1 = data submitted from previous page [' name of the data'];


We'll move on.

Calc.php should now look like this:
CODE
<?php
// Set the intergers to 0. This means that if $num1 or $num1 is text, it won't work.
$num1 = 0;
$num2 = 0;

// Making the vars of the _POST data to save time
$num1 = $_POST['form1'];
$num2 = $_POST['form2'];
$func = $_POST['func'];
$submit = $_POST['submit'];

// Checks if $num1 or $num2 is empty
if(!$num1 || !$num2){
// If it is, include form.php
include('form.php');
} else if($func == add){
// If func == add, include the form page, AND, the solution.
include('form.php');
$num3 = $num1 + $num2;
echo "<br /><br />";
echo "<b>Solution</b>: <br />";
echo "$num1 + $num2 = $num3";

} else if($func == sub){
include('form.php');
$num3 = $num1 - $num2;
echo "<br /><br />";
echo "<b>Solution</b>: <br />";
echo "$num1 - $num2 = $num3";

} else if($func == div){
include('form.php');
// The @ Sign supresses the error, because in PHP, it gives an error that you can't divide by 0
@ $num3 = $num1 / $num2;
// This then checks if $num2 = 0
if ($num2 == 0){
// Tells user that you can't divide it
echo '<b>You can not divide a number by 0</b>';
// Exits the script, so it can't echo it or anything
exit;
}
echo "<br /><br />";
echo "<b>Solution</b>: <br />";
echo "$num1 / $num2 = $num3";

}else{
include('form.php');
$num3 = $num1 * $num2;
echo "<br /><br />";
echo "<b>Solution</b>: <br />";
echo "$num1 * $num2 = $num3";
}
?>


So in the end you should only have 2 files: form.php and calc.php
-Enjoy happy.gif
Last Visitors


10 Apr 2008 - 3:10


28 Dec 2007 - 20:08


5 Oct 2007 - 15:21

Comments
Other users have left no comments for willsc8forwings.

Friends
There are no friends to display.
© GrandForums.com