Page 1 of 1

Moved servers, code no longer works. Help please!

Posted: Sun Jul 02, 2006 3:03 pm
by Citizen
Hello, I created this quick script to add an entry to my database. I moved servers and the code no longer works.

My new server is running php version 4.4.2 and mysql version 4.0.27-standard.

Is it a problem with my code or do I need to update the new server's version of php?

Code: Select all

<?php

include("../../inc/config/connect.inc");

include("header.php");

protect();

if (member_types2($VAR[4]) != '0') {
	echo "<p>Sorry, but you must be logged in as an administrator to view this area.";
}
else
{
include("menu.php");

if ($submit) {
$catname = strip_tags($catname);
$catname = trim($catname);
$displayorder = strip_tags($displayorder);
$displayorder = trim($displayorder);
	if ($catname == "") {
echo "Please enter a category name.";
	}
	else if ($displayorder == "") {
echo "Please enter a valid display order.";
	}
	else {
$sql = "INSERT INTO `arcade_categories` (catname, displayorder) VALUES ('$catname', '$displayorder')";
$result=mysql_query($sql) or die(mysql_error());
echo "<p>Congratulations, your arcade category has been entered!";
	}
}
echo"
<h2>Add a new category:</h2>
<p>
<form method='post' action='$PHP_SELF'>
<p><b>Category Name:</b></p>
<input type='Text' name='catname' maxlength='20'>
<p><b>Display Order:</b></p>
<input type='Text' name='displayorder' maxlength='10'>
<p>
<input type='Submit' name='submit' value='Submit'></p>
</form>
";
include("footer.php");
}
?>

Posted: Sun Jul 02, 2006 3:39 pm
by LiveFree

Code: Select all

if (member_types2($VAR[4]) != '0') {
        echo "<p>Sorry, but you must be logged in as an administrator to view this area.";
}
to

Code: Select all

if ($member_types2($VAR[4]) != '0') {
        echo "<p>Sorry, but you must be logged in as an administrator to view this area.";
}

Posted: Sun Jul 02, 2006 3:48 pm
by Ollie Saunders
I Don't see how you reached that conclusion tucker.
Moved servers, code no longer works. Help please!
What doesn't work, do you get any errors?

Posted: Sun Jul 02, 2006 4:04 pm
by Citizen
The form is displayed and I can enter information. When I click submit, the page refreshes and the fields are erased but the form doesnt add the content to the database or show any errors.

Posted: Sun Jul 02, 2006 4:09 pm
by Ollie Saunders
Can you paste here the contents of ../../inc/config/connect.inc please

Posted: Sun Jul 02, 2006 4:20 pm
by Citizen
The connect.inc script works fine. It checks to see if I'm logged in as an admin, which I am, and the page loads. The script stops working after I click submit.

Posted: Sun Jul 02, 2006 5:13 pm
by Ollie Saunders
where is $submit assigned then?

Posted: Sun Jul 02, 2006 5:46 pm
by xpgeek
2 Moderator - delete this post please
Citizen wrote:The connect.inc script works fine. It checks to see if I'm logged in as an admin, which I am, and the page loads. The script stops working after I click submit.
May be problem in "register globals off"

try to add

Code: Select all

extract($_POST);

Posted: Sun Jul 02, 2006 5:47 pm
by xpgeek
Citizen wrote:The connect.inc script works fine. It checks to see if I'm logged in as an admin, which I am, and the page loads. The script stops working after I click submit.
May be problem in "register globals off"

try to add

Code: Select all

extract($_POST);
or use

Code: Select all

$_POST['submit'];

Posted: Sun Jul 02, 2006 6:13 pm
by Ollie Saunders
May be problem in "register globals off"
Ahh yes that is a likely possibility.

Posted: Sun Jul 02, 2006 10:14 pm
by John Cartwright
using extract() isn't any better than having register globlas on, as it allows any variable to be injected into the script.. use the super global $_POST instead (as previously suggested)