Posted by paul on 12/01/48 11:49
Hi could anyone please help me. I am a newbie to php. I am using php4
and trying to put together some code to update a db but I am not having
much luck. This is the code I have come up with so far.
<?php
if (isset($_POST['submitted'])) { // if the form has been submitted
handle it
// check the required form fields.
if (!empty($_POST['JobNumber'])) {
// Include MYSQL info
require_once
'/home/e-smith/files/ibays/mct/cgi-bin/mysql_connect.inc.php';
// Create the query
$q = "INSERT INTO MyDB (JobNumber) VALUES ('{$_POST['JobNumber']}')";
// Execute the query
$r = mysql_query ($dbc, $q);
//print a message indicating success
if (mysql_affected_rows($dbc) == 1) {
echo '<b><font color="green">It Has Been entered!</font></b>';
} else {
echo '<b><font color="red">Sorry it has failed!</font></b>';
}
Close the connection
mysql_close($dbc)
} else { //print a message if they failed to enter a catagory
echo '<b><font color="red">You forgot to enter a value</font></b>';
}
} else {
?>
Add a new category to the Job Number:<br />
<form action="add_expense_category.php" method="post">
<input type="text" name="JobNumber" size="30" maxlength="30" /><br />
<input type="hidden" name="submitted" value="true" />
<input type="submit" name="submit" value="Submit!" />
</form>
<?php
}
?>
but for some reason it doesn't work. Am I missing something I have
looked over it 100 times but everything seems fine. Can anyone help me
out.
Thanks in advance
Paul
Navigation:
[Reply to this message]
|