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
Help with form post data and arrays
Hi all,
I am new to this forum... It has been awhile since i have worked with arrays, and i a
Whats wrong with my query?
I am trying to get this query to show the appropriate ticked vehicle roof height, unless no boxs are
Sequencing or queuing parallel process
Scenario is as follows
There is one parent process say P1 and 4 child processes say A B C D
Security Exception on pages using AJAX
I am getting the exception: attempted to perform an operation not allowed by the security policy on
Multiple while loops
I have several DB queries that I know should be returning results and aren't. I have a feeling it ha
Suggestions for Functional module
Hello experts,
I Have done B.Sc(Mathematics) and MCA & have learnt SAP/ABAP but do n
how to insert value
I am having file bookissueadd.php..... in which i am having tag
<td height="21&q
Preventing SQL Injection
I have a question about SQL Injection, In some of our code we use this:
view plaincopy to clipboa
PHP mail() rejected by SMTP
I'm currently working on a newsletter application which is installed on a windows 2003 server runnin
Adding Different Numbers From MySQL
Basically I have a mysql database with a couple prices as the following:
9.99
9.99
9.99