Jump to content

pakenney38

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Posts posted by pakenney38

  1. Well ideally, I would like to just do something like

    $query = "INSERT INTO table (blah1, blah2, blah3, newvar) VALUES ($blah1, $blah2, $blah3, $newvar)";
    mysql_query($query);
    

    But if the form field associated with $newvar was not filled in, I would like it to not submit a value to MySQL. If there is some easy way of doing this without going through the whole

    if ($newvar != '')

    before I run my query, then I would like to know how to do that. I suppose I could just use $_POST['newvar'] in my MySQL query, but in my situation, I can't always do it that way.

  2. I know this is probably some AJAX based thing I want to do, but I want to make a second form element appear on a page based on the action of a first form element. The second element may or may not contain dynamic content.

     

    For example: I click on a radio button and a drop-down list appears filled with names that have been populated from a MySQL table.

    Does anyone have any good documentation or examples they could point me towards on how to do this?

  3. THE GOAL: Open child.php with the link on main.php. Fill out the form on child.php and submit the form variable back to main.php in the window that is already open. Close the window for child.php automatically after it submits the form. Display the contents of the variable on main.php.

     

    THE PROBLEM: This is just a little test that I am putting together to incorporate into a larger project. I have had many years of experience with HTML and a couple with PHP, but I am starting to jump into combining this with Javascript and of course now I am running into browser specific issues. The following code works in IE 7 fully, but does not display the variable back on main.php using Mozilla 2.0. Possibly, the form variable is never even sent to the page (no way to prove or disprove that with my skill level).

     

    [main.php]

    <!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>Untitled Document</title>
    <script type="text/javascript" language="javascript">
    
    self.name = 'main';
    
    </script>
    
    <style type="text/css">
    <!--
    .style1 {font-family: Verdana, Arial, Helvetica, sans-serif}
    -->
    </style>
    </head>
    
    <body>
    <a
    href="child.php"
    target="child"
    onclick="window.open('child.php', 'child'); return false" class="style1">link</a><br /><br />
    <font class="style1">
    <?PHP
    $textfield = $_POST['textfield'];
    echo $textfield
    ?>
    </font>
    </body>
    </html>
    

     

    [child.php]

    <!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>Untitled Document</title>
    <SCRIPT LANGUAGE="JavaScript">
    
    function closeWindow()
    {
    //Firefox
    if (navigator.appName == 'Netscape')
    {
    window.open('', '_self', '');
    window.close();
    }
    else //Internet Explorer
    setTimeout("WB.ExecWB(45,2)",0);
    }
    
    </SCRIPT> 
    <OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2">
    </OBJECT> 
    <style type="text/css">
    <!--
    .style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-weight: bold;
    }
    -->
    </style>
    </head>
    <body>
    <form action="main.php" method="post" name="form1" target="main" id="form1" onsubmit="closeWindow()">
      <label><span class="style1">Enter Variable</span>
      <input type="text" name="textfield" />
      </label>
      <p>
        <label>
        <input type="submit" name="Submit" value="Submit" />
        </label>
      </p>
    </form>
    </body>
    </html>
    

  4. Here's what I want to do:

    1. Send a message using mail()
    2. in the body of the message I want HTML and <pre> text
    3. in the <pre> text I want to output the value of a variable from PHP.

    right now, I try something like

    [code]$message .= '<pre>$var</pre>';[/code]

    and I get "$var" sent to me in an email. How do I get the value of $var instead?
  5. So is there some alternative technology you would suggest, or any direction at all?
    When working on an older upload project, I eventually scrapped it, because I had increased cgi_timeout and the max_execution_time on my Apache server in different increments along with trying some other settings and never got more than 5-6MB uploaded before the browser gave an error.
  6. I am interested in creating an file upload form for people where I work to upload PDF files and the like. Previous attempts have left me frustrated as I can only get about 5-6MB files uploaded in one form submit before there is an error of some sort.

    Has anyone seen any good examples/books on how to create this?

    Another idea I had involved:
    1. The user types in a title for their file
    2. The user uploads the file with the form
    3. PHP processes the title, turns it into a bullet text on the web site and links the text to the uploaded file automatically using a MySQL reference.
  7. Here's a code snippet from something I am working on.
    The problem is that my JavaScript function doesn't seem to run at all when the page is pulled up in the browser.

    [code]echo "<!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>Set up email</title>
    <script type='text/javascript'>
    <!--
    function passcheck(Form1) {
    if (Form1.Password.value.length < 6)
    {alert('The password must contain at least 6 characters.');
    return false;}
    else {
    if (Form1.Password.value.indexOf('XXX') > -1)
    {alert (\"The password you have entered violates\none or more of the following rules:\n
      1. The password must be 6 or more characters long.\n
      2. The password cannot contain XXX.\n
      3. The password cannot contain the word password.\n
      Please choose another password.\");
      return false;}
    else {
    if (Form1.Password.value.indexOf('password') > -1)
    {alert (\"The password you have entered violates\none or more of the following rules:\n
        1. The password must be 6 or more characters long.\n
              2. The password cannot contain XXX.\n
              3. The password cannot contain the word password.\n
              Please choose another password.\");
              return false;}
    else {
    if (Form1.Password.value.indexOf(' ') > -1)
    {alert (\"The password cannot contain any spaces.\n
      Please choose another password.\");
      return false;}
    else {
    return true;}}}}}

    //-->
    </script>
    </head>
    <html>
    <body>
    <p><img src='login-window_logo.gif' width='188' height='60'>";

    if (strlen($sMsg) > 0) {
    echo($sMsg . "<br />");
    }

    if (strlen($sErr) > 0) {
    echo($sErr . "<br />");
    }

        echo "</p>
    <p><strong>Please enter a password to be used for your new account.<br>
    This password must be 6 or more charaters long.<br>
    The password cannot contain 'XXX'.<br>
    The password cannot contain the word 'password'.</strong></p>
    <form method='post' name='Form1' onSubmit='return passcheck(this)' action='{$_SERVER['PHP_SELF']}'>
    Postoffice:
      <input type='text' name='PostOffice' value='XXX' readonly />
      <br />
    Mailbox name: <input type='text' name='MailBox' value='$mailbox' readonly /><br />
    Password: <input type='password' name='Password' value='$Password' /><br />
    <input type='hidden' name='TRANS' value='1' />
    <input type='submit' value='Add Mailbox' />
    </form>
    </body>
    </html>";[/code]
  8. Still working on my form....

    This time, I'm having trouble adding rows to the form because for some reason, I can't get the value of $addrow. I normally wouldn't post complete code, but this is good stuff:

    [code]<?PHP

    if (isset($addrow))
    {
    $addrow = $_POST['addrow'];
    $rowcount = $_POST['rowcount'];

    $name = $_POST['name'];
    $empno = $_POST['empno'];
    $base = $_POST['base'];
    $seat = $_POST['seat'];
    $equip = $_POST['equip'];
    $explain = $_POST['explain'];
    for ($x = 1; $x <= $rowcount; $x++)
    {
    $date[$x] = $_POST['date' . $x];
    $fltno[$x] = $_POST['fltno' . $x];
    $actblk[$x] = $_POST['actblk' . $x];
    $schblk[$x] = $_POST['schblk' . $x];
    $dhcr[$x] = $_POST['dhcr' . $x];
    $paycr[$x] = $_POST['paycr' . $x];
    $nontax[$x] = $_POST['nontax' . $x];
    $tax[$x] = $_POST['tax' . $x];
    $comments[$x] = $_POST['comments' . $x];
    }
    }
    else
    {
    $rowcount = 5;
    }

    echo "
    <!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>Untitled Document</title>
    <style type='text/css'>
    <!--
    .style5 {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: small; }
    .style8 {font-weight: bold; font-family: Verdana, Arial, Helvetica, sans-serif;}
    .style9 {font-family: Verdana, Arial, Helvetica, sans-serif}
    -->
    </style>
    </head>

    <body>
    ";

    echo "$rowcount<br><br>";
    echo "$addrow<br><br>";

    echo
    "
    <p class='style8'>Online Crew Pay Sheet</p>
    <p class='style5'>Please complete all appropriate fields. To add more flights, click Add Rows. To Submit the Pay Sheet, click Finished.<br />
      Please verify that the information that you enter is correct before you click Finished.<br />
      You will <em>not</em> have another opportunity to edit this information after it is submitted.</p>
      <form id='form1' name='form1' method='post' action='{$_SERVER['PHP_SELF']}'>
    <table width='447' border='1'>
      <tr>
        <td width='46'><div align='right'><span class='style5'>NAME</span></div></td>
        <td width='157'><span class='style5'>
          <label>
          <input name='name' type='text' id='name' />
          </label>
        </span></td>
        <td width='82'><div align='right'><span class='style5'>EMPLOYEE<br />
        NUMBER </span></div></td>
        <td width='144'><span class='style5'>
          <label>
          <input name='empno' type='text' id='empno' />
          </label>
        </span></td>
      </tr>
    </table>
    <br />
    <table width='383' border='1'>
      <tr>
        <td width='34'><div align='right'><span class='style5'>BASE</span></div></td>
        <td width='69'><span class='style5'>
          <label>
          <input name='base' type='text' id='base' size='3' />
          </label>
        </span></td>
        <td width='35'><div align='right'><span class='style5'>SEAT</span></div></td>
        <td width='63'><span class='style5'>
          <label>
          <select name='seat' id='seat'>
            <option value='--' selected='selected'>--</option>
            <option value='CA'>CA</option>
            <option value='FO'>FO</option>
            <option value='FA'>FA</option>
          </select>
          </label>
        </span></td>
        <td width='40'><div align='right'><span class='style5'>EQUIP</span></div></td>
        <td width='102'><span class='style5'>
          <label>
          <select name='equip' id='equip'>
            <option value='XXXXXX' selected='selected'>XXXXXX</option>
          </select>
          </label>
        </span></td>
      </tr>
    </table>
    <br />
    <span class='style5'>The date, flight number and pay credit of each row must be filled in, otherwise the row will be ignored.</span> <br />
    <table width='970' border='1'>
      <tr>
        <td width='75'><div align='center'><span class='style5'>DATE</span></div></td>
        <td width='67'><div align='center'><span class='style5'>FLIGHT<br />
        NUMBER</span></div></td>
        <td width='65'><div align='center'><span class='style5'>ACTUAL<br />
        BLOCK</span></div></td>
        <td width='96'><div align='center'><span class='style5'>SCHEDULED<br />
        BLOCK</span></div></td>
        <td width='60'><div align='center'><span class='style5'>DH<br />
        CREDIT</span></div></td>
        <td width='60'><div align='center'><span class='style5'>PAY<br />
        CREDIT</span></div></td>
        <td width='84'><div align='center'><span class='style5'>NON TAX<br />
          PER DIEM
        </span></div></td>
        <td width='84'><div align='center'><span class='style5'>TAXABLE<br />
        PER DIEM </span></div></td>
        <td width='321'><div align='center'><span class='style5'>COMMENTS</span></div></td>
      </tr>
    ";

    if (isset($addrow))
    {
    $rowcount = $rowcount + 5;
    echo "<input name='rowcount' type='hidden' value='$rowcount'>";
    }
    else
    {
    echo "<input name='rowcount' type='hidden' value='$rowcount'>";
    }

    for ($x = 1; $x <= $rowcount; $x++)
    {
    echo
    "
      <tr>
        <td><label>
          <div align='center'>
            <input name='date$x' type='text' id='date$x' size='10' />
          </div>
        </label></td>
        <td><div align='center'>
          <label>
          <input name='fltno$x' type='text' id='fltno$x' size='5' />
          </label>
        </div></td>
        <td><div align='center'>
          <input name='actblk$x' type='text' id='actblk$x' size='5' />
        </div></td>
        <td><div align='center'>
          <input name='schblk$x' type='text' id='schblk$x' size='5' />
        </div></td>
        <td><div align='center'>
          <input name='dhcr$x' type='text' id='dhcr$x' size='8' />
        </div></td>
        <td><div align='center'>
          <input name='paycr$x' type='text' id='paycr$x' size='8' />
        </div></td>
        <td><div align='center'>
          <input name='nontax$x' type='text' id='nontax$x' size='8' />
        </div></td>
        <td><div align='center'>
          <input name='tax$x' type='text' id='tax$x' size='8' />
        </div></td>
        <td><div align='center'>
          <label>
          <input name='comments$x' type='text' id='comments$x' size='52' />
          </label>
        </div></td>
      </tr> 
    ";
    }
     
    echo "
    </table>
    <p>
      <label>
      <input type='submit' name='addrow' value='Add Rows' />
      </label>
    </p>
    <p class='style5'>Please use this space to explain pay irregularities or make additional
        <label>
      comments:
      <textarea name='textarea' cols='100' rows='5'></textarea>
        </label>
    </p>
    <p><span class='style5'>I certify the above to be true and correct and with complete information to the best of my knowledge (please enter initials):</span>
      <label>
      <input name='textfield' type='text' size='5' />
      </label>
    </p>
    <p>
      <label>
      <input type='submit' name='Submit' value='Finished' />
      </label>
    </p>
    </form>
    </body>
    </html>
    ";
    ?>[/code]

    When I run my script, one of my only errors is:
    [code]Notice: Undefined variable: addrow in E:\local_sites\newpaysheet\index.php on line 51[/code]

    Can I not use 2 submit buttons? How do I dance around this?
  9. Does anyone know how to echo HTML table rows based on a loop?
    For example, I have this code that doesn't work. Assume that $addrow is set via a submit button.
    With this said, rowcount should be equal to 5 on the intial page load. After the script runs, it should be equal to 10.

    [code]if (isset($addrow))
    {for ($x = ($rowcount + 1); $x <= ($rowcount + 5); $x++)
    {echo
    "
    <tr>
        <td><label>
          <div align='center'>
            <input name='date$x' type='text' id='date$x' size='10' />
          </div>
        </label></td>
        <td><div align='center'>
          <label>
          <input name='fltno$x' type='text' id='fltno$x' size='5' />
          </label>
        </div></td>
        <td><div align='center'>
          <input name='actblk$x' type='text' id='actblk$x' size='5' />
        </div></td>
        <td><div align='center'>
          <input name='schblk$x' type='text' id='schblk$x' size='5' />
        </div></td>
        <td><div align='center'>
          <input name='dhcr$x' type='text' id='dhcr$x' size='8' />
        </div></td>
        <td><div align='center'>
          <input name='paycr$x' type='text' id='paycr$x' size='8' />
        </div></td>
        <td><div align='center'>
          <input name='nontax$x' type='text' id='nontax$x' size='8' />
        </div></td>
        <td><div align='center'>
          <input name='tax$x' type='text' id='tax$x' size='8' />
        </div></td>
        <td><div align='center'>
          <label>
          <input name='comments$x' type='text' id='comments$x' size='52' />
          </label>
        </div></td>
      </tr>
    ";
    }
    $rowcount = $x;
    echo "<input name='rowcount' type='hidden' id='rowcount' />";}
    else
    {
    $rowcount = 5;
    echo "<input name='rowcount' type='hidden' id='rowcount' />";
    }[/code]
×
×
  • 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.