Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Noob misunderstanding?

Status
Not open for further replies.

jasc2k

Programmer
Nov 2, 2005
113
GB
Hi all,

This must be an obvious answer but I have never had much dealings in javascript/jQuery.

In short I have a php routine contained in an external file I wish to call via the client side and echo the returned php string into a HTML div

Here is my code to process the file:
Code:
$('#top_info').load('test.php');
this code is in the document ready section of my index.php header

The code runs fine and does as it should only now any buttons on my side that submit data to the server when used returns the user to a blank page with just the test.php result?

Any help appreciated,
Thanks
 
ok have just noticed my problem however I still dont know how to fix maybe I am in the wrong forum
below is my test.php:
Code:
<?php
//require_once('include/session.php');
//require_once('include/database.php');

	global $database, $session;
					
	if($session->logged_in){
		$bmonth = substr($session->userinfo['dob'], 4, -2);
		$bday = substr($session->userinfo['dob'], -2);
		$today = date( 'dm' );
		
		if(strcmp($bday.$bmonth, $today) == 0){
			$msg = "Happy Birthday $session->username from <b>MyPhaze</b>!";
		} else {
			$msg = "Welcome back to <b>MyPhaze</b> $session->username.";
		}
				
		if(MAIL){
			$extra = $database->mailIDs($session->username);
			$q = "SELECT mail_id FROM ".TBL_MAIL_INBOX." WHERE UserTo = '".$session->username."' AND status = 'unread'".$extra;// AND re_id = '0'";
			$numUnreadMail = $database->query($q) or die(mysql_error());
			$numUnreadMail = mysql_num_rows($numUnreadMail);
		
			if($numUnreadMail > 0){
				if($numUnreadMail > 1){ $s ="s"; }
				$msg .= "<br />[<a href='index.php?id=mail'>You have ".$numUnreadMail." unread message";
				if(isset($s)){ $msg .= $s; }
				$msg .= "</a>]";
			}
		}
	} else {
		$msg = "Welcome to <b>MyPhaze</b><span id='loginbutton'><a href='#' title='Log In'></a></span>";
		$msg .= "<br /><b>You are not Logged in!</b> | <a href='index.php?id=forgot'>Forgot Password?</a>";
	}
	echo $msg;
?>

the top two lines where I include the session.php is causing the redirect because I have allready included session.php in my index.php
But I need to somehow call/send the username to the function using javascript?

I hope someone gets me, lol
Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top