NameSilo

Need help with Php code

Spaceship Spaceship
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
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
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
•••
there is no $_POST['diagnosis'] cuz u named it "textfield" in the html form.

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

Code:
        if(mysql_query($result, $connec) {
 
0
•••
Unstoppable Domains
Domain Recover
NameMaxi - Your Domain Has Buyers
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back