| | |
ugh! One Page, 2 re-loads (page request i guess)
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
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
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
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*)
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
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!
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
![]() |
Similar Threads
- Slow Page Loads in IE (Viruses, Spyware and other Nasties)
- Displaying data on same page without reloading page. (JavaScript / DHTML / AJAX)
- How do i set a page as a Home Page (HTML and CSS)
- page.php?page=1,2,3,4,..inf. (PHP)
Other Threads in the PHP Forum
- Previous Thread: Php Mysql Image Question
- Next Thread: New Project - First One - Need Help!
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





