Jump to content

Archived

This topic is now archived and is closed to further replies.

localhost

news system...

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???

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites
those ` quote have always worked for me in situations like this...idk why theyre not working now.

Share this post


Link to post
Share on other sites

×

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.