Jump to content

news system...


localhost

Recommended Posts

[code]<?php

/*
submit news script made by dann for access
from the admin panel
admin/
*/

include('../includes/connect.php');

session_start();

$user = $_SESSION['user'];

if($user) {

if(isset($_POST['submit'])) {

$username = $_POST['username'];
$title = $_POST['title'];
$description = $_POST['description'];
$ip = $_POST['ip'];
$date = $_POST['date'];

if($title==NULL || $description==NULL || $username==NULL || $ip==NULL || $date==NULL) {
echo "All fields must be filled in.";
} else {
$query = "INSERT INTO news (`username`, `title`, `description`, `ip`, `date`) VALUES ('$username', '$title', '$description', '$ip', '$date')";
$result = mysql_query($query) or die('Could not insert news into system contact Copernicus');

} // for submit button if
} // for if is NULL
} else { // for the logged in if statement
echo "you must be logged in.";
}

?>
<style type="text/css">
<!--
.style1 {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: x-small;
}
-->
</style>
<title>Submit News</title>
<p><input type="hidden" name="username" value=" <?php $_SESSION['user']; ?> " />
  <Br>
  <span class="style1">Title:<Br>
  <input type="text" name="title" />
    
  <BR>
  Description:
  <Br>
  <input name="description" type="text" value="" height="50">
  <BR>
  <input type="submit" name="submit" value="Submit">
  <input type="hidden" name="ip" value=" <?php echo $_SERVER['REMOTE_ADDR']; ?> ">
  <input type="hidden" name="date" value=" <?php echo date('m/d/Y'); ?> ">
  </span></p>
  [/code]

this doesnt submit it to the database, any idea why???
Link to comment
Share on other sites

assuming that you are actually getting a connection from your include, and assuming that all of your variables are not null, i think the problem is that you have those funky quotes around your column names.

$query = "INSERT INTO news ([b]`[/b]username[b]`[/b], [b]`[/b]title[b]`[/b], [b]`[/b]description[b]`[/b], [b]`[/b]ip[b]`[/b], [b]`[/b]date[b]`[/b]) VALUES ('$username', '$title', '$description', '$ip', '$date')";

for some reason those types of quotes don't seem to work a lot..
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.