473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

redirection after submission of page not working in ie 7

Hi,

I have a form which allows user to upload image. On submission of the form the data is inserted into the mysql database and image is copied into a directory. After this i try to redirect the user to the form which gives error in IE 7.This form works perfectly in Mozilla Fire Fox.

The form has one text box, file browse option and a submit button. The enctype of the form is set to multipart form data.

I really cannot why the IE 7 is giving error. Below is the message displayed by IE 7

Internet Explorer cannot display the webpage

Most likely causes:
You are not connected to the Internet.
The website is encountering problems.
There might be a typing error in the address.

What you can try:

Cany anyone help me.

Thanks

Harish
Jul 31 '09 #1
4 3289
Markus
6,050 Expert 4TB
No idea of what the error could be caused by without seeing the form markup.. so post it?
Jul 31 '09 #2
@Markus

Hi Markus,

Below is the form markup, followed by the PHP code file which is called on submission of the form.

Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3.  
  4. <title>www.jettoner.com - Admin Panel</title>
  5. <link href="../style.css" rel="stylesheet" type="text/css">
  6. <script type="text/javascript">
  7.  
  8.  
  9. function check()
  10. {
  11.  
  12.  
  13.          var ok=1;
  14.         if(isEmpty( document.myform.Category_Name.value ))
  15.         {
  16.             alert("Please enter Category Name");
  17.             document.myform.Category_Name.value = "";
  18.             document.myform.Category_Name.focus();
  19.  
  20.                 ok=0;
  21.             return false;
  22.         }
  23.  
  24.  
  25.         if(ok==1)
  26.         {
  27.  
  28.          document.myform.submit();    
  29.         }
  30.  
  31.  
  32. }
  33.  
  34. function isEmpty( str ){ 
  35.     var strRE = /^[\s ]*$/gi; 
  36.     return strRE.test( str ); 
  37.  
  38.  
  39. </script>
  40.  
  41. </head>
  42.  
  43. <body >
  44.  
  45. <table cellspacing="0" cellpadding="0" border="1" width="920" align="center" >
  46. <tr><td  height="40" class="mainheading">
  47. <?php getGIHeader(); ?>
  48.  
  49. </td></tr>
  50. <tr><td>
  51. <table width="99%" border="0">
  52. <tr><td width="10%" valign="top">
  53.  
  54. <? getGILeftPane(); ?>
  55.  
  56. </td>
  57. <td width="50%" align="center" valign="top">
  58.  
  59. <table cellspacing="0" cellpadding="0" border="0" width="95%" align="center" >
  60. <tr><td class="mainheading">
  61. Add Category
  62. <br><br>
  63. </td></tr>
  64. <tr><td>
  65. <!-- Data entry form starts here -->
  66. <form action='AddCategory1.php' method='post' name="myform" enctype="multipart/form-data"> 
  67. <table cellspacing="0" cellpadding="0" border="0" width="55%" align="left" >
  68. <tr><td colspan="2" class="messageHeading" height="30" align="center"> <?php echo $errorMessage;  ?></td></tr>
  69. <tr><td align="center" height="30">Category:</td><td><input type="text" name="Category_Name" value="<?php echo $row['Category_Name']; ?>"></td></tr>
  70. <tr><td align="center" height="30">Image:</td><td><input type="file" name="file1" ></td></tr>
  71. <tr><td></td><td><br><input type="Button" name="Submit" value="Submit" onClick=check()></td></tr>
  72. </table>
  73. <!-- Data entry form ends here -->
  74. </form>
  75. </td></tr>
  76. </table>
  77. </td>
  78. </tr>
  79. </table>
  80. </td></tr>
  81. </table>
  82.  
  83. </body>
  84.  
  85. </html>
PHP page that executes the code on submission of the form:

Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3. require_once('../includes/Common.php');
  4. require_once('../includes/DbConnector.php');
  5.  
  6. // Create an instance of DbConnector
  7.     $connector = new DbConnector();
  8.  
  9.  
  10.  
  11. // check whether category name exists, if yes redirect to the Add Category page
  12. $selStatement ="select * from Category where Category_Name='".$_POST["Category_Name"]."'";
  13.  
  14.     if (!($result = $connector->query($selStatement)))
  15.     {
  16.        $_SESSION["Message"] = "Error occured while processing the request!";
  17.        header("location:/salesdemo/management/Message.php");
  18.        exit;
  19.     }
  20.  
  21.     $RowCount = $connector->fetchNoOfRows($result);
  22.  
  23.  
  24. If($RowCount == 1)
  25. {
  26.         //echo "inside RowCount = $RowCount";
  27.     //exit;
  28.  
  29.     //  set up a $lastformVars array to store the previously entered data
  30.     $lastformVars = array();
  31.     $lastformVars["Category_Name"] = $_POST['Category_Name'];
  32.  
  33.  
  34.     // Save the array as a sesssion variable
  35.     $_SESSION["lastformVars"] = $lastformVars;
  36.  
  37.     // Store the $errors array as a session variable
  38.     $_SESSION["errors"] = $errors;
  39.  
  40.        $_SESSION["Message"] = "Category Name already exists!";
  41.             header("location:AddCategory.php");
  42.             exit;
  43.  
  44. }
  45. else
  46. {
  47. $uploaddir = "../CategoryImages"; 
  48. // The Upload Part
  49. if(is_uploaded_file($_FILES['file1']['tmp_name']))
  50. {
  51. //move_uploaded_file($_FILES['file1']['tmp_name'],$uploaddir.'/'.$_FILES['file']['name']);
  52. //$Cat_Image = $_FILES['file1']['name'];
  53. //print "Your file has been uploaded successfully! Yay!";
  54. //exit;
  55.  
  56. if(move_uploaded_file($_FILES['file1']['tmp_name'], $uploaddir.'/'.$_FILES['file1']['name'])) {
  57.    // echo "The file ".  basename( $_FILES['file1']['name']). 
  58.     " has been uploaded";
  59.     $Cat_Image = $_FILES['file1']['name'];
  60.  
  61. } else{
  62.     //echo "There was an error uploading the file, please try again!";
  63.     //echo $uploaddir.'\\'.$_FILES['file']['name'];
  64.     $Cat_Image = "";
  65.  
  66. }
  67.  
  68.  
  69.  
  70. } else {
  71. //print "Incorrect file extension!";
  72. $Cat_Image = "";
  73. }
  74.  
  75. // Create insert statement
  76. $statement ="insert into Category(Category_Name,Category_Image) values('".trim($_POST["Category_Name"])."','".$Cat_Image."') ";  
  77.                   // Save the form data into the database 
  78.                 //echo $statement;
  79.                 //exit;
  80.          if ($result = $connector->query($statement)){
  81.  
  82.              // It worked, give confirmation
  83.  
  84.             $_SESSION["Message"] = "Successfully added Category !";
  85.             //echo $_SESSION["Message"];
  86.             header('location:AddCategory.php');
  87.             exit;
  88.  
  89.         }else{
  90.  
  91.            // It hasn't worked so stop. Better error handling code would be good here!
  92.             $_SESSION["Message"] = "Error occured while adding Category !";
  93.             header("location:AddCategory.php");
  94.             exit;
  95.  
  96.         }
  97.  
  98.  
  99. }
  100.  
  101.  
  102. ?>
Aug 1 '09 #3
Enable output buffering for this script (will degrade performance) or replace header() redirect with a JS redirect.

Look up the php docs on header() for more info.
Aug 1 '09 #4
@unauthorized

Cannot enable output buffering because the php script is used only to add record to the mysql db and then redirect user again to the AddCategory.php page, Even if error occurs in AddCategory1.php script the user is redirected to the AddCategory.php page using header().
Aug 1 '09 #5

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

Similar topics

5
by: Joshua Beall | last post by:
Hi All, I do web design for some small organizations, and one of the sites I have set up takes online conference registrations. Now, most of the time it works. In fact, every time I try it, it...
8
by: CJM | last post by:
How do people go about preventing the user from submitting a form for a 2nd time? For example, the user submits a form, clicks on the back button, and the submits the form again. I have used...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
6
by: Oleg Konovalov | last post by:
Hi, I have a Java/JavaScript GUI application where I perform a lot of long DB operations , which takes 5-60 secs to perform. Sometimes user double-clicks the button or just gets impatient and...
3
by: Niall | last post by:
The short version: how does one get Javascript to abort a form submission/page load half way through? Long version: I have a page, the guts of which can be summarised as: <script>
8
by: integravtec | last post by:
Hey guys, I'm new here. Just had a question, so I want to thank you in advance for the help. I not too familiar with programming other languages than Html, dhtml, and javascript. So I figured there...
1
by: keigh | last post by:
Hi Everyone - I am trying to figure out how to create a hit counter that shows how many people have signed up for something. Specifically, we are asking people to "sign a pledge" on our website and...
2
by: dmorand | last post by:
I'm just seeing if there's a better way I can do this. I want to display the results from my submission page which handles adds, edits, deletes. I want to display the Name, Description, and Date...
2
by: jtime | last post by:
I recently inherited a page from a former coworker and am stuck with how to fix it. The webpage provides the user with a form that allows them to select from different criteria, and as the user...
7
by: khanishfaq82 | last post by:
This Script below works perfectly in firefox but fails to execute in Internet Explorer.Kindly copy and paste the script below to see it working.What i require is if i click 'MENU1' and it is still in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.