Jump to content

Is this right or is there a better way?


Lucky2710

Recommended Posts

I've got a php script that I'm using to process a form. When the script finishes I want the screen to go back to the home page of the website once its done processing the form through the script. So ive got this code as the very last two lines of my script.

 

$URL="http://sports.nodinelandscaping.com/phplogin_v2.3/Home.php";
header ("Location: $URL")

 

The script is doing everything it's supposed to do except this.

It's just stopping on a plain white page which aint gonna work!

 

Maybe i cant see the trees for the forest but if yall see something wrong or have a better way of doing this please tell me.

Link to comment
Share on other sites

You're missing a ; which should be throwing an error, if you have error reporting turned too low so that this error isn't displayed you'll see a white page. For development purposes you should always have error reporting turned on all the way:

 

error_reporting(E_ALL);

 

You should try:

 

$URL="http://sports.nodinelandscaping.com/phplogin_v2.3/Home.php";
header ("Location: $URL");
exit;

 

After a header redirect you should always call exit so that processing is stopped.

Link to comment
Share on other sites

<?php
error_reporting(E_ALL);
?>
<?php 
include 'dbc.php';
page_protect();
?>
<?php
$userid = $_SESSION['user_id'];
?>
<?php
$date=("now");
if ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('6 September 2010')){

//Week 1------------------------------------------------------------------------------------------------
if ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('2 September 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk1_acc_Florida A&M at Miami (FL)');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk1_acc_Presbyterian at Wake Forest');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk1_acc_Samford at Florida State');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk1_acc_South Carolina State at Georgia Tech');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk1_acc_Weber State at Boston College');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk1_acc_North Texas at Clemson');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk1_acc_Western Carolina at North Carolina State');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk1_acc_Richmond at Virginia');
$game9 = $_POST[game9];
$game9DB = ('cfb_wk1_acc_Elon at Duke');
$game10 = $_POST[game10];
$game10DB = ('cfb_wk1_acc_LSU vs. North Carolina');
$game11 = $_POST[game11];
$game11DB = ('cfb_wk1_acc_Navy vs. Maryland');
$game12 = $_POST[game12];
$game12DB = ('cfb_wk1_acc_Boise State vs. Virginia Tech');
}
elseif ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('4 September 2010')){
$game3 = $_POST[game3];
$game3DB = ('cfb_wk1_acc_Samford at Florida State');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk1_acc_South Carolina State at Georgia Tech');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk1_acc_Weber State at Boston College');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk1_acc_North Texas at Clemson');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk1_acc_Western Carolina at North Carolina State');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk1_acc_Richmond at Virginia');
$game9 = $_POST[game9];
$game9DB = ('cfb_wk1_acc_Elon at Duke');
$game10 = $_POST[game10];
$game10DB = ('cfb_wk1_acc_LSU vs. North Carolina');
$game11 = $_POST[game11];
$game11DB = ('cfb_wk1_acc_Navy vs. Maryland');
$game12 = $_POST[game12];
$game12DB = ('cfb_wk1_acc_Boise State vs. Virginia Tech');
}
elseif ( strtotime($date) > strtotime('18 July 2010') && strtotime($date) < strtotime('6 September 2010')){
$game11 = $_POST[game11];
$game11DB = ('cfb_wk1_acc_Navy vs. Maryland');
$game12 = $_POST[game12];
$game12DB = ('cfb_wk1_acc_Boise State vs. Virginia Tech');
} 
else{
}

}

//Week 2---------------------------------------------------------------------------------------------

elseif ( strtotime($date) > strtotime('6 September 2010') && strtotime($date) < strtotime('11 September 2010')){

if ( strtotime($date) > strtotime('6 September 2010') && strtotime($date) < strtotime('11 September 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk2_acc_Duke at Wake Forest');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk2_acc_Georgia Tech at Kansas');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk2_acc_James Madison at Virginia Tech');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk2_acc_Kent State at Boston College');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk2_acc_Florida State at Oklahoma');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk2_acc_Presbyterian at Clemson');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk2_acc_Miami (FL) at Ohio State');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk2_acc_Morgan State at Maryland');
$game9 = $_POST[game9];
$game9DB = ('cfb_wk2_acc_North Carolina State at UCF');
$game10 = $_POST[game10];
$game10DB = ('cfb_wk2_acc_Virginia at USC');
} 
else{
}

}
//Week 3 ----------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('11 September 2010') && strtotime($date) < strtotime('18 September 2010')){

if ( strtotime($date) > strtotime('11 September 2010') && strtotime($date) < strtotime('16 September 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk3_acc_Cincinnati at North Carolina State');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk3_acc_Georgia Tech at North Carolina');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk3_acc_Maryland at West Virginia');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk3_acc_East Carolina at Virginia Tech');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk3_acc_Brigham Young at Florida State');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk3_acc_Alabama at Duke');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk3_acc_Clemson at Auburn');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk3_acc_Wake Forest at Stanford');
}
elseif ( strtotime($date) > strtotime('11 September 2010') && strtotime($date) < strtotime('18 September 2010')){
$game2DB = ('cfb_wk3_acc_Georgia Tech at North Carolina');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk3_acc_Maryland at West Virginia');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk3_acc_East Carolina at Virginia Tech');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk3_acc_Brigham Young at Florida State');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk3_acc_Alabama at Duke');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk3_acc_Clemson at Auburn');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk3_acc_Wake Forest at Stanford');
} 
else{
}

}
//Week 4 ----------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('18 September 2010') && strtotime($date) < strtotime('25 September 2010')){

if ( strtotime($date) > strtotime('18 September 2010') && strtotime($date) < strtotime('23 September 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk4_acc_Miami (FL) at Pittsburgh');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk4_acc_Wake Forest at Florida State');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk4_acc_North Carolina State at Georgia Tech');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk4_acc_Virginia Tech at Boston College');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk4_acc_FIU at Maryland');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk4_acc_Army at Duke');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk4_acc_North Carolina at Rutgers');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk4_acc_Virginia Military Institute at Virginia');
}
elseif ( strtotime($date) > strtotime('18 September 2010') && strtotime($date) < strtotime('25 September 2010')){
$game2 = $_POST[game2];
$game2DB = ('cfb_wk4_acc_Wake Forest at Florida State');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk4_acc_North Carolina State at Georgia Tech');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk4_acc_Virginia Tech at Boston College');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk4_acc_FIU at Maryland');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk4_acc_Army at Duke');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk4_acc_North Carolina at Rutgers');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk4_acc_Virginia Military Institute at Virginia');
} 
else{
}

}
//Weeek 5-------------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('25 September 2010') && strtotime($date) < strtotime('2 October 2010')){

if ( strtotime($date) > strtotime('25 September 2010') && strtotime($date) < strtotime('2 October 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk5_acc_Notre Dame at Boston College');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk5_acc_Duke at Maryland');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk5_acc_Virginia Tech at North Carolina State');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk5_acc_East Carolina at North Carolina');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk5_acc_Georgia Tech at Wake Forest');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk5_acc_Miami (FL) at Clemson');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk5_acc_Florida State at Virginia');
} 
else{
}

}
//Week6---------------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('2 October 2010') && strtotime($date) < strtotime('9 October 2010')){

if ( strtotime($date) > strtotime('2 October 2010') && strtotime($date) < strtotime('9 October 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk6_acc_Virginia at Georgia Tech');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk6_acc_Boston College at North Carolina State');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk6_acc_Clemson at North Carolina');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk6_acc_Navy at Wake Forest');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk6_acc_Florida State at Miami (FL)');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk6_acc_Central Michigan at Virginia Tech');
} 
else{
}

}
//Week 7------------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('9 October 2010') && strtotime($date) < strtotime('16 October 2010')){

if ( strtotime($date) > strtotime('9 October 2010') && strtotime($date) < strtotime('16 October 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk7_acc_Boston College at Florida State');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk7_acc_Middle Tennessee at Georgia Tech');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk7_acc_Miami (FL) at Duke');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk7_acc_North Carolina State at East Carolina');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk7_acc_Maryland at Clemson');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk7_acc_North Carolina at Virginia');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk7_acc_Wake Forest at Virginia Tech');
} 
else{
}

}
//Week 8-------------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('16 October 2010') && strtotime($date) < strtotime('28 October 2010')){

if ( strtotime($date) > strtotime('16 October 2010') && strtotime($date) < strtotime('23 October 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk8_acc_Maryland at Boston College');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk8_acc_Georgia Tech at Clemson');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk8_acc_Eastern Michigan at Virginia');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk8_acc_Duke at Virginia Tech');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk8_acc_North Carolina at Miami (FL)');
} 
else{
}

}
//Week 9------------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('23 October 2010') && strtotime($date) < strtotime('30 October 2010')){

if ( strtotime($date) > strtotime('23 October 2010') && strtotime($date) < strtotime('28 October 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk9_acc_Florida State at North Carolina State');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk9_acc_Clemson at Boston College');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk9_acc_Wake Forest at Maryland');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk9_acc_William & Mary at North Carolina');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk9_acc_Miami (FL) at Virginia');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk9_acc_Duke at Navy');
}
elseif ( strtotime($date) > strtotime('23 October 2010') && strtotime($date) < strtotime('30 October 2010')){
$game2 = $_POST[game2];
$game2DB = ('cfb_wk9_acc_Clemson at Boston College');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk9_acc_Wake Forest at Maryland');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk9_acc_William & Mary at North Carolina');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk9_acc_Miami (FL) at Virginia');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk9_acc_Duke at Navy');
} 
else{
}

}
//Week 10-----------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('30 October 2010') && strtotime($date) < strtotime('6 November 2010')){

if ( strtotime($date) > strtotime('30 October 2010') && strtotime($date) < strtotime('4 November 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk10_acc_Georgia Tech at Virginia Tech');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk10_acc_North Carolina at Florida State');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk10_acc_Virginia at Duke');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk10_acc_Boston College at Wake Forest');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk10_acc_North Carolina State at Clemson');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk10_acc_Maryland at Miami (FL)');
}
elseif ( strtotime($date) > strtotime('30 October 2010') && strtotime($date) < strtotime('6 November 2010')){
$game2 = $_POST[game2];
$game2DB = ('cfb_wk10_acc_North Carolina at Florida State');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk10_acc_Virginia at Duke');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk10_acc_Boston College at Wake Forest');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk10_acc_North Carolina State at Clemson');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk10_acc_Maryland at Miami (FL)');
} 
else{
}

}
//Week 11-----------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('6 November 2010') && strtotime($date) < strtotime('13 November 2010')){

if ( strtotime($date) > strtotime('6 November 2010') && strtotime($date) < strtotime('13 November 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk11_acc_Clemson at Florida State');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk11_acc_Miami (FL) at Georgia Tech');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk11_acc_Boston College at Duke');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk11_acc_Wake Forest at North Carolina State');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk11_acc_Virginia Tech at North Carolina');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk11_acc_Maryland at Virginia');
} 
else{
}

}
//Week 12------------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('13 November 2010') && strtotime($date) < strtotime('20 November 2010')){

if ( strtotime($date) > strtotime('13 November 2010') && strtotime($date) < strtotime('20 November 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk12_acc_Duke at Georgia Tech');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk12_acc_Virginia at Boston College');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk12_acc_Florida State at Maryland');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk12_acc_North Carolina State at North Carolina');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk12_acc_Clemson at Wake Forest');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk12_acc_Virginia Tech at Miami (FL)');
} 
else{
}

}
//Week 13-----------------------------------------------------------------------------------------------
elseif ( strtotime($date) > strtotime('20 November 2010') && strtotime($date) < strtotime('27 November 2010')){

if ( strtotime($date) > strtotime('20 November 2010') && strtotime($date) < strtotime('27 November 2010')){
$game1 = $_POST[game1];
$game1DB = ('cfb_wk13_acc_Florida at Florida State');
$game2 = $_POST[game2];
$game2DB = ('cfb_wk13_acc_Georgia Tech at Georgia');
$game3 = $_POST[game3];
$game3DB = ('cfb_wk13_acc_North Carolina State at Maryland');
$game4 = $_POST[game4];
$game4DB = ('cfb_wk13_acc_North Carolina at Duke');
$game5 = $_POST[game5];
$game5DB = ('cfb_wk13_acc_Boston College at Syracuse');
$game6 = $_POST[game6];
$game6DB = ('cfb_wk13_acc_South Carolina at Clemson');
$game7 = $_POST[game7];
$game7DB = ('cfb_wk13_acc_Wake Forest at Vanderbilt');
$game8 = $_POST[game8];
$game8DB = ('cfb_wk13_acc_Virginia at Virginia Tech');
$game9 = $_POST[game9];
$game9DB = ('cfb_wk13_acc_South Florida at Miami (FL)');
} 
else{
}

}

else{
}

?>

<?php
mysql_connect ("localhost","user","pass");
mysql_select_db ("sports");

$query = "UPDATE users SET 
`$game1DB`='$game1',
`$game2DB`='$game2', 
`$game3DB`='$game3',
`$game4DB`='$game4',
`$game5DB`='$game5',
`$game6DB`='$game6',
`$game7DB`='$game7',
`$game8DB`='$game8',
`$game9DB`='$game9',
`$game10DB`='$game10',
`$game11DB`='$game11',
`$game12DB`='$game12'
WHERE id = '$userid'"; 

mysql_query ($query);
mysql_close();

$URL="http://sports.nodinelandscaping.com/phplogin_v2.3/Home.php";
header ("Location: $URL");
exit();
?>

Link to comment
Share on other sites

I've tested the script excluding the update query and it worked fine. Try this separately:

 

<?php
$URL="http://sports.nodinelandscaping.com/phplogin_v2.3/Home.php";
header ("Location: $URL");
exit();
?>

 

And see if it works for you.

Link to comment
Share on other sites

I changed the bottom code to

WHERE id = '$userid'"; 

mysql_query ($query);
mysql_close();
?>
<?php
$URL="http://sports.nodinelandscaping.com/phplogin_v2.3/Home.php";
header ("Location: $URL");
exit();
?>

And it still aint workin. But if i put

<?php
$URL="http://sports.nodinelandscaping.com/phplogin_v2.3/Home.php";
header ("Location: $URL");
exit();
?>

in by itself it works! So I dont know??? :confused:

 

 

 

There has to be a way to get this workin!

Or Some other way.

Link to comment
Share on other sites

Original

$game8DB = ('cfb_wk13_acc_Virginia at Virginia Tech');
$game9 = $_POST[game9];
$game9DB = ('cfb_wk13_acc_South Florida at Miami (FL)');
} 
else{
}

}

else{
}

?> //I GOT RID OF THIS

<?php   //AND I GOT RID OF THIS

mysql_connect ("localhost","user","pass");
mysql_select_db ("sports");

$query = "UPDATE users SET 
`$game1DB`='$game1',
`$game2DB`='$game2', 
`$game3DB`='$game3',
`$game4DB`='$game4',

 

I just got rid of it being separate and what do you know it worked!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.