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
Did you know?Explore Trending and Topic pages for more stories like this.
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 Like 17 Dislike
Previous forums Next forums
Other forums

Paypal
Hi all,

I have an advanced basic knowledge of php

I want to try something new for a s

How to give the privillege for triggers?
Hi,

How to give the privillage for triggers to particular user?

Please let me

Files in current folder. Should be an easy fix.
Never mind. I've asked about this before and just found my answer. Anyway to delete this?

Need help with unexpected T-STRING error
I'm a newbie and I'm still learning PHP. However this error has me stumped. I've googled, searched t

Multiple server callbacks (NOT POSTBACKS)
Hello, I have 2 different javascript client side functions that are on timers. When the timers elap

How do I create a 2D game "camera" to follow player?
In J2ME programming I'm targeting MIDP 2.0 devices.

I'm using gamecanvas and I was thinking t

GET * FROM _____ Except?
I have a site that is for stock photography.

This section of the code calls images to display

in php, link returns to the line
When I add a link in a php page, the link word returns to the line (as a
would do)

Examp

Which practice of iteration through containers is preferred
In the "real world" what kind of loop do most people use to iterate through a container like a vecto

how to easy edit text, with box? Help.
Hi.
I have a little problem. I'm doing a webpage for my aunt and I would like to make it as easy

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash