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
need help in mysql_num_rows()
please tell me what i am doing wrong in this query. it displays this error
Code: Warning: mys
Not capturing all the information we require in the form.......
Hi Guys,
I was wondering if you would share some more of your knowledge today, I'm hoping it
check if value exists
I have googled this for a while and I am getting lots of different results. Is there a standard meth
Problems generating word documents on server side for security reasons
I have a problem with word documentation generation when generating a word document (docx) with PHP.
php global variable
how can we create global variable so we can use its value in any form.. Please give example to
Oracle Connectivity
Hi Every One,
Can we access SAP from oracle database.If it possible then please spec
Find only certain URLs from page ... regex (semi-complete script)
Hi guys,
What I need to do is take a page & extract all the URLs from the page &a
how do i display data on a page from mysql
1 - do i use this code at the top of each of my page i wish to only alow access if there as been a s
scandir clients directory
hi,
how can i scandir the clients directory? i need a script that when i click a button it will u
Last character removed
I have created a string from an array. I have inserted commas from my form values. I am trying to re