Left menu, right form display

I have a standard html/css page that displays a top horizontal menu, and a left vertical menu.

When I select an option from the left menu it’s calling a php program that loads a template (basically a form for each option).

My problem is I want to display the form to the right of the existing vertical menu and below the horizontal menu. Currently it displays like a new page, and a look at the page source shows the form detials without the rest of the calling page!

What do I need to do? I probably haven’t explained this very well :shifty:

Hi Salient. It’s not really clear what your situation is, so any further explanation you can give would be helpful.

If this is just a positioning issue, please post the generated HTML and the CSS that goes with it so we can help you with positioning. If it’s a PHP issue, we can move the thread to that forum.

Ralph think it’s an html issue or maybe css.

Okay step by step going down the files, and cutting down to the relevant lines

  1. Admin.php

<?php

include_once("./template/admin_head.html");

?>

...

						<li><a href="admin_country.php?mod=cadd">Add a Country</a></li>

In the admin_head.html we load the <head> section of the html, including css and js etc.

A menu exists on the left hand side of the pafe with one of the options being “Add a Country”. Okay that displays fine

  1. admin_country.php

	function countryadd()
	{
		global $templates, $admin_lang;
		include($templates."admin_new_country.php");
		exit();
	}

We drop into the countryadd function, in next version will be a class, that basically loads the “admin_new_country.php” template where we enter Country details.

  1. admin_new_country.php

	<form method="post" action="admin_country.php?mod=newcountry">
		<p><?php echo($admin_lang['ctydetails']); ?></p>
		<ol>
	       	<li>
        		<label for="countryid"><?php echo($admin_lang['ctyid']); ?></label>
        		<input type="text" name="countryid" id="countryid" />
        	</li>
        	<li>
        		<label for="countryname"><?php echo($admin_lang['ctyname']); ?></label>
        		<input type="text" name="countryname" id="countryname" />
        	</li>
        	<li>
        		<label for="cgraphic"><?php echo($admin_lang['ctyupflag']); ?></label>
				<input type="file" name="cgraphic" id="cgraphic" class="file" />
			</li>
        	<li>
        		<button type="submit" id="save"><?php echo($admin_lang['ctyadd']); ?></button>
        	</li>
	    </ol>
	</form>				

When I look at page source I get the template html and nothing else :frowning: So basically it’s losing the css and previous html, almost like it’s creating a fresh page. Think I’m missing something here, but not sure what.

Have checked google but either am not entering the correct search criteria or this isn’t a common occurance :shifty:

Strangely it’s finding the language includes and translating those.

Sorry, but all this is over my head. Everything you’ve posted above is just PHP stuff, and doesn’t show what’s actually happening on your page once it reaches the browser. (All PHP gets stripped out on the server, before the page is sent to the browser.)

Not sure what that means.

Again, if this is an HTML/ CSS issue, please post the page as it’s seen by the browser, with the full HTML and CSS. That way we can assess any layout issues. If, instead, this is an issue of functionality, then your really need to be over in the PHP or WordPress forums.

[This is really sounding like a PHP (functionality) question, so I’ve moved this thread to the PHP forum. :slight_smile: ]

Looking at page source we get


<!--
	Template  :	admin_country.php
	Date      : 22 May 2011
	Author    : Jeff (R version)
	Version   : 1.0.1
-->

	<form method="post" action="admin_country.php?mod=newcountry">
		<p>Country Details</p>
		<ol>
	       	<li>
        		<label for="countryid">Country Id</label>
        		<input type="text" name="countryid" id="countryid" />
        	</li>

        	<li>
        		<label for="countryname">Country Name</label>
        		<input type="text" name="countryname" id="countryname" />
        	</li>
        	<li>
        		<label for="cgraphic">Upload a Flag</label>
				<input type="file" name="cgraphic" id="cgraphic" class="file" />
			</li>

        	<li>
        		<button type="submit" id="save">Add the Country</button>
        	</li>
	    </ol>
	</form>				

Basically we are getting the template displayed with the language translates (via php echos) having been done.

I’m wondering if because our main page has the page ending tags (</body> </html>), the browser is displaying that and then sees the template as a separate page when I click through onto it? Might explain the situation.

This may require the whole page to be re-generate on each option click? We could do this with includes easily enough, but it kind of defeats the purpose somewhat :frowning:

Uhmm no it’s an html question, now know what the problem is, trying to sort a solution that doesn’t involve a complete rebuild of the page from scratch :eek:

I think it’s a php question :slight_smile: (Bear in mind I know no php)

When you submit your form you are requesting a new page and that’s what you get.


<form method="post" [B]action="admin_country.php?mod=newcountry"[/B]>

You ask for admin_country.php and that’s what you get. You didn’t ask for the original page with admin_country.php inserted into the middle.

What I guess you should be doing (and I know no PHP as I said above) is requesting the original page again but modifying it with the results from the form submission so that your new data is visible.

However it seems that perhaps some sort of ajax request would be more suitable.

Hopefully one of the PHP experts will see this thread and advise the best way to do this.:slight_smile:

Need to see more of admin_country.php - specifically, where it looks for $_GET[‘mod’], and what it does with it (probably a switch statement)

As requested


	if(isset($_GET['mod']))
	{
		$mod = $_GET['mod'];
	} else {
		$mod = '';
	}
	
	if(isset($_GET['id']))
	{
		$id = $_GET['id'];
	} else {
		$id = '';
	}
	
	switch($mod)
	{
		case 'cadd':
			countryadd();
			break;	
		case 'newcountry':
			countrywrite();
			break;
		case 'del':
			countrydel();
			break;
		case 'edit':
			countryedit();
			break;
		case 'mod':
			countrymod();
			break;
		default:
			showall();
			break;
	}

As Paul has pointed out above it’s a request of a new page that is causing us an issue. The removal of all php from the scripts and a simple test with html elicits the same issue :frowning:

So I guess the question becomes, how to keep the original page and insert the form somehow, or do I need to redisplay the entire page with the form html included?

  1. admin_country.php
	function [COLOR="Red"]countryadd[/COLOR]()
	{
		global $templates, $admin_lang;
		include($templates."admin_new_country.php");
		exit();
	}

<form method=“post” action="admin_country.php?mod=newcountry">

	case [COLOR="Green"]'newcountry'[/COLOR]:

countrywrite();
break;

you’re looking in the wrong function.

Sorry, the form calls another function to write the record, the form is being displayed correctly via the correct link.

The problem is the browser is interrupting a new page submission when it hits the form, that’s the issue I need to work around somehow.

A couple of people on another forum have suggested ajax, but since I don’t know that it’s problematic for me at this stage as we simply want to get it up and running and worry about smoothing the rough edges out in a later version.

I read your response. Granted it’s 11:30 at night, but… I dont actually understand what you said.

Which part of the things you pasted to us arnt actually the thing you pasted? The form action, the switch, or the function

Don’t worry about it, have the answer on another forum and will follow their lead on a work around.

As stated, and people seem not to be getting this, the issue is one with html and page display, not with php or anything else. As it turns out we simply fell into a gotcha and will have to take a couple of steps back to move forward on this project. Slightly irritating but I should have thought things through move thoroughly before splitting the project amongst the team :slight_smile:

Code was posted on request :shifty:

Thanks for the answers guys, but we have a workable solution now that is being implemented overnight (our time in Oz).

Just so you know, posting the same question on different sites at the same time is not good etty quetty. At least don’t admit to it. :stuck_out_tongue:

All the same, glad it’s sorted. :slight_smile: