localhost Posted June 5, 2006 Share Posted June 5, 2006 [code]<?php/*submit news script made by dann for accessfrom the admin paneladmin/*/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 statementecho "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 https://forums.phpfreaks.com/topic/11208-news-system/ Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 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 https://forums.phpfreaks.com/topic/11208-news-system/#findComment-41939 Share on other sites More sharing options...
localhost Posted June 5, 2006 Author Share Posted June 5, 2006 those ` quote have always worked for me in situations like this...idk why theyre not working now. Link to comment https://forums.phpfreaks.com/topic/11208-news-system/#findComment-41940 Share on other sites More sharing options...
localhost Posted June 5, 2006 Author Share Posted June 5, 2006 FIXED. IT was due to the lack of <form action="" method="POST> :p Link to comment https://forums.phpfreaks.com/topic/11208-news-system/#findComment-41942 Share on other sites More sharing options...
.josh Posted June 5, 2006 Share Posted June 5, 2006 edit: you posted at same time as me. kk then. Link to comment https://forums.phpfreaks.com/topic/11208-news-system/#findComment-41943 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.