Script not running properly
Posted on
16th Feb 2014 07:03 pm by
admin
Hello Everyone
This is a basic script for posting to a database. I'm not sure why it doesn't work. Can anyone tell me why?
Code: [Select]<?php
require('config.php');
if(isset($_GET['id']) == TRUE && isset($_GET['td'])==TRUE){
if(is_numeric($_GET['id'])==FALSE || is_numeric($_GET['td'])==FALSE) {
$error = 1;
}
if($error == 1){
header("Location: " . $config_basedir);
}
else{
$validentry = $_GET['id'];
$validtd = $_GET['td'];
}
}
else{
$validentry = 0;
}
if($_POST['submit']) {
$db = mysql_connect($dbhost,$dbuser,$dbpassword);
mysql_select_db($dbdatabase, $db);
if(!$db){
die('FAILED TO OPEN DATABASE:' . mysql_error());
}
$sql = "INSERT INTO todo(id, topic, date, comment)
VALUES (" . $validentry . ", '" . $_POST['topic'] .
"', '" . $_POST['date'] . "', '" . $_POST['comment'] . "');";
$result=mysql_query($sql);
if(!$result){
die('FAILED TO INPUT INTO DATABASE:' . mysql_error());
}
header("Location: index.php?id=" . $validentry);
}
?>
<center>
**All dates must be inputted in the YYYY-MM-DD format**
<form action="<?php echo $SCRIPT_NAME . "?id=" . $validentry; ?>" method="post">
<table>
<tr>
<td>Topic</td>
<td><input type="text" name="topic"></td>
</tr>
<tr>
<td>Date</td>
<td><input type="text" name="lname"></td>
</tr>
<tr>
<td>Comment</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="submit" value="Submit Note"></td>
</tr>
</table>
</form>
</center>
No comments posted yet
Your Answer:
Login to answer
295 17
Other forums
Error: SQL Syntax; Line 1
Code:
<?php require "global_settings.php"; ?>
<title&g
Need help with a mail notify function
I was tasked with setting up a site that's been prewritten. The site is basically a form that captur
[Need Help] php timing issues
I don't know what is going wrong. I need some help with being able to set an image at 9:00am Colorad
Error Messaging not working
I changed the way my form tells the user of an error. But I can't seem to get it to work properly.
Procedural to OOP
John Kleijn said that to avoid writing "crappy code", we should learn OOP and common OO pr
Auto fill in input value based on User_ID
Hello,
I'm looking form some input on the following problem.
User loads page ->
Form always sends to error page...
Hello,
Any help will be greatly appreciated. I am having trouble getting multiple fields to be re
PHP & MS Access - Line Break
Hey Guys!
I'm pulling records from an MS Access database and listing them using PHP and I'm r
BAPI BBP_INB_DELIVERY_CREATE - material number missing in delivery
Hi Experts,
I was able to successfully create an Inbound delivery with reference to a PO
PHP doesn't send my mail
Hi all, I found this and used it to send mail. Simple contact form with some required fields. The va