Jump to content

Insert data


fehrenbacher33

Recommended Posts

Help please cant get it to insert into database

 

<?php

 

$Name = $_POST ['Name'];

$Dwag_Tag  = $_POST ['Dawg'];

$Dept= $_POST ['Dept'];

$Phone = $_POST ['Phone'];

$Buliding = $_POST ['buliding'];

$Request = date('Y-m-d',strtotime($_POST ['Request']));                             

$Pickup = date('Y-m-d',strtotime($_POST ['Pickup']));                                                                     

$Comments = $_POST ['Comments'];

 

if(!isset($_POST['Equipment']))

$Equip_Number = null;

else

$Equip_Number = $_POST['Equipment'];

 

 

if(!isset($_POST['Status']))

$SIU_STATUS = 'off';

else

$SIU_STATUS = $_POST['Status'];

 

 

$server = "localhost";

$user = "root" ; 

$pwd = "" ; 

 

$connect = mysql_connect($server, $user, $pwd)

or die ("Error: Connection lost!");

 

$sel = mysql_select_db ("siu");

 

if (!$sel)

      exit ("Error: Could no t select database!");

 

     

$sql = "INSERT INTO Equipment_Receipt(Request, Pickup, Name, buliding,  Status, Dept,  Dawg, Phone, Comments, Equipment)";

$sql.= "VALUES (\"$Request\",\"$Pickup\",\"$Name\",\"$Buliding\",\"$SIU_STATUS\", \"$Dept\", \"$Dwag_Tag\", \"$Phone\",\"$Comments\",$Equip_Number)";

 

 

 

$query = mysql_query($sql);

$numRows = mysql_affected_rows($connect);

 

if($numRows ==1)

  {

    echo "<h3> Order has been  successfully orderd </h3>";

 

}

 

 

mysql_close($connect);

 

?>

 

 

 

___________________________________________________________________________________________

 

 

 

 

<?php

 

$server = "localhost";

$user = "root" ; 

$pwd = "" ; 

$connect = mysql_connect($server, $user, $pwd)

or die ("Error: Connection lost!");

$sel = mysql_select_db ("SIU");

 

if(!$sel)

exit("Error: Could not select database!");

 

 

echo"

 

 

 

<form action = insertdo.php    method = post >

 

<table width='629' border= '1' align='center' cellpadding='3' cellspacing='3' >

 

<tr>

 

<td>Name: </td>

<td><input type='text' name = 'Name'  size='40' maxlength='40'/></td>

 

    </tr>

 

<tr>

 

<td>SIU ID #:</td>

<td><input  type ='text'  name = 'Dawg'    size = '15' maxlength= '15' /></td>

 

  </tr>

 

    <tr>

 

<td>SIU Status:</td>

 

<td>

Student <input type  ='radio'  name = 'Status'  VaLue = 'Student'  />

Staff<Input type = 'radio'    name = 'Status'    Value = 'Staff'/>

Professor<Input type = 'radio'  name = 'Status'    Value = 'Professor' /> 

</td>

 

</tr>

 

<tr>

<td>Phone:

<p>(xxx-xx-xxxx)</p></td>

 

<td><input type = 'text' name = 'Phone'    size = '14'  maxlength= '14' />    </td>

</tr>

 

 

<tr>

<td>Buliding:</td>

 

<td><input type = 'text' name = 'buliding'  size = '40'  maxlength= '40' />    </td>

</tr>

 

<tr>

<td>Department: </td>

<td><input  type = 'text' name = 'Dept'  size='38' maxlength='38'  size = '30' /></td>

</tr>

 

 

<tr>

<td> Shipment

<p>Enter the date </P>

</td>

 

<td><input type='text' name='Request' />    </td>

</tr>

 

 

<tr>

<td> Return Date: </td>

<td><input type='text' name='Pickup' />    </td>

</tr>

 

<tr>

<td> Equipment: </td>";

 

$sql = "SELECT * FROM  Equipment";

$query  = mysql_query($sql);

if (mysql_num_rows($query) == 0)

{

echo "No records found";

}

else

echo  "<td><select name='Equipment' size = '1'>";

while($row = mysql_fetch_object($query))

{

echo "<option Value = $row->Equip_Number>$row->Equipment_Category</option>";

}

echo "</select></td></tr>";

 

 

echo"

 

 

      <tr>

  <td> Comments: </td>

  <td><textarea name='Comments' cols= '25'rows='5' ></textarea>    </td>

    </tr>

 

<tr>

<td colspan='2'><input type ='reset'  name = 'Reset'  />

<input type = 'submit'  name = 'Submit' value='Submit'/>    </td>

</tr>

 

</table>

</form>

";

 

mysql_close($connect);

 

?>

Link to comment
https://forums.phpfreaks.com/topic/184855-insert-data/
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.