Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post random code
Author Message
Mickey
Down with MJ yo

Posts: 3,663.2843
Threads: 251
Joined: 26th Apr 2008
E-Pigs: 28.7300
Offline
Post: #25
RE: Post random code

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<html>
<head>
<title>Calcy</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<fieldseT>
<legend>Numbers</legend>
    <p>Input one : 
      <input type="text" name="input"><? echo $input; ?>
      <br /> 
      <br />
    Input 2 : 
    <input type="text" name="input2">
  </p>
    <p>Select which you would like to do:
      <SELECT name="mode" size=1>
        <OPTION selected value="add"> Addition </OPTION>
        <OPTION value="minus"> Minus </OPTION>
        <OPTION value="multiply"> Multiply </OPTION>
        <OPTION value="square"> Square route of input one </OPTION>
      </SELECT>
<br />
      <input name="submit" type="submit" value="submit">
        </p>
        </fieldset>
</form>
<?php
if(isset($_POST['submit'])){
    
$input = $_POST['input'];
$input2 = $_POST['input2'];

    if(empty($input) || empty($input2)){
        echo 'You have not provided all the information';
    } elseif(!ereg ("([0-9])", $input)){
        echo 'Please enter Numbers only';
    } elseif( $HTTP_POST_VARS['mode'] === 'minus'){
        echo $input - $input2;
    } elseif( $HTTP_POST_VARS['mode'] === 'add') {
        echo $input + $input2;
    } elseif( $HTTP_POST_VARS['mode'] === 'multiply') {
        echo $input * $input2;
    } elseif( $HTTP_POST_VARS['mode'] === 'square') {
        echo sqrt($input);
    } else {
        echo 'You have not given the correct information';
    }
}
?>


</body>
</html>


By the way not mine


[Image: MiCk3Y.jpg]

[Image: battle.png]

Spoiler for link:
(This post was last modified: 24/02/2009 10:43 PM by Mickey.)
24/02/2009 10:42 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Post random code - Mickey - 24/02/2009, 11:15 AM
RE: Post random code - feinicks - 24/02/2009, 11:19 AM
RE: Post random code - Nacos - 24/02/2009, 11:34 AM
RE: Post random code - Mickey - 24/02/2009, 11:22 AM
RE: Post random code - S7* - 24/02/2009, 12:02 PM
RE: Post random code - PLZDELETE - 24/02/2009, 12:05 PM
RE: Post random code - S7* - 24/02/2009, 12:08 PM
RE: Post random code - feinicks - 24/02/2009, 12:17 PM
RE: Post random code - Mc Cabe - 24/02/2009, 12:37 PM
RE: Post random code - Assassinator - 24/02/2009, 04:17 PM
RE: Post random code - Mythos - 24/02/2009, 04:27 PM
RE: Post random code - Mickey - 24/02/2009, 06:08 PM
RE: Post random code - ZiNgA BuRgA - 24/02/2009, 06:20 PM
RE: Post random code - boogschd - 24/02/2009, 06:38 PM
RE: Post random code - ZiNgA BuRgA - 24/02/2009, 06:53 PM
RE: Post random code - -PHENOMENON- - 24/02/2009, 07:05 PM
RE: Post random code - boogschd - 24/02/2009, 07:08 PM
RE: Post random code - -PHENOMENON- - 24/02/2009, 07:11 PM
RE: Post random code - feinicks - 24/02/2009, 08:01 PM
RE: Post random code - boogschd - 24/02/2009, 09:24 PM
RE: Post random code - krystabegnalie - 24/02/2009, 08:02 PM
RE: Post random code - Slushba132 - 24/02/2009, 09:47 PM
RE: Post random code - Sparker - 24/02/2009, 10:28 PM
RE: Post random code - Gadget - 24/02/2009, 10:40 PM
RE: Post random code - Mickey - 24/02/2009 10:42 PM

Forum Jump:


User(s) browsing this thread: 2 Guest(s)

 Quick Theme: