ugh! One Page, 2 re-loads (page request i guess)

Reply

Join Date: May 2006
Posts: 7
Reputation: OrangeSunshine is an unknown quantity at this point 
Solved Threads: 0
OrangeSunshine's Avatar
OrangeSunshine OrangeSunshine is offline Offline
Newbie Poster

ugh! One Page, 2 re-loads (page request i guess)

 
0
  #1
May 14th, 2006
i guess i didn't really have to make this page load repeatedly like this (but, why should it matter, right? i mean.. technically, couldn't i get it to reload indefinietly?) but, i didn't want the user to be sent all over to different pages just to fill out this little scheduing form thing.

i see already from the PHP code coloring that i've got something seriously wrong right around my midsection

i've spent so much time on this alone already, i could really use a fresh pair of eyes. i realize i probably should have tried to debug that section... but... what can ya do.. thanks for reading!
[php]<?php
ob_start();
session_start();
// START. IF FLOW IS EMPTY SCRIPT HALTS. schedule.php IS DISPLAYED
if (empty($_POST['flow'])) {

if (isset($_SESSION['flow'] && $_SESSION['flow'] = "go")) {

if (isset($_POST['op']) && ($_POST['op'] == "makedate")) {
// make the timestamp
$day = $_POST['day'];
$month = $_POST['month'] + 1;
$m = $month;
$year = $_POST['year'];
$year = $year + 2005;
$mkhour = $_POST['hour'];
$mkmin = $_POST['min'];

$check = checkdate($m, $day, $year);
if ($check == 1) {

$newtime = date("M-d-Y \a\\t h:i a", mktime($mkhour, $mkmin, 0, $month, $day, $year));
$tstime = mktime($mkhour, $mkmin, 0, $month, $day, $year);
$dynadate = "<p>READY TO MAKE THE DATABASE QUERY and move on!!!</p>";
$ready = 1;

} elseif ($check == 0) {
$ready = 0;
$dynadate = "<p>You entered an invalid date! Please <a href=\"schedule.php\">try again</a>:</p>";

}

}

header("Location: url("schedule.php"));
exit;
}
else { // CHECK FOR ['OP'] WHICH IS SET AFTER TIME IS SELECTED
}


} else if (isset($_POST['flow']) && ($_POST['flow'] == "go")) {

$dynadate = "";
$_SESSION['flow'] = $_POST['flow'];

if (isset($newtime, $_POST['op'], $day, $m, $month, $year, $_POST['day'])) {
} else { // THE IF ISSET W/ OUT FLOW SWITCHING IS USED TO SET THE VARIABLES FOR DYNADATE PULL-DOWNS ? can see no other purpose
}

// BEGIN MAKING HTML FORM
$dynadate .= "<h3>Select the Date for your Big Day!</h3>
<p class=\"specialmsg\"><strong>STOP!</strong> Before entering this date... Thanks for your cooperation!</p>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">";



// MAKE MONTHS ARRAY
global $m;
$monthArray = array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August',
'September', 'October', 'November', 'December');
$dynadate .= "<select name=\"month\">";
for ($m = 0; $m < count($monthArray)+1; $m++){
$dynadate .= "<option value=\"$m\">$monthArray[$m]</option>";
if ($m == 11) {
break;
} else {

}
}
$dynadate .= "</select>";

// MAKE DAYS ARRAY
$dynadate .= "<select name=\"day\">";
for ($x = 0; $days = $x+1; $x++){

$dynadate .= "<option value=\"$days\">$days</option>";
if ($x==30) {
break;
}
}
$dynadate .= "</select>";

// MAKE YEARS ARRAY
$yearArray = array('2005', '2006', '2007', '2008', '2009', '2010');
$dynadate .= "<select name=\"year\">";
for ($y = 0; $y < count($yearArray)+1; $y++){
$dynadate .= "<option value=\"$y\">".$yearArray[$y]."</option>";
if ($y == 5) {
break;
} else {
$yearnum = $y;
}
}


$dynadate .= "</select>";

// BEGIN TIME SECTION
$dynadate .= "<p class=\"specialmsg\">What time ... that day.</p>";
$hours = 24;
$min_sec = 60;

$hour = '<select name="hour">';
for($i=0; $i<=$hours; $i++){
$hour .= '<option value="'.$i.'">'.date('h (a)', mktime($i,0,0,1,1,2000)).'</option>';
}
$hour .= '</select>';

$min = '<select name="min">';
for($i=0; $i<=$min_sec; $i++){
$min .= '<option value="'.$i.'">'.date('i', mktime(0,$i,0,1,1,2000)).'</option>';
}
$min .= '</select>';

$dynadate .= "$hour.$min";

// $_POST['op'] = makedate
$dynadate .= "<input type=\"hidden\" name=\"op\" value=\"makedate\"/>
<br /><input type=\"submit\" name=\"submit\" value=\"Enter Date\" /></form>";


} // END THE QUITE LENGTHY DATE-DROP-DOWN FORM THING
else {
header("Location: url("schedule.php"));
exit;
} echo $dynadate; {
}




?>
<html>stuff</html>
<?php

if empty($ready) {

echo $dynadate;
}

?>[/php]
by the way-- sorry to be that guy who comes in and posts a crack-load of code, lookin for answers the cheap and easy way. i welcome anyone w/ beginner to moderately complex inquiries to PM me if you need to get un-stuck from somwhere. as you can see from this code, i ain't that good, but i do know what a lot of it is supposed to do. heehee

EDIT: if this seems a little schizophrenic, it's because i chopped the date dropdown stuff right out of something i did about a year ago... there's one part in there, i was like... 'huh?'-- where the if isset(...) doesn't really do anything... i left it there cause i was being lazy-- thinking it was some BandAid i put over some other part which was poorly structured. the whole date thing is heavily influenced by helpers in another great forum.
My little collection of useful stuff... if you're a newb, or even someone just starting to get into CSS and XHTML, there might be something worth looking at in there
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 7
Reputation: OrangeSunshine is an unknown quantity at this point 
Solved Threads: 0
OrangeSunshine's Avatar
OrangeSunshine OrangeSunshine is offline Offline
Newbie Poster

Re: ugh! One Page, 2 re-loads (page request i guess)

 
0
  #2
May 14th, 2006
i see what's wrong w/ that middle part-- one too many else's in that if else expression! :O
probably because i was originally pulling the date part in via include (notice the html break near the bottom)... yes-- a schizo hodgepodge of messed up. this things got more cut and paste than a 2nd grade art class!

lemme check to see if that fixes it...
(*crosses fingers*)
My little collection of useful stuff... if you're a newb, or even someone just starting to get into CSS and XHTML, there might be something worth looking at in there
Reply With Quote Quick reply to this message  
Join Date: May 2006
Posts: 7
Reputation: OrangeSunshine is an unknown quantity at this point 
Solved Threads: 0
OrangeSunshine's Avatar
OrangeSunshine OrangeSunshine is offline Offline
Newbie Poster

Re: ugh! One Page, 2 re-loads (page request i guess)

 
0
  #3
May 15th, 2006
hey there-- i hope no one has bothered w/ this... i realized my errors

suddenly it occurred to me that i was getting a white screen every time, instead of the NOTICE and WARNING messages... here, something i installed must have modified my php.ini and i just realized it!
what a headache-- it's so much easier when you know which lines are messing up!!
doh!
My little collection of useful stuff... if you're a newb, or even someone just starting to get into CSS and XHTML, there might be something worth looking at in there
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the PHP Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC