Naithin Posted July 28, 2007 Share Posted July 28, 2007 Hi guys, I've reached the end of my tether in terms of what I can troubleshoot of my own here, particually in the absence of any error output at all. The form displays fine (in the EVE Ingame browser, as intended), allows for data entry, and the submit button will.. well.. reload the page. However as near as I can tell, the submit is not being picked up by the top of the page where I'm checking for it, as the form displays anew, with no entries into the database. If I intentionally leave the title blank, same thing occurs. Form reloads, with no sign nor trace of the error message I tried to encode into it. So, I'm hoping that the non detection of the submit is something easy to fix that I've simply been overlooking. Any and all assistance or pointers in the right direction would be incredibly appreciated. Managed to cobble it together thus far, would like to try see it through! PS: User/pass in the mysql connect have been edited out, they are there correctly in original code. <?php require 'includes/pagesetup.php'; //connect to DB $db = mysql_connect ("localhost", "username", "pass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("naithin_eve"); $pilot = new pilot(); if($submit) // If news has already been submitted. { // Set global variables to easier names // and pervent sql injection and apostrophe to break the db. $title = mysql_real_escape_string($_POST['title']); $posted = mysql_real_escape_string($_POST['posted']); $corp = mysql_real_escape_string($_POST['corp']); $blurb = mysql_real_escape_string($_POST['blurb']); $full = mysql_real_escape_string($_POST['full']); // check if title field is empty, print error if true. if(!$title) // empty { echo "Error: News requires a title in order to be posted."; exit(); // Exit script here, performing no other actions. } //Add Data into the DB. $result = mysql_query("INSERT INTO evenews (dtime, title, posted, corp, blurb, full) VALUES (NOW(),'$title','$posted','$corp','$blurb','$full')",$db); //Print success?! echo "<h4>Thank-you! News added successfully.</h4>"; } else { ?> <h3>::Add News::</h3> <br /> <br /> <form action="addnews.php" method="post"> Title: <input name="title" size="25" maxlength="255"> <br /> <input name="posted" type="hidden" value="<?php echo $pilot->get('name');?>"> <input name="corp" type="hidden" value="<?php echo $pilot->get('corp');?>"> <br /> Text Blurb: <br /> <textarea name="blurb" rows="5" cols="25"> </textarea> <br /> Full News: <br /> <textarea name="full" rows="5" cols="25"> </textarea> <br /> <input type="submit" name="submit" value="Add News"> <br /> </form> <?php } ?> And in case it is relevant, here is the pagesetup.php include file: <?php // Constants: define ('DIRSEP', DIRECTORY_SEPARATOR); // Get site path $site_path = realpath(dirname(__FILE__) . DIRSEP . '..' . DIRSEP) . DIRSEP; define ('site_path', $site_path); $browser = $HTTP_SERVER_VARS['HTTP_USER_AGENT']; $ingame = (substr($browser,0,16)=='EVE-minibrowser/'); function pageSetup() { global $browser, $ingame, $trusted; if ($ingame) // check for the IGB. { if ($_SERVER['HTTP_EVE_TRUSTED']=='no') { // Check site for trust. If not trusted, set flag and redirect. $trusted = false; header("refresh: 0;URL=./trust.php"); } else { // If site is trusted, set true. $trusted = true; } } else // If any other browser than the IGB, redirect to the non IGB Error page. { header("refresh: 0;URL=./igb.php"); } } // For loading classes function __autoload($class_name) { $filename = strtolower($class_name) . '.php'; $file = site_path . 'classes' . DIRSEP . $filename; if (file_exists($file) == false) { return false; } include ($file); } pageSetup(); ?> Quote Link to comment Share on other sites More sharing options...
Naithin Posted July 28, 2007 Author Share Posted July 28, 2007 I have managed to fix one of my errors, and news can be submitted now! \o/ However.. It still cannot detect if the title is empty and error appropriately. My code in this area now looks like: if(isset($_POST['submit'])) // If news has already been submitted. { if(empty($_POST['title'])) // empty { echo "Error: News requires a title in order to be posted."; exit(); // Exit script here, performing no other actions. } If you need anything further, please let me know. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.