-
Just a blank screen
I am wanting to make a database app. Very simple. I just need to be able to enter information into a database, delete it and show it.
I've gotten the show part.
I am working on the insert part and I am stuck. I have a very simple HTML form with about 9 fields.
I am using a MS Access database and PHP.
This is my processing file:
PHP Code:
<?php
$requester=$_Post['Requester']
$owner=$_Post['Owner']
$makemodel=$_Post['MakeModel']
$serialno=$_Post['SerialNo']
$received=$_Post['Received']
$shipped=$_Post['Shipped']
$ticketno=$_Post['TicketNo']
$notes=$_Post['Notes']
if ( !( $database = odbc_connect( "Warranty", "","")))
die( "Could not connect to database" );
$stmt = odbc_prepare($database, "INSERT INTO WarrantyInformation (Requester, Owner, MakeModel, SerialNo, Received, Shipped, TicketNo, Notes) VALUES('$requester','$owner', '$makemodel', '$serialno', '$received', '$shipped', '$ticketno', '$notes');" );
if (!odbc_execute( $stmt))
{
echo "Whoops";
}
When I go to the form page and fill it in and click SUBMIT, I get a blank page and the DB is not updated. If I turn on the Friendly Warning in IE it just gets me a 500 Internal Server error.
I am using Xitami as the webserver and it processes other PHP stuff just fine. What am I doing wrong?
Thanks,
JRF2k
-
You need to put a ';' at the end of your variables that are set to the posted data.
sooo like this,
Code:
$requester=$_Post['Requester'];
$owner=$_Post['Owner'];
$makemodel=$_Post['MakeModel'];
$serialno=$_Post['SerialNo'];
$received=$_Post['Received'];
$shipped=$_Post['Shipped'];
$ticketno=$_Post['TicketNo'];
$notes=$_Post['Notes'];
Also i duno if its just you havent included it, but the closing ?> php tag. Duno just a suggestion
-
Entry is blank spaces
When I run the code below, I get the next autonumber in the DB, but there is no data in there. I've rechecked all my variables and I can't see anything wrong. It just writes blanks and then autonumbers. What am I missing?
Here is my HTML Form:
Code:
<html>
<head><title></title></head>
<body>
<FORM action="insertintodb.php" method="post">
Requester: <input type="text" name="requester"></br>
Owner:<input type="text" name="owner"></br>
Make/Model:<input type="text" name="makemodel"></br>
Serial Number:<input type="text" name="serialno"></br>
Received:<input type="text" name="received"></br>
Shipped:<input type="text" name="shipped"></br>
Ticket Number:<input type="text" name="ticketno"></br>
Notes/Commnets:<input type="text" name="notes"></br>
<input type="Submit" name="Enter"><input type="reset"></br>
</FORM>
</body>
</html>
and here is the PHP:
PHP Code:
<?php
$requester=$_Post['requester'];
$owner=$_Post['owner'];
$makemodel=$_Post['makemodel'];
$serialno=$_Post['serialno'];
$received=$_Post['received'];
$shipped=$_Post['shipped'];
$ticketno=$_Post['ticketno'];
$notes=$_Post['notes'];
if ( !( $database = odbc_connect( "Warranty", "","")))
die( "Could not connect to database" );
$stmt = odbc_prepare($database, "INSERT INTO WarrantyInformation (Requester, Owner, MakeModel, SerialNo, Received, Shipped, TicketNo, Notes) VALUES('$requester','$owner', '$makemodel', '$serialno', '$received', '$shipped', '$ticketno', '$notes');" );
if (!odbc_execute( $stmt))
{
echo "Whoops";
}
?>
-
Thanks! That was it.
I SHOULD have seen that! :mad:
That got it working, somewhat anyway. I have a new post about now the Access DB will autonumber but no data is inserted. If you can help, please do. I can't see anything wrong with the code.
-
Code:
<FORM action="insertintodb.php" method="post">
Requester: <input type="text" name="requester" value=""></br>
Owner:<input type="text" name="owner" value=""></></br>
Make/Model:<input type="text" name="makemodel" value=""></></br>
Serial Number:<input type="text" name="serialno" value=""></></br>
Received:<input type="text" name="received" value=""></></br>
Shipped:<input type="text" name="shipped" value=""></></br>
Ticket Number:<input type="text" name="ticketno" value=""></></br>
Notes/Commnets:<input type="text" name="notes" value=""></></br>
<input type="Submit" name="Enter"><input type="reset"></br>
</FORM>
insert value into your form
change
to
-
Anytime :D i made a simple mistake of leaving out an equals in html and when you send that through it doesnt work....we all do it.
Think boogyman got there before i did. He seems to have it cracked, thats what i would have suggested.
-
Thank you! That got it working wonderfully.
If you don't mind me asking another basic question.
How would I add links on my output page that would allow deleting of records?
Here is that page:
PHP Code:
<html>
<body><?php
$conn=odbc_connect('Warranty','','');
if (!$conn)
{exit("Connection Failed: " . $conn);}
$sql="SELECT * FROM WarrantyInformation";
$rs=odbc_exec($conn,$sql);
if (!$rs)
{exit("Error in SQL");}
echo "<table border=1>";
echo "<tr><th>Requester</th>";
echo "<th>Owner</th>";
echo "<th>Make/Model</th>";
echo "<th>Serial Number</th>";
echo "<th>Recieved</th>";
echo "<th>Shipped</th>";
echo "<th>Ticket Number</th>";
echo "<th>Notes/Comments</th></tr>";
while (odbc_fetch_row($rs))
{
$requester=odbc_result($rs,"Requester");
$owner=odbc_result($rs,"Owner");
$makemodel=odbc_result($rs,"MakeModel");
$serialno=odbc_result($rs,"SerialNo");
$received=odbc_result($rs,"Received");
$shipped=odbc_result($rs,"Shipped");
$ticketno=odbc_result($rs,"TicketNo");
$notes=odbc_result($rs,"Notes");
echo "<tr><td>$requester</td>";
echo "<td>$owner</td>";
echo "<td>$makemodel</td>";
echo "<td>$serialno</td>";
echo "<td>$received</td>";
echo "<td>$shipped</td>";
echo "<td>$ticketno</td>";
echo "<td>$notes</td></tr>";
}
odbc_close($conn);
echo "</table>";
?></body>
</html>
-
same way you assign any other links, however this would need extra security to be sure that the person has the correct level of administrative access to perform this deletion action. the only way to "undo" a delete is from a backup, which means dumping your database.
you assign the link to an anchor tag and use a get variable to assign the exact record you wish to delete,and once clicked, that script would perform a query to delete the record
Code:
DELETE FROM table WHERE condition;
-
Thanks again!
The page that will contain that will be password protected.
Thanks for all the help. I am almost done.
So, the command will be "DELETE FROM WarrantyInformation WHERE Requester =".$_POST['Requester']";
How would I just delete the entire record? Would I need to refer to it by the autonumer or something like that?
The link itself is: <a ... umm...!! STUCK AGAIN! :mad:
Looked around on Google but I can't see to find anything that explains it.
-
-