Jump to content

crmamx

Members
  • Posts

    417
  • Joined

  • Last visited

Posts posted by crmamx

  1. This is the simplest of forms, but it has no character. It is the type I use in everything.

     

    form1.php

    <html>
    <head>
    </head>
    <body>
    <?php
    // Connect to database=====================================================
    
    include("connect_db.php"); 
    
    // retrieve form data ======================================================
    
    $id = $_POST['id']; 
    
    // sending query ===========================================================
    
    $query = "SELECT ama,model_name,model_mfg,wingspan,engine,decibels FROM airplanes WHERE id='$id'";
    if( !$result = mysql_query($query) ) {
        echo "<br>Query $query<br>Failed with error: " . mysql_error() . '<br>';
    } else {
        $fetch = mysql_fetch_array( $result );
    }
    
    
    // $fetch = mysql_fetch_array(mysql_query("SELECT ama,model_name,model_mfg,wingspan,engine,decibels FROM airplanes
    // WHERE id='$id'"));
    
    // Output form with retrieved data ==========================================
    ?>
    <h3>Change the data and then click the CHANGE button</h3><br>
    <form name="myForm" action="delete_airplanes.php" onsubmit="return validateForm()" method="post">
    ID #:<input type="text" name="id" value="<?=$fetch[id]?>" /><br>
    AMA #:<input type="text" name="ama" value="<?=$fetch[ama]?>" /><br>
    Model Name:<input type="text" name="model_name" value="<?=$fetch[model_name]?>" /><br>
    Model Mfg:<input type="text" name="model_mfg" value="<?=$fetch[model_mfg]?>" /><br>
    Wingspan:<input type="text" name="wingspan" value="<?=$fetch[wingspan]?>" /><br>
    Engine:<input type="text" name="engine" value="<?=$fetch[engine]?>" /><br>
    Decibels:<input type="text" name="decibels" value="<?=$fetch[decibels]?>" /><br><br>
    <input name="submit" id="submit" value="CHANGE!" type="submit">
        
    </form>
    
    <br>
    <body>
    </html>
    

     

    I would love to be able to get this form to work.

     

    <!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>
      <title>Enter Airplane Data</title>
      <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1" />
      <meta name="language" content="en" />
      <style type="text/css">
    .focus { background: #FEF1C1; }
    .class123-label { font-family: Verdana; font-size: small; }
    .class123-sidebyside { float:left; margin:0 5px 0 0;}
    .class123-twocol { float:left; width:45%; margin:0 5px 0 0;}
    .class123-threecol { float:left; width:30%; margin:0 5px 0 0;}
    .class123-likert_style_li { display:inline-block; vertical-align:middle; text-align:center; top:0px; padding:2px; width:64px; height:50px; margin:0px; margin-right:1px; margin-bottom:1px; font:11px/18px verdana; background:#ddd; zoom:1; *display:inline; }
    .class123-likert_style_li2 { display:inline-block; vertical-align:middle; text-align:center; top:0px; padding:2px; width:64px; height:50px; margin:0px; margin-right:1px; margin-bottom:0px; font:12px/18px verdana; background:#fff; zoom:1; *display:inline; border-top:1px solid #ddd; }
    .fontbold { font-weight: bold; }
    .fontitalic { font-style: italic; }
    .requiredspan { font-family: Verdana; font-size:10px; color:#f00; } </style>
    </head>
    <body style="background-color: rgb(138, 174, 222); direction: ltr;">
    <div style="height: 50px;"> </div>
    <center>
    <table style="border-collapse: collapse;" id="AutoNumber1"
    border="0" cellpadding="0" cellspacing="0"
    width="658">
      <tbody>
        <tr>
          <td class="tdborder" colspan="3" width="658">
          <img alt="shadow" class="tdimagesus"
    src="/templates/cache/dynamicimage-1-1560BD.png" height="9"
    width="100%" /> </td>
        </tr>
        <tr>
          <td height="38" width="4"> </td>
          <td class="tdheader"
    style="border-style: solid solid none; border-color: rgb(1, 76, 169) rgb(1, 76, 169) -moz-use-text-color; border-width: thin thin medium;"
    bgcolor="#1560bd" height="38" width="650"> <img
    alt="logo"
    src="http://www.123contactform.com/templates/logos/computers_anvelope_white.png"
    align="left" /> </td>
          <td height="38" width="4"> </td>
        </tr>
        <tr>
          <td height="171" width="4"> </td>
          <td class="tdmain"
    style="border-style: none solid; border-color: -moz-use-text-color rgb(1, 76, 169); border-width: medium thin; padding-right: 10px;"
    bgcolor="#ffffff" height="171" width="650">
          <div class="selector-off">
          <center>
          <script type="text/javascript">
    <!--
    function InputActions(field,id) {
    var i=1;
    var lid="none";
    for (i=1;i<=100;i++) { lid='row'+i;
    lidsec='rowsec'+i;
    if (document.getElementById(lid) != null) {
    if (lid==id) {
    document.getElementById(lid).className='focus';
    if (document.getElementById(lidsec) != null)
    document.getElementById(lidsec).className='focus';
    }
    else {
    document.getElementById(lid).className='';
    if (document.getElementById(lidsec) != null)
    document.getElementById(lidsec).className=''; }
    } } } //-->
          </script>
          <form class="form"
    action="http://www.123contactform.com/contact-form-crmamx-122034.html"
    method="post" enctype="multipart/form-data"><input
    name="action" value="verify" type="hidden" />
            <table style="min-width: 250px;" cellpadding="4">
              <tbody>
                <tr id="row1">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684273"
    for="id123-control684273">Name:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684273" name="control684273"
    onclick="InputActions(this,'row1');"
    onkeyup="InputActions(this,'row1');" onchange="" value=""
    size="20" type="text" />
                  </td>
                </tr>
                <tr id="row2">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684275"
    for="id123-control684275">Subject:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684275" name="control684275"
    onclick="InputActions(this,'row2');"
    onkeyup="InputActions(this,'row2');" onchange="" value=""
    size="20" type="text" />
                  </td>
                </tr>
                <tr id="row3">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684281"
    for="id123-control684281">Model Name:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684281" name="control684281"
    onclick="InputActions(this,'row3');"
    onkeyup="InputActions(this,'row3');" onchange="" value=""
    size="35" type="text" />
                  </td>
                </tr>
                <tr id="row4">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684286"
    for="id123-control684286">Model Mfg:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684286" name="control684286"
    onclick="InputActions(this,'row4');"
    onkeyup="InputActions(this,'row4');" onchange="" value=""
    size="35" type="text" />
                  </td>
                </tr>
                <tr id="row5">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684287"
    for="id123-control684287">Wingspan:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684287" name="control684287"
    onclick="InputActions(this,'row5');"
    onkeyup="InputActions(this,'row5');" onchange="" value=""
    size="35" type="text" />
                  </td>
                </tr>
                <tr id="row6">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684288"
    for="id123-control684288">Engine Mfg/Size:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684288" name="control684288"
    onclick="InputActions(this,'row6');"
    onkeyup="InputActions(this,'row6');" onchange="" value=""
    size="35" type="text" />
                  </td>
                </tr>
                <tr id="row7">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" id="id123-title684289"
    for="id123-control684289">Decibel Reading:</label><span
    class="requiredspan customspan" title="Required field">*</span></td>
                  <td style="" align="left"><input
    id="id123-control684289" name="control684289"
    onclick="InputActions(this,'row7');"
    onkeyup="InputActions(this,'row7');" onchange="" value=""
    size="35" type="text" />
                  </td>
                </tr>
                <tr id="row8">
                  <td style="text-align: left;" valign="top"><label
    class="class123-label" for="id123-captcha" id="verifno">Verification
    No.:</label><span class="requiredspan customspan"
    title="Required field">*</span></td>
                  <td align="left" valign="top"><input
    id="id123-captcha" onclick="InputActions(this,'row8');"
    onkeyup="InputActions(this,'row8');" name="txtNumber"
    value="" size="16" type="text" /></td>
                </tr>
                <tr>
                  <td align="right"><a
    title="Don't know why you have to enter this verification number? Click here!"
    href="http://www.123contactform.com/faq.html#q1"
    onclick="window.open('http://www.123contactform.com/faq.html#q1','_blank','width=740, height=90, left=' + (screen.width/2-370) + ', top=250');return false;"><img
    src="http://www.123contactform.com/img/help_icon.gif"
    alt="contact form faq" border="0" /></a></td>
                  <td align="left"><img
    alt="verification image"
    src="http://www.123contactform.com/random.php" /></td>
                </tr>
                <tr>
                  <td></td>
                  <td align="left"><input
    class="class123-button" id="id123-button-send"
    value="Send email" type="submit" /></td>
                </tr>
              </tbody>
            </table>
            <div style="height: 1px; display: none; visibility: hidden;">
            <input name="email" type="text" /></div>
          </form>
          </center>
          </div>
          </td>
          <td height="171" width="4"></td>
        </tr>
      </tbody>
    </table>
    </center>
    </body>
    </html>
    

     

    Of course I did not write this.

     

    I have never used a form before built as a table, only like the form1.php

     

    1. Does this form work in the same way?

    2. I want to retrieve a record from the db and display it in this form. Do I do it in the same way as in form1.html with a value=?

    3. If the above is true then I would assume (that always gets me in  trouble) that in my next program (update_db.php) I would capture the input data the same.

     

    Thanks

     

  2. I never could get the thing to work completely. So I found something else and tried it and so far it appears to work ok. Never used FETCH before. I like it.

     

    <html>
    <head>
    </head>
    <body>
    <?php
    // Connect to database=====================================================
    
    include("connect_db.php"); 
    
    // retrieve form data ======================================================
    
    $id = $_POST['id']; 
    
    // sending query ===========================================================
    
    $fetch = mysql_fetch_array(mysql_query("SELECT ama,model_name,model_mfg,wingspan,engine,decibels FROM airplanes
    WHERE id='$id'"));
    
    // Output form with retrieved data ==========================================
    ?>
    <form name="myForm" action="delete_airplanes.php" onsubmit="return validateForm()" method="post">
    AMA #:<input type="text" name="ama" value="<?=$fetch[ama]?>" /><br>
    Model Name:<input type="text" name="model_name" value="<?=$fetch[model_name]?>" /><br>
    Model Mfg:<input type="text" name="model_mfg" value="<?=$fetch[model_mfg]?>" /><br>
    Wingspan:<input type="text" name="wingspan" value="<?=$fetch[wingspan]?>" /><br>
    Engine:<input type="text" name="engine" value="<?=$fetch[engine]?>" /><br>
    Decibels:<input type="text" name="decibels" value="<?=$fetch[decibels]?>" /><br>
    <input type="Submit">
    </form>
    
    <br>
    <body>
    </html>

     

    Any comments or advice on this?

     

    Now I am just praying that my update_db.php that you fixed for me will pick up the data and update the db.

  3. Thanks Pikachu, you are most helpful as always.

     

    I will use your code which is more correct, but just for the record, this statement from the other two programs that work (and output to a table) I left out of this program. Damn!!!

    while($row = mysql_fetch_array( $result )) {
    
    // and then of course to table
    
    echo "<tr><td>";
    echo $row['id'];
    

  4. I got the update to the db working.

     

    Now I am trying to get the form input that feeds the update program to work.

     

    This code works in two other programs but it doesn't work here. The only difference is in the other two programs I am outputing a table rather than a form. It displays the ID in the form but doesn't display the AMA.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Change data</title>
    </head>
    
    <?php
    
    // Connect to db  =============================================================
    
    include("connect_db.php");
    
    // Retrieve form data ========================================================
    
    $id = $_POST['id'];
    
    // Send query ===========================================================
    
    $result = mysql_query("SELECT * FROM airplanes
    WHERE id='$id'") or die(mysql_error());  
    
    if (!$result) {
        die("Query to show fields from table failed");
    }
    
    ?>
    
    <h3> Change an airplane</h3>
    <form action="update_db_airplane.php" method="post">
              
     
        
    ID #: <input name="id" type="text" size="3" maxlength="3" value="<?php echo $id; ?>"><br>
    AMA #:<input name="ama" size="6" maxlength="6" type="text" value="<?php echo $ama; ?>"><br>
            
    Model Name: <input name="model_name" size="6" maxlength="6" type="text"><br>
               
    Model Mfg: <input name="model_mfg" size="30" maxlength="30" type="text"><br>
            
        
    Wingspan: <input name="wingspan" size="3" maxlength="3" type="text">
        In inches<br>
    Engine Mfg & Size: <input name="engine" size="30" maxlength="30" type="text"><br>
         
    Sound Reading: <input name="decibels" size="3" maxlength="3" type="text">
      
    Leave blank if you don't know it.<br>
           
           
           
           
           
           
           
           
         <input value="Change" type="submit"></form>
    </body>
    </html>
    

     

    While I am at it what is a better way to align the boxes in the form?

     

    Thanks

  5. You never execute the UPDATE query with mysql_query(); it's just a string in the middle of nowhere.

    Just didn't know how. Tried everything I could find in the tutorials.

    I suspect the SELECT query isn't really necessary; you can simply execute the UPDATE query, then if the query returns an error, or mysql_affected_rows() == 0, no record was updated.

    Of course you are right, I did this so I could visually see when it did or if it didn't. Will change the final code.

    I assume that $_POST['id'] is expected to be an integer? If so, it should be cast as one, and left unquoted in the query string.

    Yep!

    None of the other variables ($model_name, $model_mfg, $wingspan, $engine and $decibels) in the query string will have values, because they've not been assigned.

    I did that just to reduce the clutter while I tested. Let me ask, as is will those values just be null and write nothing?

     

    All form data, even from hidden fields, select boxes, radio buttons, etc. is subject to user manipulation, and should be validated and sanitized before being allowed into a query string.

    Shouldn't those values be validated in the preceeding form program?

     

    By the way, many thanks....it's working. Now let me see if I can finish it and capture, validate and update everything changed in the form.

  6. I am at my wit's end. My programs to add and delete records in the db work fine, but I cannot get the update program to work.

     

    I have completely rewritten the whole thing. The if statements are my version of seeing if a record is found. If not found, it prints. If found it also prints but does not update.

     

    <?php // Update airplane in database
    
    // Connect to database =====================================================
    
    include("connect_db.php");
    
    $id = $_POST['id']; // Retrieve form id
    
    // Send query ====================================================
    
    $query = "SELECT * FROM airplanes WHERE id='$id'";
    if (!mysql_query($query)){
    die('Error :' .mysql_error());
    }
    $result = mysql_query ($query);
    $num = mysql_num_rows($result);
    
    // Check to see if record exists =======================================
    
    if (mysql_num_rows($result) == 1)
        {
        "UPDATE airplanes SET model_name='$model_name', model_mfg='$model_mfg', wingspan='$wingspan', engine='$engine', decibels='$decibels' WHERE id='$id'";
            print 'Database successfully updated';
        } 
        
    // Record not in db  ===============================================
        if (mysql_num_rows($result) == 0)
        {
        print '<big style="color: red;"><span style="font-weight: bold;">
        ERROR MESSAGE:</span></big> ID number not found'; 
        echo "<br />";
        echo "<br />";
        print 'Use the BACK button on your browser to try again'; 
        echo "<br />";
        } 
        
    echo "<br />"; 
    echo '<p>Return to <a
    href="members_menu.html">Members Menu Here</a></p>';
    
    ?>
    

  7. ID is the auto-incremented key. However, it still doesn't update the db. What kills me is my programs to add or delete records in the db work fine but I can't figure this one out.

     

    <?php // change airplane in database
    
    // Connect to database =====================================================
    
    include("connect_db.php");
    
    // retrieve form data from form2.html  ==========================================
    
    $id = $_POST['id']; // do not change
    $id = $_POST['ama']; // do not change
    $id = $_POST['model_name'];
    $id = $_POST['model_mfg'];
    $id = $_POST['wingspan'];
    $id = $_POST['engine'];
    $id = $_POST['decibels'];
    
    // Send query ===========================================================
    
    mysql_query("DELETE FROM airplanes WHERE id=$id");
    
    echo '<p>Return to <a
    href="members_menu.html">Members Menu Here</a></p>';
    ?>
    

     

    I'm thinking maybe I shouldn't have volunteered for this job.

     

     

  8. Tried that. Tried everything I know.

     

    The $query line just happens to be the last thing I tried. Can't see where it would do any good to post the many different lines I have tried because none of them worked.

     

    These doesn't work either.

     

    "UPDATE airplanes SET model_name = '$model_name' WHERE id = '$id'";
    UPDATE airplanes SET model_name = '$model_name' WHERE id = '$id';
    

     

    Was just reading Reed's page. Sure is a clean design.

  9. This executes with no errors but it is not updating the db. I have previously verified that the record exists.

     

    <?php // update  database
    
    // Connect to database =====================================================
    
    include("connect_db.php");
    
    // retrieve form data from form2.html  ==========================================
    
    $id = $_POST['id']; // do not change
    $id = $_POST['ama']; // do not change
    $id = $_POST['model_name'];
    $id = $_POST['model_mfg'];
    $id = $_POST['wingspan'];
    $id = $_POST['engine'];
    $id = $_POST['decibels'];
    
    // Send query ===========================================================
    
    $query = "UPDATE airplanes SET model_name = '$model_name' WHERE id = '$id'";
    
    //if (!mysql_query($query)){
    //die('Error :' .mysql_error());
    //}
       
    echo '<p>Return to <a
    href="members_menu.html">Members Menu</a></p>';
    
    ?>
    

     

    Thanks

  10. Not sure this still holds truth but search engines have trouble properly indexing your website with frames. The problem with frames is that search engines index your navigation and content as different pages which means people can end up on your main content with no navigation or on a page with only navigation.

    That's what I like..."pacifics." That surely is a bad thing. I will look into changing it. Only another 40 hours of work for me...lol

     

    Many thanks

  11. In previous posts you have said that my web site security is no security at all and recommemded standard(?) php programs which utilize the hosts .htaccess folder. I have looked at them and being a beginner at mySQL and php, they are really complicated.

     

    A technical rep at my host says I can do the exact same thing by going into cPanel/Security/Password Protect Directories and setting up a password for the directory. He says then the user will be prompted for the password when they try to access the site. And I do not have to write one single line of code.

     

    It it is too good to be true it probably is.

    If I folllow his advice what kind of security do I have?

     

    Thanks

     

     

  12. Hey guys, I am dated!

     

    How many programs have I written on punched cards? A ton.

     

    I don't have photoshop, just wordpad and komodo.

     

    You dont like the marquee. Neither do I. Never have. Gonna remove it.

     

    Other than that, what don't you like? What is wrong with frames?

     

    Work up a new design using html and css and start to port your site over to that.

     

    Not trying to be cute but it is written in html and a little css.

     

    What is it that is dated and why is that a bad thing?

  13. Works perfect. Thanks.

     

    But why am I not able to echo the variable $amamo by itself?

     

    <?php>
    session_start(); 
    
    $id = $_POST['amano'];
    $_SESSION['amano'] = $_POST['amano'];     
    //$_SESSION['amano'] = (int)$_POST['amano']; // Do this if number              
    echo "Pageviews = ". $_SESSION['amano'];  //Works
    echo "<br />";
    echo "AMA # = ". $_POST['amano']; // Works
    echo "<br />";
    echo "AMANO:" .$amano; // This won't work and I have tried single and double 
    //quotes, period, no period...everything I can think of to output #amano by itself
    echo "<br />";
    echo "Sessions AMA # = ".$_SESSION['amano']; // Works
    ?>
    

  14. I am trying to define a session variable where I can save it and use it as the user surfs the site.

     

    I need the variable saved as $amano so I can use it in my select from/where statement and to echo within a table.

     

    This is a test trying to capture and define the variable and works, but I can't get the variable $amano into the session. If I am then I don't know how to display it.

     

    <?php>
    session_start(); 
    $id = $_POST['amano'];
    $_SESSION['amano'] = '$amano';     
                 
    echo "Pageviews = ". $_SESSION['amano'];  // My effort to see what is happening.
    echo "<br />";
    echo "AMA # = ". $_POST['amano']; // I have it just like I want it here.
    echo "<br />";
    echo "Sessions AMA # = ".$_SESSION['amano']; 
    ?>
    

     

     

     

  15. You *never* retain a password - that is a huge security flaw.

     

    I don't understand this. I am capturing the user input (maybe password is the wrong nomenclature) from the form in the php program using Post. Then I link to my file: (and select only one record).

     

    ID    Number........ect.

    1      804333

    2      398434

    3      804333

    4      354778

     

    If the search=0, then either the password is invalid or that user does not have any records in the file. It prints an error message.

     

    If the search=1, it will print a link to the menu program.

     

    In either case, neither the form or the php program returns the "password" to the browser. So what is it I don't know?

     

    Secondly:

     

    If the search=1, then the user will link to the next program (html) which will present 4 options.

     

          display

          add

          change

          delete

     

    When he selects the option it will link to a php program. And here is where I need the number he entered in the form when he started.

     

     

  16. I was in the furniture mfg business for many years and will give you a couple of examples of what I was talking about.

     

    partno file - a unique part number for every product

     

    If you offer more than one color for a part number you cannot put colors in that file. You must cross reference and link from the partno file to a colorno file. Same for any other attribute that offers options.

     

    Price. If you offer different prices to different customers then you must design your database to reflect that option. Discounts?

     

    It can get pretty complicated and must be thought out.

     

     

  17. You do not create a database with phpMyAdmin.

     

    Most every host that allows databases use the cPanel software, which allows you to set up email, files, logs, security, domains, security, databases and a couple of others.

     

    Database setup and maintenance is done with MySQL. Table setup and maintenance is done with phpMyAdmin, tho to set up a site you will have to learn php.

     

    Before you do anything, I would strongly suggest you study and have a good understanding of a relational database. Then design on paper every field that you want to use and how it relates to another field/s. Now do a flowchart of the programs you will need to access/add/change/delete/display the data. Otherwise you will waste many, many hours and end up with a mess which you will have to redo.

     

     

  18. How do I retain a password as a user navigates from page to page without having to ask him for it again. I do not need it to protect the page, I need it to execute whatever selection he makes.

     

    enter_psw.html  // this is a form
    verify_psw.php  // I have the password here
    menu1.html  // I don't have the password here and need it
                   display_records
                   add_record.php
                   change_record.php
                   delete_record_php
    

  19. That would work if I knew which number in the column (there are 45) the user wanted to link to. There are html pages for each of the 45 numbers.

     

    What I would like to be able to do is place the mouse pointer over a number in the table, click on the number, have it create the link, and then execute the link, not just display it.

     

    If this is not possible, how do I detect what number he wants to select with the mouse pointer and thereby echo the URL number.html.

     

    I could just output the link in the table but I don't want to do that. It would confuse the user.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.