6 Replies - 7413 Views - Last Post: 10 December 2008 - 02:24 PM Rate Topic: -----

#1 jamiet757  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-December 08

Redirect Loop with PHP Script

Posted 10 December 2008 - 07:02 AM

I have a PHP script that I recently moved from one host to another host. When I moved it, it stopped working correctly. Whenever I click Sign Up, Create Project, Manage Account, or Sign Out, it gives me a redirect error, stating that the page is redirecting in a way that will never complete. Here is the website so you can see it youself:
www.greensfear.com

The problem files are:
freelancers.php
webmasters.php
index.php (an admin page)

Here is the code for the admin index.php page that I think is causing the problem:

<?

if (!$pass) {
echo '<center>
  <form action="index.php" method="post">
	Password: <input type="password" name="pass"> <input type="submit" value="Login">
  </form>
<br><br>
</center>';
} else if ($pass !== $adminpass) {
echo '<center>Password Incorrect!<br><br>
<form action="index.php" method="post">
	Password: <input type="password" name="pass"> <input type="submit" value="Login">
  </form>
</center>';
} else if ($adminpass == "") {
echo '<center>
  <a href="index.php">index.php</a> will not run until the required variables are setup in <a href="admin_setup.php">admin_setup.php</a><br>
  <a href="admin_setup.php">Click here</a> to setup the required variables now.
</center>';


The code for the other 2 files is over 2000 lines long, so I will not post them here unless someone wants me to specifically. I am not sure which part is causing the problem.

If someone could give me an idea of what to look for, or solve the problem with the index file, maybe I could find the part and post it.

Any help is greatly appreciated!

This post has been edited by jamiet757: 10 December 2008 - 07:06 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Redirect Loop with PHP Script

#2 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2993
  • View blog
  • Posts: 10,347
  • Joined: 08-August 08

Re: Redirect Loop with PHP Script

Posted 10 December 2008 - 07:35 AM

Are short tags enabled on the new server? If not, the <? will cause problems.

You're missing a brace at the end of your snippet.
Was This Post Helpful? 0
  • +
  • -

#3 jamiet757  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-December 08

Re: Redirect Loop with PHP Script

Posted 10 December 2008 - 07:40 AM

View PostCTphpnwb, on 10 Dec, 2008 - 06:35 AM, said:

Are short tags enabled on the new server? If not, the <? will cause problems.

You're missing a brace at the end of your snippet.


Yes I know the brace is missing, I just took a random section of the code, there was a lot more after that, but I thought this was the section that was causing it.

How do I enable short tags?
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2993
  • View blog
  • Posts: 10,347
  • Joined: 08-August 08

Re: Redirect Loop with PHP Script

Posted 10 December 2008 - 08:10 AM

View Postjamiet757, on 10 Dec, 2008 - 06:40 AM, said:

How do I enable short tags?

From my php.ini file, located in /usr/local/php5/lib on my system.
; Allow the <? tag.  Otherwise, only <?php and <script> tags are recognized.
; NOTE: Using short tags should be avoided when developing applications or
; libraries that are meant for redistribution, or deployment on PHP
; servers which are not under your control, because short tags may not
; be supported on the target server. For portable, redistributable code,
; be sure not to use short tags.
short_open_tag = Off


This post has been edited by CTphpnwb: 10 December 2008 - 08:10 AM

Was This Post Helpful? 0
  • +
  • -

#5 William_Wilson  Icon User is offline

  • lost in compilation
  • member icon

Reputation: 205
  • View blog
  • Posts: 4,807
  • Joined: 23-December 05

Re: Redirect Loop with PHP Script

Posted 10 December 2008 - 08:22 AM

i've only ever seen this issue once. It was caused by including a file which used header information to redirect. Some how this generates the error that you are getting.

EDIT: I was able to recreate it, so hopefully it is the root of your problem. Basically the redirecting include (say redirect.php) is included in a page (say a.php). The redirect occurs and takes you to say b.php, the problem is b.php includes either redirect.php or a.php, thus there is a cycle of redirects.
Was This Post Helpful? 0
  • +
  • -

#6 jamiet757  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 10-December 08

Re: Redirect Loop with PHP Script

Posted 10 December 2008 - 02:11 PM

View PostWilliam_Wilson, on 10 Dec, 2008 - 07:22 AM, said:

i've only ever seen this issue once. It was caused by including a file which used header information to redirect. Some how this generates the error that you are getting.

EDIT: I was able to recreate it, so hopefully it is the root of your problem. Basically the redirecting include (say redirect.php) is included in a page (say a.php). The redirect occurs and takes you to say b.php, the problem is b.php includes either redirect.php or a.php, thus there is a cycle of redirects.


But the fact is that it was working perfectly with one host, but when I transfer it to the new host, it no longer works. I submitted a support ticket to see if they have any idea what is going on. It seems to me the problem is not necessarily with the site files, but with the host config
Was This Post Helpful? 0
  • +
  • -

#7 Hary  Icon User is offline

  • D.I.C Regular

Reputation: 44
  • View blog
  • Posts: 427
  • Joined: 23-September 08

Re: Redirect Loop with PHP Script

Posted 10 December 2008 - 02:24 PM

There is probably something worng with the error pages. If you have an custom 404 error page, that cannot be found, this occurs as well. (All 4xx and 5xx errors to be more specific)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1