Jump to content

Recommended Posts

Okay, so my code is (currently) as follows:

 

<? if($_GET['page'] == "startTime"){

if(isset($_POST['newTime'])){
	$unix = mktime(0, 0, 0, 1, 1, $_POST['year']);
	echo ('<script>
		function closeFB() {
		$("#startTimeDiv").html("<div id="message"></div>");
		$("#message").html("<p>X</p>")
		.append("<p>X<br><? echo $unix; ?></p>");
		$.fancybox.close(); 
		}
		</script>');
	echo '<script type="text/javascript">'
 	   , 'closeFB();'
 	   , '</script>';
}
?>

Then there's a whole big table which ends with:

	<td colspan="2" align="center"><br /><input class="czas" type="submit" name="newTime" value="Set Start Time" /></td></tr>
   </form>
  </table>
</div>
<? die(); } ?>

Okay, so what I want is the user to be able to put in a custom time (in the above code, only the year is currently customizable, that will be expanded when I figure out how to get the year to work).

 

The user inputs the year, which in the form corresponds with the PHP $_POST['year']. So, what I want is for the use to input the year, and when on submit, $_POST['year'] to then contain a number, to then include the mktime function, to then echo the javascript function which also has a php echo of the mktime output, and then to call the javascript function.

 

Every time I include the JS function inside the webpage, instead of what I'm trying to do here and echo it (load it) at the proper time, it pre-runs through mktime and since mktime does not contain a year value until submit, it doesn't work properly. But, when I do it like I've done it and echo JS after the submit button is clicked, the JS function apparently is not working.

 

Any ideas?

 

Struggling with server-side vs client-side to know what I'm doing right/wrong...

That doesn't work either. I'm approaching day 4 working on solving this, getting a little frustrated.

 

When I tried this, it didn't work at all:

 

 if($_GET['page'] == "startTime"){
 if(isset($_POST['newTime'])){
echo '<script>window.location = "anyPage.php"</script>';}?>

Don't know why. Even if I move the isset to the top of the page, before the if($_GET, it still doesn't work.

 

The last time ANYTHING worked properly, it was:

 

<? if($_GET['page'] == "startTime"){?>
<script>
	function closeFB() {
	<? $unix = mktime(0, 0, 0, 1, 1, $_POST['year']); ?>
	$("#startTimeDiv").html("<div id='message'></div>");
	$("#message").html("<p>X</p>")
	.append("<p>X<br><? echo $unix; ?></p>");
	$.fancybox.close(); 
	}
	</script>

With the submit button as follows:

   <tr>
	<td colspan="2" align="center"><br /><input class="czas" type="submit" onClick="closeFB();" name="newTime" value="Set Start Time" /></td></tr>
   </form>
  </table>
</div>
<? die(); } ?>

And when that ran, it returns a unix timstamp of 946702800, where if I change it to mktime(0, 0, 0, 1, 1, 2015);, it returns 1420092000, which is proper. But, with the former, when I view the source code on the page (before I hit any buttons), and click the link in the source code (via FF) to the anyPage.php?page=startTime, I see:

<script>
	function closeFB() {
		$("#startTimeDiv").html("<div id='message'></div>");
	$("#message").html("<p>Contact Form Submitted!</p>")
	.append("<p>We will be in touch soon.<br>946702800</p>");
	$.fancybox.close(); 
	}
	</script>

The JS ran before the input field had a chance to be inputted and before the button could have been pressed. I know I could make the input field into a JS variable, but that puts me back to square one with how to then pass the JS variable to the PHP mktime function, since it would have to be done before the JS ran.

 

And as stated above, your input, which probably will help eventually, did not solve my problem...but it may be a start to solving my problem.

Notice: Use of undefined constant F - assumed 'F' in /home/..../public_html/...../X.php on line 18

Notice: Use of undefined constant d - assumed 'd' in /home/..../public_html/...../X.php on line 18

Notice: Use of undefined constant Y - assumed 'Y' in /home/..../public_html/...../X.php on line 18

Notice: Use of undefined constant g - assumed 'g' in /home/..../public_html/...../X.php on line 18

Notice: Use of undefined constant i - assumed 'i' in /home/..../public_html/...../X.php on line 18

Notice: Use of undefined constant sa - assumed 'sa' in /home/..../public_html/...../X.php on line 18

Notice: Undefined variable: scheduled in /home/..../public_html/...../X.php on line 24

Notice: Undefined index: page in /home/..../public_html/...../X.php on line 58

Notice: Undefined index: page in /home/..../public_html/...../X.php on line 68

Notice: Undefined index: page in /home/..../public_html/...../X.php on line 79

 

Line 18: $time = date(F." ".d.", ".Y." ".g.":".i.":".sa,time());
Line 24: $scheduled .= "<span style='color:#FF0000'>F</span>";}

Line 58: <?  if($_GET['page'] != "startTime"){ ?>

Line 68: <? if($_GET['page'] == "ajax"){?>

Line 79: if($_GET['page'] == "startTime"){?>

 

Nothing of this, as far as I can tell, deals with the JS. However, I'm not sure why any of those lines are throwing (secret) errors.

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.