Jump to content

Calling a form item from another form


Darkmatter5

Recommended Posts

If I have this item

<form method="post">
<table border="0">
  <tr>
    <td>First name:</td>
    <td><div align='center'><input name="FirstName" type='text' id="FirstName" /></div></td>
  </tr>
</table>
</form>

 

in my page and then I have another form which consists of the following code.

<form method="post">
<table width="770" border="0">
  <tr>
    <td><div align='center'><input name='editclient' type='submit' id='editclient' value='Store new client data' /></div></td>
    <td width="140"><div align="right">Function Status =></div></td>
    <td width="344"><div class="style2">
	<?php
        	         if(isset($_POST['editclient'])) {
                  include 'library/dbconfig.php';
                  include 'library/opendb.php';
                  $fields=array("ClientID","FirstName","LastName","CompanyName","ContactTitle","Address","City","State","ZipCode","HomePhone","WorkPhone","WorkPhoneExtension","FaxPhone","Email");
         for($i=0; $i<=13; $i++) {
	if(isset($_POST['$fields[$i]'])) mysql_query("UPDATE INTO byrnjobdb.clients SET $fields[$i]=$_POST['$fields[$i]']
                                                                WHERE $fields[0]=$_POST['$fields[0]']");
	if(empty($_POST['$fields[3]'])) echo $_POST['$fields[2]']. ", " . $_POST['$fields[1]']. " updated!";
	else echo $_POST['$fields[2]']. ", " .$_POST['$fields[1]']. " of " .$_POST['$fields[3]']. " updated!";
	include 'library/closedb.php';
	}
	?>
    </div></td>
  </tr>
</table>
</form>

 

How do I call the FirstName item in the first table from the "Store new client data" button you click?  Right now as it is, it always gives me the output of " , updated!" regardless if I leave FirstName blank or enter something in there.

 

Help please!

Link to comment
https://forums.phpfreaks.com/topic/106829-calling-a-form-item-from-another-form/
Share on other sites

I don't understand the question.  Are these two forms on the same page?  Neither form has an action (the page it sends the data to) -- what page does the processing of the forms?  It appears the form page itself does.

 

Why do you have two separate forms?  Why not just make them both one form?

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.