0
<?php 
//ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Cycle Tracks Portal - Validation Page</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
	<script language="javascript">
		redirTime = "5000"; 
		redirURL = "index.php"; 
		function redirTimer() {
			self.setTimeout("self.location.href redirURL;",redirTime);
		}
	</script> 
</head>

<body>
<?php
// connection to MySQL server
mysql_connect('localhost','root','');
mysql_select_db('administration');

// *** Validate request to login to this site.
//session_start();

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $loginPassword=$_POST['password']; 
  $MM_redirectLoginSuccess = "validated.php";
  $MM_redirectLoginFailed = "index.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db('administration');
  
	 if(empty($_POST['username']) && empty($_POST['password'])) {
  	 die('<div class="error_up">Both field was blank</div>
		<br><br><div class="footer_padding">
			&copy; Copyright Cycle Tracks <span>®</span></div>
			');
	 }
	 if(empty($_POST['username'])) {
  	 die('<div class="error_up">Username field was blank</div>
		<br><br><div class="footer_padding">
			&copy; Copyright Cycle Tracks <span>®</span></div>
			');
	 }
	 if(empty($_POST['password'])) {
  	 die('<div class="error_up">Password field was blank</div>
		<br><br><div class="footer_padding">
			&copy; Copyright Cycle Tracks <span>®</span></div>
			');
	 }
	
  $loginUsername = get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername);
  $password = get_magic_quotes_gpc() ? $password : addslashes($password);
  $LoginRS_query = "SELECT username, password FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  
  if ($loginFoundUser) {
    
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	}
  else {
    echo "redirTimer()";
}
}
?>

</body>
</html>
<?php 
//ob_end_flush(); 
?>

I know the way i call the function is wrong in line 68, how do i call the js function?

3
Contributors
22
Replies
23
Views
9 Years
Discussion Span
Last Post by nav33n
0

you can do it like what you have done in the 1st statement:

echo "<script type='text/javascript'>"
echo "redirTimer()";
echo "</script>";
0

maybe include the whole function with variables:

echo  '<script language="javascript">
redirTime = "5000";
redirURL = "index.php";

function redirTimer() {
self.setTimeout("self.location.href redirURL;",redirTime);
}

redirTimer()
</script> ';
0

No. Do what he has said in the previous post.
ie.,

echo "<script type='text/javascript'>"
echo "redirTimer()";
echo "</script>";

But, Change this line in your redirTimer function.
This

self.setTimeout("self.location.href redirURL;",redirTime);

To

self.setTimeout("self.location.href=redirURL;",redirTime);

That ll solve your problem.

0
<?php 
ob_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<title>Cycle Tracks Portal - Validation Page</title>
		<style type="text/css" media="all">@import "images/style.css";
</style>
	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="rss/" />
	
	<script language="javascript">
		redirTime = "5000"; 
		redirURL = "index.php"; 
		function redirTimer() {
			self.setTimeout("self.location.href=redirURL;",redirTime);
	</script>
	
</head>

<body>
<?php
// connection to MySQL server
mysql_connect('localhost','root','');
mysql_select_db('administration');

// *** Validate request to login to this site.
//session_start();

if (isset($_POST['username'])) {
  $loginUsername=$_POST['username'];
  $loginPassword=$_POST['password']; 
  $MM_redirectLoginSuccess = "validated.php";
  $MM_redirectLoginFailed = "admin.php";
  $MM_redirecttoReferrer = true;
  mysql_select_db('administration');
  
	 if(empty($_POST['username']) && empty($_POST['password'])) {
  	 die('<div class="error_up">Both field was blank</div>
		<br><br><div class="footer_padding">
			&copy; Copyright Cycle Tracks <span>®</span></div>
			');
	 }
	 if(empty($_POST['username'])) {
  	 die('<div class="error_up">Username field was blank</div>
		<br><br><div class="footer_padding">
			&copy; Copyright Cycle Tracks <span>®</span></div>
			');
	 }
	 if(empty($_POST['password'])) {
  	 die('<div class="error_up">Password field was blank</div>
		<br><br><div class="footer_padding">
			&copy; Copyright Cycle Tracks <span>®</span></div>
			');
	 }
	
  $loginUsername = get_magic_quotes_gpc() ? $loginUsername : addslashes($loginUsername);
  $password = get_magic_quotes_gpc() ? $password : addslashes($password);
  $LoginRS_query = "SELECT username, password FROM adminprofile WHERE username='$loginUsername' AND password='$loginPassword'";
  $LoginRS = mysql_query($LoginRS_query) or die(mysql_error());
  $loginFoundUser = mysql_num_rows($LoginRS);
  
  if ($loginFoundUser) {
    
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	}
  else {
    echo "<script type='text/javascript'>"
	echo "redirTimer()";
	echo "</script>";
}
}
?>

</body>
</html>
<?php 
ob_end_flush(); 
?>

Parse error: syntax error, unexpected T_ECHO, expecting ',' or ';' in D:\xampp\htdocs\cycle\validate.php on line 70

0

now no more error but it is not redirecting... blank page

0

I've change the 5000 to 50 and my index.php is not a blank page. Still not working?

0

Naveen, its not working even if I use http://www.yahoo.com. It doesn't redirect at all because the page url was still validate.php. It shouldn't show validate.php. only validated.php or index.php must be shown. All working fine without the redirection function.

0

Then its not entering the else part ! echo something in "if" part as well as "else" part. Check the flow.

0
if ($loginFoundUser) {
    
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	}
  else {
	echo ('Refresh: 120; url=http://www.yahoo.com');
    //echo "<script type='text/javascript'>location.href='$MM_redirectLoginFailed';</script>";
}

Even this is not working....

0

there is no prob in the loop, just the code...

if ($loginFoundUser) {
    
    echo "<script type='text/javascript'>location.href='$MM_redirectLoginSuccess';</script>";
	}
  else {
  
    echo "<script type='text/javascript'>onload='redirTimer()';</script>";
}
}
?>

Line no.7 is not working and no error message was displayed. Pls help

0

onload wouldn't work. Print what's in $loginFoundUser. Is location.href=MM_redirectLoginSuccess working ?

0

location.href=MM_redirectLoginSuccess is working. But I want to use the redirection function. Thats why I didn't use the href....

0

hmm.. okay ! Try this.

echo '<META HTTP-EQUIV="Refresh"
      CONTENT="5; URL=redirect.php">';

This will redirect to redirect.php after 5 seconds.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.