Results 1 to 2 of 2

Thread: beginner error: forms not appearing

  1. #1
    Join Date
    Feb 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default beginner error: forms not appearing

    new to php, cant get the forms next to a: and b: to appear in the html portion of my code:

    [CODE]
    2 <?php
    3 if (isset($_POST['submit']))
    4 {
    5 $a = $_POST['a'];
    6 $b = $_POST['b'];
    7 if ($a == $b) {
    8 echo "a is equal to b.";
    9 }
    10 }
    11
    12 ?>
    13 <HTML>
    14 <BODY>
    15 <center><br /><br />
    16 <form method="post" action=" <?PHP echo $_SERVER['PHP_SELF']; ?> " >
    17 a: <insert type="text" name="a"> <br />
    18 b: <insert type="text" name="b"> <br />
    19 <input type="submit" name"submit">
    20 </form>
    21 </BODY>
    22 </HTML>
    [CODE]

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    PHP is added into existing HTML pages and does not change anything except that which is inside the <?php ?> blocks. In other words, this is not a problem with PHP. In fact, your PHP looks like it should, probably, work.

    <insert> is not an html element. You want <input>.

    Also, that code is very messy and invalid. For example, you never close your <center> tag, and that element is not the modern way to center elements on the page anyway. And overusing <br> is not the best way to space things.

    I don't mean for all of this to sound too harsh, but start with the basics and build on a strong foundation or you will have a lot more problems trying to do more complex things.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •