Jump to content

how to submit


ckdoublenecks

Recommended Posts

how do I code the submit into this form?

 

echo "<form action='#' method='post'><b>Prerent Update :<br /><br />
         <table border='1'>
          <tr>
          <th>dep</th>
          <th>tenant</th>
                    </tr>";
  while($row = mysql_fetch_assoc($result))
  {
   echo "<tr>
          <td><input type='text' name='dep' value='" . $row['dep'] . "'></td>
          <td><input type='text' name='name' value='" . $row['name'] . "'></td>
            
          </tr>";
   }
  echo "</table>
// ***
<input type="submit" name="submit" value="update record"/>
// ***
echo</form>";
  }
else{echo "No listing for appartment $apt.<br />Please select another.<br />";}
}
if(!empty($_POST["update"]))
{
$sql = "UPDATE testtable SET dep, name, amtpaid, prevbal, misc, tentpay, hudpay, datepaid  WHERE apt='apt'";
mysql_query($sql) or die("Update query failed.");
echo "Record for appartment ".$_POST["apt"]." has been updated ...";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/211023-how-to-submit/
Share on other sites

Change the double quotes to single quotes in this block of lines. From:

<?php
echo "</table>
// ***
<input type="submit" name="submit" value="update record"/>
// ***
echo</form>";
?>

To:

<?php
echo "</table>
// ***
<input type='submit' name='submit' value='Update Record' />
// ***
echo</form>";
?>

 

Ken

Link to comment
https://forums.phpfreaks.com/topic/211023-how-to-submit/#findComment-1100589
Share on other sites

I've been chastised for showing too much code but obviously I need to show it now.  I'm selecting a record to update then changing the fields.  Now it doesn't like the form I'm using at the bottom.  It works in another program? Below is the error message:

 

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\hofiles\prerentupdate.php on line 58

 

<?php
mysql_connect(localhost,root,"");
mysql_select_db(test) or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$apt = $_POST['apt'];
$query="SELECT * FROM testtable Where apt='$apt'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
  echo "<form action='#' method='post'><b>Prerent Update :<br /><br />
         <table border='1'>
          <tr>
          <th>dep</th>
          <th>tenant</th>
          <th>apt</th>
          <th>amt paid</th>
          <th>rent due</th>
          <th>prevbal</th>
          <th>misc</th>
          <th>tentpay</th>
          <th>hudpay</th>
          <th>date paid</th>
          </tr>";
  while($row = mysql_fetch_assoc($result))
  {
   echo "<tr>
          <td><input type='text' name='dep' value='" . $row['dep'] . "'></td>
          <td><input type='text' name='name' value='" . $row['name'] . "'></td>
          <td><input type='text' name='apt' value='" . $row['apt'] . "' readonly style='border:none;' onmouseup='this.blur()'></td>
          <td><input type='text' name='amtpaid' value='" . $row['amtpaid'] . "'></td>
          <td><input type='text' name='rentdue' value='" . $row['rentdue'] . "' readonly style='border:none;' onmouseup='this.blur()'>></td>
          <td><input type='text' name='prevbal' value='" . $row['prevbal'] . "'></td>
          <td><input type='text' name='misc' value='" . $row['misc'] . "'></td>
         <td><input type='text' name='tentpay' value='" . $row['tentpay'] . "'></td>
          <td><input type='text' name='hudpay' value='" . $row['hudpay'] . "'></td>
          <td><input type='text' name='datepaid' value='" . $row['datepaid'] . "'></td>         
          </tr>";
   }
echo "</table>
<input type='submit' name='submit' value='Update Record' />
echo</form>";?>
  }
else{echo "No listing for appartment $apt.<br />Please select another.<br />";}
}
if(!empty($_POST["update"]))
{
$sql = "UPDATE testtable SET dep, name, amtpaid, prevbal, misc, tentpay, hudpay, datepaid  WHERE apt='apt'";
mysql_query($sql) or die("Update query failed.");
echo "Record for appartment ".$_POST["apt"]." has been updated ...";
}
?>
<form method="post" action="#">
<br />
<input type="text" name="apt"/> <p>
<input type="submit" name="submit" value="select apartment"/>
</form>

Link to comment
https://forums.phpfreaks.com/topic/211023-how-to-submit/#findComment-1100784
Share on other sites

You're not updating anything within your SQL query

 $sql = "UPDATE testtable SET dep, name, amtpaid, prevbal, misc, tentpay, hudpay, datepaid  WHERE apt='apt'";
mysql_query($sql) or die("Update query failed.");
echo "Record for appartment ".$_POST["apt"]." has been updated ...";

You're listing the fields to update but not providing anyvalues. An update query is formatted like so

UPDATE table SET some_field='new value', another_field='some other value' WHERE whatever='something'

Link to comment
https://forums.phpfreaks.com/topic/211023-how-to-submit/#findComment-1100843
Share on other sites

I'm guessing the new value is in $_POST['amtpaid'] variable. Your query will be like this

$sql = "UPDATE testtable SET amtpaid = '" . mysql_real_escape_sting($_POST['amptpaid']) . "' WHERE apt='" . mysql_real_escape_string($_POST['apt'] . "'";
mysql_query($sql) or die("Update query failed.");
echo "Record for appartment ".$_POST["apt"]." has been updated ...";

Link to comment
https://forums.phpfreaks.com/topic/211023-how-to-submit/#findComment-1100858
Share on other sites

I got this message:

 

Parse error: syntax error, unexpected ';' in C:\xampp\htdocs\hofiles\prerentupdate.php on line 50

 

<?php
mysql_connect(localhost,root,"");
mysql_select_db(test) or die( "Unable to select database");
if(!empty($_POST["submit"]))
{
$apt = $_POST['apt'];
$query="SELECT * FROM testtable Where apt='$apt'";
$result=mysql_query($query);
if(mysql_num_rows($result))
{
  echo "<form action='#' method='post'><b>Prerent Update :<br /><br />
         <table border='1'>
          <tr>
          <th>dep</th>
          <th>tenant</th>
          <th>apt</th>
          <th>amt paid</th>
          <th>rent due</th>
          <th>prevbal</th>
          <th>misc</th>
          <th>tentpay</th>
          <th>hudpay</th>
          <th>date paid</th>
          </tr>";
  while($row = mysql_fetch_assoc($result))
  {
   echo "<tr>
          <td><input type='text' name='dep' value='" . $row['dep'] . "'></td>
          <td><input type='text' name='name' value='" . $row['name'] . "'></td>
          <td><input type='text' name='apt' value='" . $row['apt'] . "' readonly style='border:none;' 

onmouseup='this.blur()'></td>
          <td><input type='text' name='amtpaid' value='" . $row['amtpaid'] . "'></td>
          <td><input type='text' name='rentdue' value='" . $row['rentdue'] . "' readonly style='border:none;' 

onmouseup='this.blur()'></td>
          <td><input type='text' name='prevbal' value='" . $row['prevbal'] . "'></td>
          <td><input type='text' name='misc' value='" . $row['misc'] . "'></td>
         <td><input type='text' name='tentpay' value='" . $row['tentpay'] . "'></td>
          <td><input type='text' name='hudpay' value='" . $row['hudpay'] . "'></td>
          <td><input type='text' name='datepaid' value='" . $row['datepaid'] . "'></td>         
          </tr>";
   }
echo "</table>
<input type='submit' name='update' value='Update Record' />
echo</form>";
  }

else{echo "No listing for appartment $apt.<br />Please select another.<br />";}
}
if(!empty($_POST["update"]))
{

$sql = "UPDATE testtable SET dep = '" . mysql_real_escape_sting($_POST['dep']) . "', name = '" . 

mysql_real_escape_sting($_POST['name']) . "', amtpaid = '" . mysql_real_escape_sting($_POST['amptpaid']) 

. "', prevbal = '" . mysql_real_escape_sting($_POST['prevbal']) . "', misc = '" . 

mysql_real_escape_sting($_POST['misc']) . "', tentpay = '" . mysql_real_escape_sting($_POST['tentpay']) . 

"', hudpay = '" . mysql_real_escape_sting($_POST['hudpay']) . "', datepaid = '" . 

mysql_real_escape_sting($_POST['datepaid']) . "' WHERE apt='" . mysql_real_escape_string($_POST['apt'] 

. "'";

mysql_query($sql) or die("Update query failed.");
echo "Record for appartment ".$_POST["apt"]." has been updated";
}
?>
<form method="post" action="#">
<br />
<input type="text" name="apt"/> <p>
<input type="submit" name="submit" value="select apartment"/>
</form>

Link to comment
https://forums.phpfreaks.com/topic/211023-how-to-submit/#findComment-1100873
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.