View Single Post
  #1 (permalink)  
Old 02-25-2009, 08:19 PM
skull skull is offline
Registered User
 
Join Date: Feb 2009
Posts: 1
Making CMS I need to know why this code doesn't work

I'm making a fully custom CMS the post of the submit button doesn't work.

Heres the code of the page im working on

Code:
<?php
	$table = "`admin_players`";
	$where = $_GET["id"];
	if($_POST["adminpanel_add"] > "0" AND $row10["add"] == "1")
	{
		$query = "SELECT `user` FROM `admin_players` WHERE `user` = '".$_POST["user"]."'";
		$result = mysql_query($query);
		$row = mysql_fetch_array($result);
		$row = valid_row($row);
		print '<form name="adminpanel_add2" method="POST" action="?p=adminpanel&s='.$_GET["s"].'" enctype="multipart/form-data">';
		print '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
		
		pname('Add');
		$_POST = valid_row($_POST);
		fields('First Name', 'fname', '', 'text', $_POST["fname"], '');
		fields('Last Name', 'lname', '', 'text', $_POST["lname"], '');
		fields('Phone Number', 'phone', '', 'text', $_POST["phone"], '');
		if($_POST["user"] != $row["user"] OR $_POST["pass"] != $_POST["vpass"] OR $_POST["email"] != $_POST["vemail"] OR !eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($_POST['email'])) ))
		{
			if($_POST["email"] != $_POST["vemail"] OR !eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($_POST['email'])) ))
			{
				if($_POST["email"] != $_POST["vemail"])
				{
					fields('E-Mail Address Does not match Verify E-Mail', 'email', '', 'text', $_POST["email"], '');
					fields('Verify E-Mail Address Does not match E-Mail', 'vemail', '', 'text', $_POST["vemail"], '');
				}
				elseif(!eregi('^[a-zA-Z]+[a-zA-Z0-9_-]*@([a-zA-Z0-9]+){1}(\.[a-zA-Z0-9]+){1,2}', stripslashes(trim($_POST['email'])) ))
				{
					fields('E-Mail Address Is not valid', 'email', '', 'text', $_POST["email"], '');
					fields('Verify E-Mail Address Is not valid', 'vemail', '', 'text', $_POST["vemail"], '');
				}
			}
			else
			{
					fields('E-Mail Address', 'email', '', 'text', $_POST["email"], '');
					fields('Verify E-Mail Address', 'vemail', '', 'text', $_POST["vemail"], '');
			}
			print'<tr valign="top">
			<td colspan="8" class="row_space"></td>
			</tr><tr valign="middle">
			<td class="row_name">Group</td>
			<td class="row_value"><select name="gid">'; 
				$query2 = "SELECT `id`, `name` FROM `admin_group` ORDER BY `name` ASC";
				$result2 = mysql_query($query2);
				while($row2 = mysql_fetch_array($result2))
				{
					$row2 = valid_row($row2);
					if($row2["id"] == $_POST["gid"])
					{
						print'<option value="'.$row2["id"].'" selected>'.$row2["name"].'</option>';				
					}
					else
					{
					print'<option value="'.$row2["id"].'">'.$row2["name"].'</option>';
					}
			
				}
			print'</select></td></tr>';
			if($_POST["user"] != $row["user"])
			{
				fields('User Name Already Taken', 'user', '', 'text', $_POST["user"], '');
			}
			else
			{
				fields('User Name', 'user', '', 'text', $_POST["user"], '');
			}
			if($_POST["pass"] != $_POST["vpass"])
			{
				fields('Password Does not match verify password', 'pass', '', 'password', $_POST["pass"], '');
				fields('Verify Password Does not match password', 'vpass', '', 'password', $_POST["vpass"], '');				
			}
			else
			{
				fields('Password', 'pass', '', 'password', $_POST["pass"], '');
				fields('Verify Password', 'vpass', '', 'password', $_POST["vpass"], '');				
			}
			fields('Allow to add', 'add', 'Yes, No', 'options', $_POST["add"], '1, 0');
			fields('Allow to edit', 'edit', 'Yes, No', 'options', $_POST["edit"], '1, 0');
			fields('Allow to delete', 'del', 'Yes, No', 'options', $_POST["del"], '1, 0');
			fields('Active', 'active', 'Yes, No', 'options', $_POST["active"], '1, 0');
			fields('', 'add', '', 'submit', '', '');
			print'</table></form>';
		}
	}
	if($row10["add"] == "1" AND $_POST["adminpanel_add"] < "0")
	{
		print '<form name="adminpanel_add2" method="POST" action="?p=adminpanel&s='.$_GET["s"].'" enctype="multipart/form-data">';
		print '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
		
		pname('Add');
		fields('First Name', 'fname', '', 'text', '', '');
		fields('Last Name', 'lname', '', 'text', '', '');
		fields('Phone Number', 'phone', '', 'text', '', '');
		fields('E-Mail Address', 'email', '', 'text', '', '');
		fields('Verify E-Mail Address', 'vemail', '', 'text', '', '');
		print'<tr valign="top">
		<td colspan="8" class="row_space"></td>
		</tr><tr valign="middle">
	<td class="row_name">Group</td>
	<td class="row_value"><select name="gid">'; 
		$query2 = "SELECT `id`, `name` FROM `admin_group` ORDER BY `name` ASC";
		$result2 = mysql_query($query2);
		while($row2 = mysql_fetch_array($result2))
		{
			$row2 = valid_row($row2);
			print'<option value="'.$row2["id"].'">'.$row2["name"].'</option>';
						
		}
		print'</select></td></tr>';
		fields('User Name', 'user', '', 'text', '', '');
		fields('Password', 'pass', '', 'password', '', '');
		fields('Verify Password', 'vpass', '', 'password', '', '');
		fields('Allow to add', 'add', 'Yes, No', 'options', '', '1, 0');
		fields('Allow to edit', 'edit', 'Yes, No', 'options', '', '1, 0');
		fields('Allow to delete', 'del', 'Yes, No', 'options', '', '1, 0');
		fields('Active', 'active', 'Yes, No', 'options', '', '1, 0');
		fields('', 'add', '', 'submit', '', '');
		print'</table></form>';
	}
?>
Here's the part code which is needed to complete the form tags

Code:
function fields($name2, $name, $value, $type, $default, $image)
{
	print'<tr valign="top">
		<td colspan="8" class="row_space"></td>
		</tr><tr valign="middle">
	<td class="row_name">'.$name2.'</td>
	<td class="row_value">';
	text($name, $value, $type, $default, $image);
	print'</td></tr>';
}
function text($name, $value, $type, $default, $image)
{
	if($type == "text" AND $default < "0")
	{
		print'<input type="text" name="'.$name.'" size="25" value="'.$value.'" onFocus="if(this.value == \''.$value.'\') {this.value = \'\';}" onBlur="if (this.value == \'\') {this.value = \''.$value.'\';}" />';
	}
	elseif($type == "text" AND $default > "0")
	{
		print'<input type="text" name="'.$name.'" value="'.$default.'">';
	}
	else
	{
		print'';
	}
	if($type == "password" AND $default < "0")
	{
		print'<input type="password" name="'.$name.'" size="25" value="'.$value.'" onFocus="if(this.value == \''.$value.'\') {this.value = \'\';}" onBlur="if (this.value == \'\') {this.value = \''.$value.'\';}" />';
	}
	elseif($type == "password" AND $default > "0")
	{
		print'<input type="password" name="'.$name.'" value="'.$default.'">';
	}
	else
	{
		print'';
	}
	if($type == "submit")
	{
		print'<input type="submit" name="adminpanel_'.$name.'" value="Submit">';
	}
	else
	{
		print'';
	}
	if($type == "check")
	{
		print'<input name="'.$name.'" value="'.$default.'" type="checkbox">';
	}
	elseif($type == "check" AND $value =="checked")
	{
		print'<input name="'.$name.'" value="'.$default.'" checked="checked" type="checkbox">';
	}
	else
	{
		print'';
	}
	if($type == "options" AND $default < "0")
	{
		$key2 = preg_split('/, /', $image);
		$options = preg_split('/, /', $value);
		$options2 = array_combine($key2, $options);

		print'<select name="'.$name.'">';
		foreach($options2 as $key => $value2)
		{
			print'<option value="'.$key.'">'.$value2.'</option>';
		} 
		print'</select>';
	}
	elseif($type == "options" AND $default > "")
	{
		$key2 = preg_split('/, /', $image);
		$options = preg_split('/, /', $value);
		$options2 = array_combine($key2, $options);

		print'<select name="'.$name.'">';
		foreach($options2 as $key => $value2)
		{
			if($default == $key)
			{
				print'<option value="'.$key.'" selected>'.$value2.'</option>';
			}
			else
			{
				print'<option value="'.$key.'">'.$value2.'</option>';
			}
		} 
		print'</select>';
	}
	else
	{
		print'';
	}
	if($type == "textarea")
	{
		$oFCKeditor = new FCKeditor(''.$name.'') ;
	$oFCKeditor->Value = ''.$default.'';
	$oFCKeditor->Config["CustomConfigurationsPath"] = "/CMS/fck/my.js";
	$oFCKeditor->Config["ImageUploadURL"] = "/CMS/fck/editor/filemanager/connectors/php/upload.php?Type=Image&im=".$image."";
	$oFCKeditor->ToolbarSet = 'MyToolbar';
	$oFCKeditor->Create() ;
	}
	else
	{
		print'';
	}
}
Reply With Quote