Problem with $_POST and Input

Discussion in 'PHP' started by ItamarP, Jun 28, 2009.

  1. #1
    I wrote this 2 codes
    The first is from the file "parabola.html"

    <html>
    
    <head>
    <b><u>Parabola-Full Process</u></b><br/>
    </head>
    
    Please enter the parabola (Ax^+bx+c) a , b and c values  ,  Example:<br/>
    </br>
    -3x^-5x+3  (Note ; X^ means x squared)<br/>
    </br>
    View at the function above:<br/>
    </br>
    It's 'a' value is -3 , <br/>
    </br>
    it's 'b' value is -5,<br/>
    </br>
    and it's 'c' value is 3 (+3)<br/>
    
    <form name="input" action="parabola2.php" method="post">
    a value:<br/>
    <input type="text" name="$a">
    </br>b value </br>
    <input type="text" name="$b">
    </br>c value </br>
    <input type="text" name="$c">
    <br/>
    </br><input type="submit" value="submit" form="submit">
    </form>
    
    </body>
    
    </html>
    PHP:


    the second one is from the file "parbola2.php"

    <?php
    
    //data from HTML Methods
    
    $a=$_POST['a'] ;             //funca
    $b=$_POST['b'] ;             //funcb
    $c= $_POST['c'] ;            //func-c
    
    //-->calculating
    
    $funcony=echo $c ;
    $funconx=(-1*$b+^^$b*$b-4*$a*$c^^):2
    $funconx2=(-1*$b-^^$b*$b-4*$a*$c^^):2
    $funcxmaxormin=-1*(b/2a) //if the func is happy it has max ,  else , it has min
    $funcymaxnormin=$a*$funcxmaxormin+$b*$funcxmaxormin+c
    
    if ($a==0) echo {"Error!The a value musn't be 0! 
    <ahref="www.site.end">Please Insert 'a' value again</a> " ; 
    }
    elseif ($a>0) echo {"The parabola is "happy" ";
    } 
    else echo {"The parabola is "sad" " ;} <br/>
    
    <b></u>Parabola's min/max point</u><b> </br>
    </br>
    
    if ($a>0)  //max or min point
    echo  {"The maximum point of the parabola is ($funcxmaxormin,$funcymaxnormin)" ;
    }
    else echo {"The minimum point of the parabola is ($funcxmaxormin,$funcymaxnormin)"}
    
    <b><u>Parabola's meeting with the x line: </u></b> </br>
    </br> echo "($funconx1,0)" , "(funconx2,0) ;
    
    <b><u>Parabola's meeting with the y line:</u></b> </br>
    </br> echo "(0,$funcony)" ;
    ?>
    PHP:



    when i click on the "submit" button i see all the content abvoe-->the code of "parabola.php" itself. where is the problem?
     
    ItamarP, Jun 28, 2009 IP
  2. credobyte

    credobyte Peon

    Messages:
    38
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The problem is that, it's not a PHP code ( only some part of all this mess ).
    By the first, go to tizag.com and learn about variables & echo function ( there's nothing to explain .. you simply don't know anything about PHP ) ;)
     
    credobyte, Jun 28, 2009 IP
  3. ItamarP

    ItamarP Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #3
    $funcony=echo $c

    i meant to
    $funcony=$c
     
    ItamarP, Jun 29, 2009 IP
  4. credobyte

    credobyte Peon

    Messages:
    38
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Here you go ( believe me, you need to learn a lot ) :
    <?php
    
    $a=$_POST['a'] ;             //funca
    $b=$_POST['b'] ;             //funcb
    $c= $_POST['c'] ;            //func-c
    
    //-->calculating
    
    $funcony=$c ;
    $funconx=(-1*$b+^^$b*$b-4*$a*$c^^):2;
    $funconx2=(-1*$b-^^$b*$b-4*$a*$c^^):2;
    $funcxmaxormin=-1*($b/2*$a); //if the func is happy it has max ,  else , it has min
    $funcymaxnormin=$a*$funcxmaxormin+$b*$funcxmaxormin+$c;
    
    if ($a == 0) {
    	echo "Error!The a value musn't be 0! <a href='www.site.end'>Please Insert 'a' value again</a> ";
    } elseif ($a>0) {
    	echo "The parabola is 'happy'";
    } else {
    	echo {"The parabola is 'sad' <br/>";
    }
    
    echo "<b></u>Parabola's min/max point</u><b> </br></br>";
    
    if ($a>0) { //max or min point
    	echo "The maximum point of the parabola is ($funcxmaxormin,$funcymaxnormin)";
    } else {
    	echo "The minimum point of the parabola is ($funcxmaxormin,$funcymaxnormin)";
    }
    
    echo "<b><u>Parabola's meeting with the x line: </u></b> </br></br>";
    echo "($funconx1,0)" , "(funconx2,0)" ;
    
    echo "<b><u>Parabola's meeting with the y line:</u></b> </br></br>";
    echo "(0,$funcony)";
    
    ?> 
    PHP:
     
    credobyte, Jun 29, 2009 IP