473,699 Members | 2,801 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

PHP remove previous output

1 New Member
Hi all!
I'm newbie on php. On the web site i'm developing, i have encoutered a problem that i can't resolve.
I have a script that makes the file upload, and then, based on the upload, it displays a message on another .php file. (success, or invalid file). When a user uploads a file, and a "success" message is displayed, when the same user uploads another file and it is displayd a error message, this error message appears under the previous "echo" success message...
I want that when a user makes a success upload, if the next upload displays an error message, that message appears in the same page as the previous one, but without the previous "success" message that appeared.

Here is my upload.php and success.php scripts:
########upload. php############ ##
session_start() ;
$temp_upload="t emp_upload/";
/*$server="local host";
$user="root";
$password="";
$db="teste";
$con=mysql_conn ect($server, $user, $password);
if(!$con)
{
die('Could not connect:'.mysql _error());
}
else{
$descricao=$_PO ST["descriptio n"];
$query="INSERT INTO files(descripti on) VALUES('$descri ption')";
mysql_query($qu ery);
mysql_close();
*/
$filename=$HTTP _POST_FILES['userfile']['name'];
$filetype=$HTTP _POST_FILES['userfile']['type'];
$filesize=$HTTP _POST_FILES['userfile']['size'];

if ( ($filetype=="ap plication/msword") || ($filetype=="te xt/plain") || ($filetype=="ap plication/pdf") && ($filesize<1000 000)) {
if ( (move_uploaded_ file($HTTP_POST _FILES['userfile']['tmp_name'], "temp_uploa d/".$HTTP_POST_FI LES['userfile']['name']))){
$_SESSION["upload"]=1;
header("Locatio n:success.php") ;
}
else{
$_SESSION["upload"]=2;
header("Locatio n:success.php") ;
}
}
else{
$_SESSION["upload"]=3;
header("Locatio n:success.php") ;
}
?>
############### #######

#######success. php############ ###
<?php
session_start() ;
echo"Sessão Iniciada como: ".$_SESSION["login"];
?>
<html>
<head>
<title>Untitl ed Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<p></p>
<p></p>
<p></p>
<label><b>FIL E UPLOAD</b></label>
<p></p>
<table>
<form id="form" name="form" method="post" action="upload. php" enctype="multip art/form-data">
<tr>
<td><label for="descriptio n">document description</label></td>

<td><input name="descripti on" type="text" id="description "/></td>
</tr>
<tr><td><labe l for="file">Choo se File</label><td><inpu t name="userfile" type="file"></td>
<tr><td></td>
<td><input type="submit" value="Enviar">
</td>
</tr>

</form>
</table>

<label><?php if(($_SESSION["upload_success "]=1))
echo"<b>File was succefully uploaded</b>";
if(($_SESSION["upload_success "]=2))
echo"<b>Error while uploading the file</b>";
if(($_SESSION["upload_success "]=3))
echo"<b>Invalid File</b>";

?>

</label>



</body>
</html>

############### #######
May 2 '07 #1
0 1330

Sign in to post your reply or Sign up for a free account.

Similar topics

3
13932
by: Newgene | last post by:
Hi, group, May I ask a newbie question? Given the below example: for i in range(100): print "%s%%" % i I want to show the progress by print 1% to 100%. But I hope each output will clear the previous output before print, so that I can see a
5
53309
by: KC | last post by:
Hello I installed MySQL ver 4.0.20d on a Windows XP Professional PC. I created a user and database that I would like to delete, and at this point I would just like to uninstall MySQL and do a fresh installation. I have deleted MySQL by going to Start > Settings > Control Panel > Add or Remove Programs. However, when I reinstall MySQL, the previous user and database are restored, too. How does one do a complete removal of MySQL so...
1
7540
by: Steve S | last post by:
I need some help modifying this code. The code was orginally setup to add/remove a single table row. I modified it to add 2 (two) rows with one column that spans both rows. That part works. I just need help with the removerow function. Thanks for any help you can offer me. Here is the code: <html> <head> <title>New Document</title> <script type="text/javascript">
2
2538
by: koperenkogel | last post by:
Dear cpp-ians, I am writing code for a image segmentation program. For this purpose I want to make a list (or array) of all pixels and take a random pixel out of the list. Once the pixel is handled, I want to remove it from the list and take again a random pixel out of the new list (with the previous pixel removed). I have an image of 1450 x 1650 pixels. Every pixel is a pointer to a structure:
2
1352
by: Johm | last post by:
I need some help in finding a way to remove the filter from the previous command. I open the report from a form where i have option group called Office.Depending on the option in the option group,the record source in the report is filtered for this option. In the OnOpen event of the report i have : Public town As Long town = Forms!!
3
2653
by: Markus | last post by:
Hi! I wanted to select a subset of nodes (list = selectNodes("parent/child") from a XmlDocument, then remove all (parentNode.removeAll();) child-nodes and insert the previous selected nodes back. Of course the XmlNodes in the nodelist ref. where lost once the removeAll() were executed, this is expected. So the obvious way to achive the result would be to clone the nodes or remove the nodes not qualifying the Xpath.
4
9826
by: eksamor | last post by:
I have a simple linked list: struct element { struct element *next; int start; }; struct list { struct element *head;
10
1669
by: Hermann.Richter | last post by:
Is there any way to remove automatically all blank chars from the html sent to the client?? Example: ---------------------------------------------------------------- <? echo "HTML tags here<br>" ; ?> more HTML here <div>
37
19188
by: bahoo | last post by:
Hi, I have a list like and as output I want If I myList.remove('0024') then only the first instance of '0024' is removed.
0
8686
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9033
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8911
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6533
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5872
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4627
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3057
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2345
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2009
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.