Try "<?php" if this works, then most likely you have php short tags
disabled. To enable "<?"  Short tags check your php.ini file.

-----Original Message-----
From: Kirk Babb [mailto:[EMAIL PROTECTED]]
Sent: Monday, April 01, 2002 6:24 PM
To: [EMAIL PROTECTED]
Subject: [PHP] $PHP_SELF

SysInfo: Apache/1.3.24 (Win32) PHP/4.1.3-dev

I have a question that could be Apache, could be php, but I'm so new to this
I have to ask: what is wrong with my code for the form action?  Apache does
not recognize the <? as the beginning of php code and gives an error
"filename is not valid" whenever this form is submitted [note: phpinfo() and
several other php files work with no problem]?

<FORM ACTION="<? echo( $PHP_SELF); ?>" METHOD=POST>
   SSN:         <INPUT TYPE=INT NAME="ssn"><BR>
   First Name:  <INPUT TYPE=TEXT NAME="firstname"><BR>
   Last Name:   <INPUT TYPE=TEXT NAME="lastname"><BR>
   Employer:    <INPUT TYPE=TEXT NAME="employer"><BR>
   Comments:    <INPUT TYPE=TEXT NAME="comments"><BR>
   <CENTER>
   <INPUT TYPE=SUBMIT NAME="submitalumni" VALUE="SUBMIT">
   </CENTER>
   </FORM>

<?

   //  Connect to the db server
   $dbconn = @mysql_connect("localhost", "root", "password");

   if (!$dbconn) {
      echo( "<P>Unable to connect to the database server at this
time.</P>" );
      exit();
   }

   //  Select the Alumni db
   if(! @mysql_select_db("Alumni") ) {
      echo( "<P>Unable to locate the Alumni db at this time.</P>" );
      exit();
   }

   // If an alumni information record has been submitted

    if ("SUBMIT" == $submitalumni) {
      $sql = "INSERT INTO Alumni SET " .
              "SSN='$ssn', " .
              "FIRST_NAME='$firstname', " .
              "LAST_NAME='$lastname', " .
              "EMPLOYER='$employer', " .
              "COMMENTS='$comments' ";
      if (mysql_query($sql)) {
        echo( "<p>Your alumni information has been added.</p>");
      } else {
        echo( "<P>Error adding submitted alumni information: " .
             mysql_error() . "</P>");
      }
    }
    echo("<P> Here are all the Alumni in our database: </P>");

    // Request all alumni entries
    $result=mysql_query(
    "SELECT * from alumni");
    if (!$result) {
       echo( "<P>Error performing query: " . mysql_error() . "</P>");
       exit();
    }
    // display alumni info in paragraph form
    while ( $row = mysql_fetch_array($result) ) {
        echo( "<P>" . $row["SSN"] . "</P>");
    }

?>


THANKS for your help!  - Kirk



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to