kjetterman Posted January 21, 2013 Share Posted January 21, 2013 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! Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2013 Share Posted January 21, 2013 You cannot use include and concatenate it to a string. Quote Link to comment Share on other sites More sharing options...
kjetterman Posted January 21, 2013 Author Share Posted January 21, 2013 (edited) 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 January 21, 2013 by kjetterman Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2013 Share Posted January 21, 2013 I have to say you are really going about this all wrong. Quote Link to comment Share on other sites More sharing options...
kjetterman Posted January 21, 2013 Author Share Posted January 21, 2013 (edited) I have to say you are really going about this all wrong. I am open to suggestions or further direction. So... what is the right way to go about doing this? Edited January 21, 2013 by kjetterman Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2013 Share Posted January 21, 2013 What are you doing with $statusMessage? Have you looked into using a templating system like Smarty? Quote Link to comment Share on other sites More sharing options...
kjetterman Posted January 21, 2013 Author Share Posted January 21, 2013 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2013 Share Posted January 21, 2013 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.