NameSilo

Need help with Php code

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
Watch

wackyjoe

Established Member
Impact
3
hey im working on a site for a doctor...its a basic site where he can add his patients info and then view it...but for some reason my form wont work here it is:
PHP:
<table width="500" border="0" cellspacing="2" cellpadding="0">
<form action="confirm.php" method="POST">
    <tr>
      <th style="background-color: #009900;" width="114" scope="col">Field</th>
      <th style="background-color: #666666;" width="386" scope="col">Input</th>
    </tr>
    <tr>
      <td class="style">Date</td>
      <td class="style1"><? $date = date("Y-m-j"); echo"$date"; ?></td>
    </tr>
    <tr>
      <td class="style">Number</td>
      <td class="style1"><input type="text" name="number"></td>
    </tr>
    <tr>
      <td class="style">Balance</td>
      <td class="style1"><input type="text" name="balance"></td>
    </tr>
    <tr>
      <td class="style">Name</td>
      <td class="style1"><input type="text" name="name"></td>
    </tr>
    <tr>
      <td class="style">Date of Birth </td>
      <td class="style1"><input type="text" name="dob"></td>
    </tr>
    <tr>
      <td class="style">Address</td>
      <td class="style1"><input type="text" name="address"></td>
    </tr>
    <tr>
      <td class="style">Diagnosis</td>
      <td class="style1"><input type="text" name="textfield"></td>
    </tr>
    <tr>
      <td class="style">Site of Injection </td>
      <td class="style1"><input type="text" name="sij"></td>
    </tr>
    <tr>
      <td class="style"> </td>
      <td class="style1"><input type="button" name="submit" value="Submit">         </td>
    </tr>
</form>
  </table>

and here is confirm.php
PHP:
 <?
if($_POST['submit']) {
   $connect = mysql_connect("localhost","******","***")or die(mysql_error());
   mysql_select_db("****")or die(mysql_error());

	$date = date("Y-m-j");
   $number = $_POST['number'];
	$balance = $_POST['balance'];
   $name = $_POST['name'];
   $dob = $_POST['dob'];
   $address = $_POST['address'];
   $diagnosis = $_POST['diagnosis'];
   $sij = $_POST['sij'];
  
   $result="INSERT INTO morphine (date,number,balance,name,dob,address,diagnosis,sij)".
      "VALUES ( '$date', '$number', '$balance', '$name',  '$dob', '$address', $diagnosis', '$sij')") or die(mysql_error("Could not Send Items"));
	$rows=mysql_num_rows($result);	
		if(mysql_query($result, $connec) {
   
   echo "Data Entered into the Database";
}
else
{
echo"sorry, your data was not stored";
}
?>
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Shouldn't you nest your code like this, by keeping the <form> tags outside your <table> ?
Code:
<form action="confirm.php" method="POST"> 
<table width="500" border="0" cellspacing="2" cellpadding="0"> 
...
</table>
</form>
 
0
Close
there is no $_POST['diagnosis'] cuz u named it "textfield" in the html form.

try changing that and tell if it works.
 
0
Close
typo?

Code:
        if(mysql_query($result, $connec) {
 
0
Close
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back