Page 1 of 1

page doesn't redirect when using Mozilla

Posted: Sun Jan 30, 2005 12:05 pm
by suzie
I am working on an open source program to suit my own needs and I'm doing very well considering I hadn't heard of php three months ago. :D

I have one problem I can't figure out. This is a calendar where events are added, and can be changed or deleted. Whenever I add, change or delete an event, instead of being rerouted to the page I started at, I get a blank page. This only happens when using Mozilla, rerouting works fine when I use IE. After you look at the code, you'll see four different reroutes, the two without the session work, so I'm guessing the problem lies with the session? I haven't the slightest idea what to do with this. That is, if it can be fixed at all since it only seems to be a problem with Mozilla.

No error messages unless I try to use the back button or look at the source code. ("The page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out (such as search or online purchase) will be repeated. To resend the data, click ok. Otherwise, click cancel.")

I am trying to learn php but it's difficult since I dove in without learning how to swim first. So, I 'm asking for some hand holding first and as a last resort will ask for the code I need as a last resort.

This is the code for the reroute

Code: Select all

if (isset($fbid)) {
		if ($fbid=="eaddsuccess" && !$_SESSIONї"AUTH_ADMIN"]) {
			feedback(stripslashes(urldecode("The new event "$fbparam" has been submitted for approval.")),0);
			echo "<BR>";
		&#125;
		elseif ($fbid=="eupdatesuccess" && !$_SESSION&#1111;"AUTH_ADMIN"]) &#123;
			feedback(stripslashes(urldecode("The update for the event "$fbparam" has been submitted for approval.")),0);
			echo "<BR>";
		&#125;
		elseif ($fbid=="urlchangesuccess") &#123;
			feedback(stripslashes(urldecode("The address of your homepage was successfully changed to "$fbparam".")),0);
			echo "<BR>";
		&#125;
		elseif ($fbid=="emailchangesuccess") &#123;
			feedback(stripslashes(urldecode("Your email address was successfully changed to "$fbparam".")),0);
			echo "<BR>";
		&#125;
  &#125; // end: if ( isset($fbid) )
Thanks for any help.

Posted: Sun Jan 30, 2005 12:09 pm
by patrikG
The post you coded doesn't redirect. I suppose the function feedback() does the that. Could you post its code?

Posted: Sun Jan 30, 2005 12:53 pm
by suzie
Here's the function feedback:

Code: Select all

<?php
  $colorpast = "#eeeeee";
  $colortoday  = $_SESSION&#1111;"TODAYCOLOR"];
  $colorfuture = "#FFFFFF";
  $colorhelpbox = "#FFFFCC";
  $colorinputbox = "#FFFFFF";

  require_once("datecalc.inc.php");
  require_once("header.inc.php");
  require_once("email.inc.php");

  define("REGEXVALIDCOLOR","/^#&#1111;ABCDEFabcdef0-9]&#123;6,6&#125;$/");	
  define("BGCOLORNAVBARACTIVE","#993333");
  define("BGCOLORWEEKMONTHNAVBAR","#993333");
  define("BGCOLORDETAILSHEADER","#993333");
  define("MAXLENGTH_URL","100");
  define("MAXLENGTH_TITLE","40");
  define("MAXLENGTH_DESCRIPTION","5000");
  define("MAXLENGTH_LOCATION","100");
  define("MAXLENGTH_PRICE","100");
  define("MAXLENGTH_CONTACT_NAME","100");
  define("MAXLENGTH_CONTACT_PHONE","100");
  define("MAXLENGTH_CONTACT_EMAIL","100");
  define("MAXLENGTH_SPONSOR","50");
  define("FEEDBACKPOS","0");
  define("FEEDBACKNEG","1");

  $nopreview    = 0;
  $showpreview  = 1;

function getNewEventId() &#123;
  $random = rand(0,999);
  $id = time();
  if ($random<100) &#123;
    if ($random<10) &#123;
      $id .= "0";
    &#125;
    $id .= "0";
  &#125;
  return $id.$random;
&#125;

function feedback($msg,$type) &#123;
  echo '<span class="';
	if ($type==0) &#123; echo "feedbackpos"; &#125; // positive feedback
  if ($type==1) &#123; echo "feedbackneg"; &#125; // error message
  echo '">';
	echo $msg;
  echo '</span><br>';
&#125;

function redirect2URL($url) &#123;
  Header("Location: $url");
  return TRUE;
&#125; // end: Function redirect2URL($url)

// display login screen and errormsg (if exists)
function displaylogin($errormsg,$database) &#123;
  global $colorinputbox;

  pageheader("Where's The Auction Calendar, Login",
             "Login",
            "Update","",$database);
  echo "<BR>\n";
  box_begin("inputbox","You must be an authorized auctioneer<br> to add and maintain auctions<br> on the calendar.<br><br>
Please login.");

  if (!empty($errormsg)) &#123;
    echo "<BR>\n";
    feedback($errormsg,1);
  &#125;
?>
Here is some reroute code from another file. (If you need this whole file, I will post it but it's pretty long.)

Code: Select all

// reroute
      if (strpos($httpreferer,"update.php")) &#123;
        redirect2URL("update.php?fbid=eupdatesuccess&fbparam=".urlencode(stripslashes($event&#1111;'title'])));
        exit;    
			&#125;
      else &#123;
        $target = $httpreferer;
        if (isset($detailscaller)) &#123; $target .= "&detailscaller=".$detailscaller; &#125;
        redirect2URL($target);
				exit;
      &#125;
    &#125; // end: if (isset($eventid) && !isset($copy))
    else &#123; // insert as new event(s) or copy an event
      if (sizeof($repeatlist) > 0) &#123; // save multiple events
        $event&#1111;'repeatid'] = getNewEventId();
	      insertintorepeat($event&#1111;'repeatid'],$event,$repeat,$database);
	      insertrecurrences($event&#1111;'repeatid'],$event,$repeatlist,$database);
        $eventid = "";
      &#125;
      else &#123; // save just one event
        $event&#1111;'repeatid'] = ""; // no recurrences
		    $eventid = getNewEventId();
        insertintoevent($eventid,$event,$database);
      &#125;
      $event&#1111;'id'] = $eventid;

      // whatever the "admin" edits gets approved right away
      if ($_SESSION&#1111;"AUTH_ADMIN"]) &#123;
      	if (!empty($event&#1111;'repeatid'])) &#123; repeatpublicizeevent($eventid,$event,$database); &#125;
        else &#123; publicizeevent($eventid,$event,$database); &#125;
      &#125;

      // reroute
      if (strpos($httpreferer,"update.php")) &#123;
       redirect2URL("update.php?fbid=eaddsuccess&fbparam=".urlencode(stripslashes($event&#1111;'title'])));
        exit;
			&#125;
      else &#123;
        $target = $httpreferer;
        if (isset($detailscaller)) &#123; $target .= "&detailscaller=".$detailscaller; &#125;
        redirect2URL($target);
				exit;
      &#125;
    &#125;
  &#125; // end: if ((isset($saveall) || ...)

Posted: Sun Jan 30, 2005 1:32 pm
by patrikG
Function feedback() only prints out some message. To redirect, you'd need some function call to function redirect2url() - which is done in the second bit of code you've posted.

Maybe it's easier if you called it yourself instead of relying on that code. Just add a function call to redirect2url() and give a URL as parameter.

Posted: Sun Jan 30, 2005 3:15 pm
by timvw
relative uri for redirection is rather new (rfc 3986, jan 2005)

i believe firefox, mozilla etc don't support it (yet).
in ie it works already (let's say they implemented features for the future :p)

Posted: Mon Jan 31, 2005 11:03 pm
by suzie
The got the reroutes working by changing this:

Code: Select all

// reroute
      if (strpos($httpreferer,"update.php")) {
        redirect2URL("update.php?fbid=eupdatesuccess&fbparam=".urlencode(stripslashes($event['title'])));
        exit;    
			}
      else {
        $target = $httpreferer;
        if (isset($detailscaller)) { $target .= "&detailscaller=".$detailscaller; }
        redirect2URL($target);
				exit;
      }
to this:

Code: Select all

redirect2URL("update.php?fbid=eupdatesuccess&fbparam=".urlencode(stripslashes($event['title'])));
        exit;
There were three different instances of this code. Two work perfectly, but I still cannot get the feedback to show for the above example.

Do you see anything wrong with the code? (the feedback code is in my first post)

Thanks,
Suzie