Jump to content

Recommended Posts

I have no Idea why the following code is generating a blank form, but it is.

 

Here is the code that generates the form:

 

<?php

include 'config.php';
mysql_select_db("exembar_site");

$query 			= "SELECT * FROM `navigation` WHERE `id`=".$_GET['page'];
$result 		= mysql_query($query);
$info 			= mysql_fetch_array($result);
$navbar			= $info['display'];

$query 			= "SELECT * FROM `pages` WHERE `id`=".$_GET['page'];
$result 		= mysql_query($query);
$info 			= mysql_fetch_array($result);
$title 			= $info['title'];

$query 			= "SELECT * FROM `pgContent` WHERE `id`=".$_GET['page'];
$result 		= mysql_query($query);
$info 			= mysql_fetch_array($result);
$top 			= $info['topBar'];
$content		= $info['content'];

$body 			='

			<form name="create" method="post" action="php/doEditPage.php?id='.$_GET['page'].'">
			<div class="label">Page Title:</div> <input type="text" name="title" class="field" value="'.$title.'"/> 
			<div class="label">Nav Text:</div> <input type="text" name="display" class="field" value="'.$navbar.'"/> 
			<div class="label">Top Bar:</div> <input type="text" name="topbar" class="field" value="'.$top.'"/> 
			<div class="label">Content: tags: [<br /> <a> <img> <i> <b> <u>]</div>
			<textarea rows="15" cols="52" name="content" class="lgfield">'.$content.'</textarea> <br />
			<input type="submit" value="Edit"  class="button"/>
			</form>

		';

$page->setContent($body);

?>

 

I seem to get this result on occasion, but can never figure out where it came from. I thought I had figured it out, the GET indexes were wrong, but that didn't fix it.

 

Any and all help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/140379-solved-form-is-blan-but-no-errors/
Share on other sites

Oh, my, $page is constructed about 3 includes up, above the inclusion of this file. setContent just sets a variable to the value passed to it.

 

Here is the Page class:

 

<?php

include 'config.php';

class Page{

function Page(){

	if(isset($_GET['id'])){

		$this->id			= $_GET['id'];

	}
	else{

		$this->id			= 0;

	}

	if(isset($_GET['option'])){

		$this->option		= $_GET['option'];

	}
	else{

		$this->option		= 0;

	}

	//pre-initialize append-only variables
	$this->tab_list		= "";
	$this->options		= "";

}

function tabs(){ //generates the tabs at the top of the box

	$tab_name				= array('Pages',
									'Staff',
									'Profile',
									);

	$tab_loc				= array('index.php?id=0&option=0',
									'index.php?id=1&option=0',
									'index.php?id=2&option=0',
									);

	for($size = 0; $size < count($tab_loc); $size++){

		if($this->id == $size){

			$this->tab_list		.= '<div class="visit_tab_outer">
										<div class="visit_tab_inner">
											<a href="'.$tab_loc[$size].'">'.$tab_name[$size].'</a>
										</div>
									</div>';
			continue;

		}

		$this->tab_list		.= '<div class="tab_outer">
								<div class="tab_inner">
									<a href="'.$tab_loc[$size].'">'.$tab_name[$size].'</a>
								</div>
							</div>';

	}

	echo $this->tab_list;

}

function appendOp($path, $name, $params = ""){ //adds an option to the sidebar of the page

	if(!empty($params)){

		$path				.= "?";

	}

	$this->nav			.= '<a href="'.$path.$params.'">'.$name.'</a>';

}

function setContent($content){ //set the content of the main body of the page

	$this->content		= $content;

}

}

?>

 

$page is constructed as an object of the Page class in the main.php file, which is responsible for the file inclusion logic. Here it is:

 

<?php

include 'classes.php';

$page			= new Page;

switch($page->id){

case 0:{

	include 'pageOptions.php';

	break;

}

case 1:{

	include 'staffOptions.php';

	break;

}

case 2:{

	include 'profileOptions.php';

	break;

}

}

?>

 

setContent() is working fine, I'm getting the form it was passed, but the values that are supposed to be in the fields are not there. The problem is with the code I originally posted

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.