SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Form Submission and databse listing problem

    Please help me Ive been at this for 2 days and its driving me crazy!!

    I have a MySQL database with one main table where I am using a form to enter the info. The proble is that The data isnt getting into the form when the PHP Self is submitted. I have been throught the syntax (Letter by letter, believe me) but still some elements of the data dont get pushed into the database. Mostly the drop down lists.

    The drop down that takes colours works OK and also the first 8 or nine fields. Then it all goes square. Some of the data is working and some not. I have the same problem on this PC and My Laptop where I have the forms also.

    A form newprop.php which looks like this
    Code:
    include_once ("../connection.php");
    
    include ("../DateDropDown.php");
    
    if (isset($_POST['HouseNr'])):
      // A new property has been entered
      // using the form.
    
      $kid = $_POST['keyid'];
      $HouseNr = $_POST['HouseNr'];
      $StreetName = $_POST['StreetName'];
      $Town = $_POST['Town'];
      $County = $_POST['County'];
      $Postcode = $_POST['Postcode'];
      $ClientCode = $_POST['ClientCode'];
      $AlarmCode = $_POST['AlarmCode'];
      $AgentCode = $_POST['AgentCode'];
      $keycollect = $POST['keycollect'];
      $CollectKeysFrom = $POST['CollectKeysFrom'];
      $WorkReq = $POST['WorkReq'];
      $Contractor = $POST['Contractor'];
      $WorkStartDate = $POST['WorkStartDate'];
      $WorkEndDate = $POST['WorkEndDate'];
      $Tenanted = $POST['Tenanted'];
      $Bedrooms = $POST['Bedrooms'];
      $Description = $POST['Description'];
      $RentAmount = $POST['RentAmount'];
      $Location = $POST['Location'];
      $PropertyType = $POST['PropertyType'];
      $curdate = date("Y-m-d");
      
      // $keycolourid = $_POST['keyid'];
    
      if ($kid == '') {
        exit('<p>You must choose a keyring colour for this property. Click "Back" and try again.</p>');
      }
    
      $sql = "INSERT INTO properties SET
          HouseNr='$HouseNr',
    	  StreetName='$StreetName',
    	  town='$Town',
    	  County='$County',
    	  Postcode='$Postcode',
    	  AlarmCode='$AlarmCode',
    	  MRAIntCode='$MRAIntCode',
    	  ClientCode='$ClientCode',
                   KeyRingColourid='$kid',
    	  AgentCode='$AgentCode',
    	  KeysCollected='$keycollect',
    	  DateEntered='$curdate', 
    	  CollectKeysFrom='$CollectKeysFrom',
    	  WorkReq='$WorkReq',
    	  ContractorName='$Contractor',
    	  WorkStartDate='$curdate',
    	  WorkEndDate='$curdate',
    	  Tenanted='$Tenanted',
    	  Bedrooms='$Bedrooms',
    	  Description='$Description',
    	  RentAmount='$RentAmount',
    	  Location='$Location',
    	  PropertyType='$PropertyType'";
    	  
    	  
      if (@mysql_query($sql)) {
        echo '<p>New Property has been added</p>';
      } else {
        exit('<p>Error adding new Property: ' . mysql_error() . '</p>');
      }
    
    
    ?>
    
    
    <p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Add another Property</a></p>
    <p><a href="launch.php">Return to Switchboard search</a></p>
    
    <?php
    else: // Allow the user to enter a new property
    
      $colours = @mysql_query('SELECT * FROM colours');
      if (!$colours) {
        exit('<p>Unable to obtain author list from the database.</p>');
      }
    
    
    ?>
    
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    
    <table bgcolor="FFFFFF" width=100% cellspacing="2" cellpadding="2" border="1">
    <tr=>
        <td>Enter House Number:</td>
        <td><input type="text" name="HouseNr" size=40>
    	</td>
    	<td>House Number</td>
    </tr>
    <tr>
        <td>Enter Street Name:</td>
        <td><input type="text" name="StreetName" size=40></td>
    	<td>Street Name of Property</td>
    </tr>
    <tr>
        <td>Enter Town:</td>
        <td><input type="text" name="Town" size=40></td>
    	<td>Enter the Town Name</td>
    </tr>
    <tr>
        <td>Enter County:</td>
        <td><input type="text" name="County" size=40></td>
    	<td>Enter the County</td>
    </tr>
    <tr>
        <td>Enter Postcode:</td>
        <td><input type="text" name="Postcode" size=40></td>
    	<td>Enter the PostCode</td>
    </tr>
    <tr>
        <td>Enter Alarm Code:</td>
        <td><input type="text" name="AlarmCode" size=40></td>
    	<td>Alarm Code if applicable</td>
    </tr>
    <tr>
        <td>MRA Internal Code:</td>
        <td><input type="text" name="MRAIntCode" size=40></td>
    	<td>MRA internal Code entered by Amersham</td>
    </tr>
    <tr>
        <td>MRA Client Code:</td>
        <td><input type="text" name="ClientCode" size=40></td>
    	<td>MRA internal Code entered by Amersham</td>
    </tr>
    <tr>
    <td>Keyring Colour Used for Property</td>
    <td>
    <select name="keyid" size="1">
      <option selected value="">Select One</option>
      <option value="">---------</option>
    <?php
      while ($colours = mysql_fetch_array($colours)) {
        $keyid = $colours['id'];
        $cname = htmlspecialchars($colours['Colour']);
        echo "<option value=$cname>$cname</option>\n";
      }
    ?>
    </select><td>Choose the Keyring Tag Colour used</td>
    </td>
    </tr>
    <tr>
        <td>MRA Agent Code:</td>
        <td><input type="text" name="AgentCode" size=40></td>
    	<td>Which Estate Agent has been used</td>
    </tr>
    <tr>
        <td>Keys have been collected!:</td>
        <td><input type="text" name="keycollect" size=40></td>
    	<td>Tick only when keys have been collected from agent!</td>
    </tr>
    
    <tr>
        <td>Collect Keys from Where?:</td>
        <td><input type="text" name="CollectKeysFrom" size=40></td>
    	<td>Enter a Brief Description</td>
    </tr>
    <tr>
        <td>Work Required on Property:</td>
        <td>
    	<select name="WorkReq" size=1>
    	<option selected value="Non Allocated">Select One</option>
    	<option value="Light">Light</option>
    	<option value="Medium">Medium</option>
    	<option value="Heavy">Heavy</option>
    	</select>
    	</td>
    	<td>Describe the Work Required</td>
    </tr>
    <tr>
        <td>Contractor Name:</td>
        <td><select name=ContractorName size=1>
    	<option value=Non Allocated>Select One</option>
    	<option value=Dave>DecorDave</option>
    	<option value=Tony>Tony Hill</option>
    	<option value=Peter>Peter</option>
    	</select></td>
    	<td>Contractor Name</td>
    </tr>
    <tr>
        <td>Work Start Date:</td>
    	<td><?php DateDropDown(90,"Dropdate"); ?>
       </td>
    	<td>Start date</td>
    </tr>
    <tr>
        <td>Work End Date:</td>
        <td><input type="text" name="WorkEndDate" size=40></td>
    	<td>Anticipated end date</td>
    </tr>
    <tr>
        <td>Tenanted:</td>
        <td><input type="Text" name="Tenanted"></td>
    	<td>Is the Property Tenanted?</td>
    </tr>
    <tr>
        <td>Number of Bedrooms:</td>
        <td><select name="Bedrooms" size=1>
    	<option value="">Select One</option>
    	<option value='1'>1</option>
    	<option value="2">2</option>
    	<option value="3">3</option>
    	<option value="4">4</option>
    	</select></td>
    	<td>Bedrooms</td>
    </tr>
    <tr>
        <td>Brief Description of property:</td>
        <td><input type="text" name="Description" size=40></td>
    	<td>Enter a Brief Description</td>
    </tr>
    <tr>
        <td>Rent Amount per week:</td>
        <td><input type="text" name="RentAmount" size=40></td>
    	<td>Enter amount in GBP</td>
    </tr>
    <tr>
        <td>Location:</td>
        <td><input type="text" name="Location" size=40></td>
    	<td>Describe location of Property</td>
    </tr>
    <tr>
        <td>Property Type:</td>
        <td><select name="PropertyType" size=1>
    	<option value="">Select One</option>
    	<option value="UpperFlat">Upper Flat</option>
    	<option value="GroundFlat">Ground Floor Flat</option>
    	<option value="Maissonette">Maissonette</option>
    	<option value="House">House</option>
    	<option value="Studio">Studio</option>
    	</select></td>
    	<td>Property Type Selection</td>
    </tr>
    </table>
    
    </br>
    <input type="submit" value="SUBMIT" />
    </form>
    <?php endif; ?>
    
    </body>
    </html>
    The problem is that the form doesnt seem to be getting all the values set by the submit button.


    I have substituted the $whatever variables with absolute values ($Contractor = 'Blah') and it works perfectly.

    I really am tearing my hair out here guys. Can anyone see any gaping holes?

    Yours in frustration

    Keith

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    From a quick thrutch into DW,
    these lines should be $_POST not $POST!
    PHP Code:
      $keycollect $POST['keycollect'];
      
    $CollectKeysFrom $POST['CollectKeysFrom'];
      
    $WorkReq $POST['WorkReq'];
      
    $Contractor $POST['Contractor'];
      
    $WorkStartDate $POST['WorkStartDate'];
      
    $WorkEndDate $POST['WorkEndDate'];
      
    $Tenanted $POST['Tenanted'];
      
    $Bedrooms $POST['Bedrooms'];
      
    $Description $POST['Description'];
      
    $RentAmount $POST['RentAmount'];
      
    $Location $POST['Location'];
      
    $PropertyType $POST['PropertyType']; 
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SitePoint Addict kivison's Avatar
    Join Date
    Dec 2004
    Location
    Whitley Bay, Tyne & Wear, UK
    Posts
    246
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Talking

    OH Thank you! I have literally got a tear in my eye! tears of joy.

    OK now Im off to the pub!

    What can I get you?

    Keith

    Typical " Cant see the wood for the trees type issue". Ive been working with this for so long, that now it makes all the sence in the world.

    Thanks again

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    No problem, glad to help! It's amazing what a fresh pair of eyes can see!

    BTW make mine a pint of stella!
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....


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
  •