Background: I'm attempting to develop an online SCUBA Diving Log application. My plans are to put it together in pieces while at the same time learning on what I've done on a previous section.
The first part I have decided to start is the dive buddy section. This section will contain all your standard contact information (ie name, address, city, state, zip, phone numbers, email addresses and a photo).
I've broken this down even further to just wanting to enter a first name, last name, address line one and address line two.
The below code 'works' meaning no errors are produced just no data is being populated in the tables. the buddy table record count never increases were the address table does increase but no data is passed, it is just a blank entry.
The below code was butchered from several different examples from books I'm using. Connection to the database works fine BTW.
Thank you for any advise!!
Expand|Select|Wrap|Line Numbers
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <title>Dive Buddy Entry Page</title>
- </head>
- <body>
- <?php require_once('../Connections/scuba.php'); ?>
- <?php
- $Fname =$POST['Fname'];
- $Lname =$POST['Lname'];
- $address_1 =$POST['address_1'];
- $address_2 =$POST['address_2'];
- $sql = "INSERT into scubalog.buddy SET
- Fname='$Fname',
- Lname='$Lname'";
- $sql = "INSERT into scubalog.address SET
- address_1='$address_1',
- address_2='$address_2'";
- if (@mysql_query($sql)) {
- echo '<p> New Buddy Added<p>';
- } else {
- echo '<p>Error adding new buddy<p> ' .
- mysql_error() . '<p>';
- }
- ?>
- <p><a href="<?php echo $_server['PHP_SELF']; ?>">Add another buddy</a></p>
- <FORM ACTION="<?php echo $_server['PHP SELF']; ?>" method="post">
- <table align="left">
- <tr valign="baseline">
- <td nowrap align="right">First Name:</td>
- <td><input type="text" name="Fname" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Last Name:</td>
- <td><input type="text" name="Lname" size="32"></td>
- </tr>
- <tr valign="baseline">
- <td nowrap align="right">Address_1:</td>
- <td><input type="text" name="address_1" size="32"></td>
- </tr>
- <td nowrap align="right">Address_2</td>
- <td><input type="text" name="address_2" size="32"></td>
- </tr>
- <tr valign="baseline">
- <tr valign="baseline">
- <td nowrap align="right"> </td>
- <td><input type="submit" value="Insert record"></td>
- </tr>
- </table>
- <input type="hidden" name="MM_insert" value="form1">
- </form>
- </body>
- </html>
Please use code tags when you post to the Forum. Read the Instruction on the Right side pane to your Editor.