Submitted information not being displayed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm attempting to takke information submitted from a web page through a POST
action, insert it into a MySQL database and upon success display the information
in a table for the submitter to see.  For some reason empty fields are inserted
into the database and the data doesn't show up in the resulting table - just the
headers.  The fields of type timestamp come up all "0".

I'm running PHP v.4.1.2 and MySQL v.3.23.52 on my server.

The form action and subscribe.php follows:

<FORM ACTION="subscribe.php" METHOD="POST">

<TABLE WIDTH=210 CELLPADDING=0 CELLSPACING=0 BORDER=0>
    <TR>
        <TD><FONT style="font-size: 13px" face="verdana,sans-serif" size="+1"
color="#3300CC"><B>Subscribe!</B></FONT></TD>
    </TR>
    <TR>
        <TD><IMG SRC="images/pixel.gif" WIDTH=1 HEIGHT=4 BORDER=0></TD>
    </TR>
    <TR>
        <TD>
            <p><font style="font-size: 13px" size="+1">Members - <br>
            Enter your name, ID number and <br>
            email address to join the mailing list today!</FONT><BR>
              <BR>
              <input type="text" size="20" name="FirstName" value="First Name">
              <BR><BR>
              <input type="text" size="30" name="LastName" value="Last Name">
              <BR><BR>
              <input type="text" size="10" name="id_num" value="ID-0000">
              <BR><BR>
              <input type="text" size="60" name="Email" value="your email">
          </p>
            <P>
            <FONT style="font-size: 9pt" face="Geneva,Helvetica,Arial,Sans
Serif" size="-1">&nbsp;<input type="submit" value="SUBMIT"></FONT>          
        </TD>
    </TR>
    
</TABLE>
            
</FORM>



<HTML>
<HEAD>
<TITLE>Processing Subscription Information</TITLE>
</HEAD>
<BODY>

<?php
/* This page receives and handles the data generated by "index.html". */
// Trim the incoming data.
$Array["FirstName"] = trim ($Array["FirstName"]);
$Array["LastName"] = trim ($Array["LastName"]);
$Array["id_num"] = trim ($Array["id_num"]);
$Array["Email"] = trim ($Array["Email"]);

// Set the variables for the database access:
$Host = "localhost";
$User = "username";
$Password = "password";
$DBName = "database";
$TableName = "Subscribers";

$Link = mysql_connect ($Host, $User, $Password);
$Query = "INSERT into $TableName values ('0', '$Array[FirstName]',
'$Array[LastName]', '$Array[id_num]', '$Array[Email]', 'NULL', 'NOW()')";

if (mysql_db_query ($DBName, $Query, $Link)) {
    $success = 1;
} else {
    print ("The query could not be executed!<BR>\n");
} 
mysql_close ($Link);

if ($success) {

    print ("<font style=\"font-size: 13px\" size=\"+1\">THE INFORMATION YOU
SUBMITTED WAS AS FOLLOWS:</FONT><BR><BR>\n");
// Create a table.
    print ("<TABLE BORDER=1 WIDTH=\"75%\" CELLSPACING=2 CELLPADDING=2
ALIGN=CENTER>\n");
        print ("<TR ALIGN=CENTER VALIGN=TOP>\n");
            print ("<TD ALIGN=CENTER VALIGN=TOP>Name</TD>\n");
            print ("<TD ALIGN=CENTER VALIGN=TOP>ID Number</TD>\n");
            print ("<TD ALIGN=CENTER VALIGN=TOP>Email Address</TD>\n");
        print ("</TR>\n");
        print ("<TR ALIGN=CENTER VALIGN=TOP>\n");
            print ("<TD ALIGN=CENTER VALIGN=TOP>$Array[FirstName]
$Array[LastName]</TD>\n");
            print ("<TD ALIGN=CENTER VALIGN=TOP>$Array[id_num]</TD>\n");
            print ("<TD ALIGN=CENTER VALIGN=TOP>$Array[Email]</TD>\n");
        print ("</TR>\n");
    print ("</TABLE>\n");

    print ("<FORM ACTION=\"subscription.html\">\n");

    print ("<center><input type=\"submit\" value=\"Take Me to the Subscription
Page\"></center>\n");

    print ("</FORM>\n");
}


?>

</BODY>
</HTML>
-----
Bruce Sommer
bes-tech1@sommerfamily.org
http://www.sommerfamily.org/~besommer/index.html

"SCSI is *NOT* magic.  There are *fundamental technical reasons* why it is necessary to sacrifice a young goat to your SCSI chain now and then."
-- John Woods

Lifetime Member of JPFO <http://www.jpfo.org/>

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux