I am new to php and I can't seem to get some code to insert information into a Access database. I am running Apache 2.2 server with php 5.1.2 and on a Windows XP SP2 platform. Here is the code I am attempting to get running, if someone is intrested in helping a new php person out.
Expand|Select|Wrap|Line Numbers
- <?php
- $Fname = $_POST["name"];
- $Fphone = $_POST["phone"];
- $Fproblem = $_POST["problem"];
- $Fdate = date("m/d/Y");
- if (!isset($_POST['submit'])) { // if page is not submitted to itself echo the form
- ?>
- <html>
- <head>
- <title>IT Issues</title>
- </head>
- <body bgcolor="#00FFFF" onLoad="self.focus();document.IssueAdd.name.focus()" >
- <h1 align="center">Tuthill Transport Technologies</h1>
- <hr>
- <h2><i><font size="5" face="Arial">IT Trouble Report</font></i></h2>
- <!-- Begin form code -->
- <tr>
- <td width="100%" valign="top">
- <form name="IssueAdd" method="post" action="<?php echo $PHP_SELF;?>">
- <font size="3" face="Arial"> Name: <input type="text" name="name" tabindex=1 maxlength="20"></font>
- <br>
- <font size="3" face="Arial"> Phone: <input type="text" name="phone" tabindex=2 maxlength="5"></font>
- </td>
- </tr>
- <tr>
- <br>
- <td width="100%" valign="top"> <br></td>
- </tr>
- <tr>
- <td width="100%" valign="top">
- <font size="3" face="Arial">
- <q>Please give a summary of the problem, and any cause that you may know of.</q>
- </font> <br> <textarea name="problem" tabindex=3 rows="10" cols="70"></textarea>
- </td>
- </tr>
- <tr>
- <br>
- <td width="100%" valign="top"> <br></td>
- </tr>
- <tr>
- <br>
- <td width="100%" valign="top">
- <input type="submit" name="submit" tabindex=4 value="Submit Request">
- </td>
- </tr>
- <tr>
- <br>
- <td width="100%" valign="top"> <br></td>
- </tr>
- </form>
- </body>
- </html>
- <?
- } else {
- echo "<b>Your request has been sent to the IT group as:</b><br/>";
- echo "<br />";
- echo "Contact name: ".$Fname." at ".$Fphone."<br />";
- echo "<br />";
- echo "To resolve: <br />";
- echo $Fproblem." <br />";
- echo "<br />";
- echo "Submission Date: ";
- //echo date("m/d/Y");
- echo $Fdate;
- echo "<br />";
- echo "Submission Time ";
- echo date("h:i:s");
- echo "<br />";
- echo "<br />";
- echo "<br />";
- echo "Thank You";
- $db = 'C:\\xampp\\htdocs\\ITrequest\\PC_PROBLEMS.mdb';
- $conn = new COM('ADODB.Connection') or exit('Cannot start ADO.');
- //$con=odbc_connect("ITrequest","","") or exit('Cannot open with ODBC');
- $conn->Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=$db") or exit('Cannot open with Jet.');
- //$conn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=$db") or exit('Cannot open with driver.');
- $sql = "INSERT INTO PROBLEMS(USER,phone,SUMMARY OF REPORT,date) VALUES('$Fuser','$Fphone','$Fproblem','$Fdate'])";
- $rs = $conn->Execute($sql);
- }
- ?>
Thank You