Jump to content

Trying to include...


kjetterman

Recommended Posts

Hi,

 

So, i'm attempting to add an includes file to a string that is echoed after a successful file upload. The problem is... I am having a hard time getting the file to show up OR I get an error message.

 

Here is the code I was trying initially

 

$statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.<br /> include('includes/usermain/successpage.php') </fieldset>";   

 

I also tried:

 

$statusMessage = "<fieldset><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.<br />". include('includes/usermain/successpage.php') ."</fieldset>";  

 

However, as I read through the manual, I understand that . is used to convert to string? I would get an error that said warning ... failed to open file: includes/usermain/successpage.php</fieldset>.

 

The reason I am trying to use the include file instead of just inserting the line or image is because, I would rather change the include file (along with conditionals) to reflect any changes or alerts, instead of going back through this major main file and doing it.

 

So, my question is... how can I successfuly use include in the above status message?

 

TIA for any help or guidance you can give! :)

Link to comment
Share on other sites

Thank you for your response, Jessica!! :)

 

So I figured out that if I create a variable with the include(); file I can concatenate it to the string like so:

 

$successP = include("includes/usermain/successpage.php");

$statusMessage = "<fieldset style=\"margin-left:20px;\"><img src=\"dImages/success.gif\"> <font color=\"#CC0000\" size=\"3\"><b>Success!</b></font><br>Your file, <b>". $_FILES['bulletinFile']['name'] ."</b>, was successfully uploaded. Please use the form below if you need to upload another file.<br />". $successP ."<br /> </fieldset>"; 

 

Now, the only issue is that the information inside of the includes file shows up above the fieldset. How can I get it to show up inside of the fieldset?

Edited by kjetterman
Link to comment
Share on other sites

What are you doing with $statusMessage?

 

Have you looked into using a templating system like Smarty?

 

Basically, the system was built before I arrived. It's an older system that has been hacked and cobbled together to work. I am working with it while I build out the new site (I will keep Smarty in mind!! Thank you for the tip!)

 

When a file is submitted, a status message or one of the $statusMessage variables will say something like "Your file, [file name] was successfully uploaded!" else, "Error! Your file didn't upload", etc.

 

What I am trying to do ... is add an additional message (only upon successful file upload) from time to time when I need to alert people of important changes or announcements. This is to catch the folks who happen to somehow slip through the cracks and bypass the index page of their member area and go straight to the upload page.

Link to comment
Share on other sites

You should put the processing for testing if there is an important message in your main header file. That way it doesn't matter WHAT page they view first, it will be in the same spot (like at the top of the page). For example I am doing a project in CakePHP right now and my layout template looks like this:

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php echo $this->Html->charset(); ?>
<title>
	<?php echo $title_for_layout; ?>
</title>
//snip...
</head>
<body>
<div id="container">
	<div id="header">
			//snip...
	</div>
	<div id="content">
		<?php echo $this->Session->flash(); ?>

// etc etc etc 

 

This is specific to CakePHP but the <?php echo $this->Session->flash(); ?> is where any important message flashes onto the screen in bright colors, then fades to grey and stays visible. 

 

 

Does your application have a main file for the header of the page?

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.