Jump to content

[SOLVED] Submit button loads a white page after a few minor changes.


ShadeSlayer

Recommended Posts

Alright, so I had the code for something I've been doing, and I revised it because it was just feeding off of a different websites database.

 

What happens now, as opposed to what happened before is huge: Before, it would enter the content to the database. Now, it sends me to a white screen. All I did were a few minor changes to make the script independent.

 

Here is my old code:

<?php
include("../common.php");

// 3.0.0 (recent add: db upload)
echo "<b>Glitch Editor</b><br />
Enter the game title in the title box, and paste the glitch code in the glitch box. **have all code in HTML<br /><br />
<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
<table width=\"100%\">
<tr>
<td width=\"100%\">
<b>Title:</b> <input type=\"text\" name=\"title\" value=\"\" /><br />
<b>Content:</b><textarea style=\"width: 100%; height: 100px;\" name=\"string\"></textarea>
</td>
</tr>
<tr><td>
<input type=\"hidden\" name=\"action\" value=\"output\" />
<input type=\"submit\" />
</td></tr>
</table>
</form>";
if ($_POST['action'] == "output")
{
$title = $_POST['title']; //, $string
$content = $_POST['string'];

$sql = "INSERT INTO pxb_glitches (date, title, content) VALUES (".date("U").", '".addslashes($title)."', '".nl2br(addslashes($content))."');";
if($exe = runQuery($sql)){ echo "Query Complete"; }else{ echo "Error entering values."; }
}
?>

As you can see there, the script got the database connection from a file in a different directory, and it just straight echo'd all the content.

 

Here is the updated code:

<?php
include("config.php");
$pagetitle = "Add Glitches";
$output = "<b>Glitch Editor</b><br />
Enter the game title in the title box, and paste the glitch code in the glitch box. **have all code in HTML<br /><br />
<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
<table width=\"100%\">
<tr>
<td width=\"100%\">
<b>Title:</b> <input type=\"text\" name=\"title\" value=\"\" /><br />
<b>Content:</b><textarea style=\"width: 100%; height: 100px;\" name=\"string\"></textarea>
</td>
</tr>
<tr><td>
<input type=\"hidden\" name=\"action\" value=\"output\" />
<input type=\"submit\" />
</td></tr>
</table>
</form>";
if ($_POST['action'] == "output")
{
$title = $_POST['title']; //, $string
$content = $_POST['string'];

$sql = "INSERT INTO pxb_glitches (date, title, content) VALUES (".date("U").", '".addslashes($title)."', '".nl2br(addslashes($content))."');";
if($exe = runQuery($sql)){ $output = "Query Complete"; }else{ $output = "Error entering values."; }
}
$pagecontents = $output;
include("layout.php");
?>

Here, I changed the location of the SQL connect file. All I did to the connect file was rename it, and move it to the local directory.

 

Then I changed all the echo tags to $output so they could be echoed in an external file (which is included at the bottom). So at the very bottom, I include the layout file for the stuff to echo the content.

 

My only problems with my scripts are submitting forms. I have a different page that displays the stuff in the database, and it displays the database info like it should.

 

So I don't see how a few minor changes like this can screw up a whole script, and I can't find anything that could be causing this problem.

 

Thanks a bunch for your help.

Link to comment
Share on other sites

I just updated my config file, took out a bunch of useless stuff.

 

<?php
/* Configuration Page
* Script by Alex Crooks Webdesign
* Copyright 2009, protected under Creative Commons Licence
*/
include("settings.php");
error_reporting("E_ALL");

// Define Table Names
define("table_achievements", $global['prefix']."_achievements");
define("table_cheats", $global['prefix']."_cheats");
define("table_comments", $global['prefix']."_comments");
define("table_glitches", $global['prefix']."_glitches");
define("table_proreviews", $global['prefix']."_proreviews");
define("table_reviews", $global['prefix']."_reviews");
define("table_unlockables", $global['prefix']."_unlockables");
define("table_walkthroughs", $global['prefix']."_walkthroughs");


// Connect to the database
if($mysql['conn'] = mysql_connect($global['host'], $global['username'], $global['password']))
{
$mysql['select'] = mysql_select_db($global['database'], $mysql['conn']);

if(!$mysql['select'])
{
echo "<b>Error:</b> Failed connection to database.<br /><br />".mysql_error();
}
}
else
{
echo "<b>Error:</b> Failed connection to server.<br /><br />".mysql_error();
}

// Retrieve Site Settings
//$setting = "SELECT * FROM ".TABLE_SETTINGS;
//$settings = mysql_fetch_array(mysql_query($setting));

// Retrieve Functions File
//include($row['functions']);
?>

 

The settings file consists of 5 things: database name, "localhost", username, password, and prefix. They all work fine (since the pages that retrieve database info work just fine).

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.