Link to home
Start Free TrialLog in
Avatar of runnerjp
runnerjp

asked on

ajax tabs and inserting php into db

im using ajax tabs so that users can update different area of their accountthe thing is when i fill in the textbox and hit submit it wont update tthe db with any of the dat... but if i go to the tab page directly so www.mysite.com/thetabpage then it will carry out the update..


ok i have tried using both action="<?=$_SERVER["REQUEST_URI"]?>" and action="<?=$_SERVER["PHP_SELF"]?>" in my form to redirect me to my tabbed page but it just doesnt update the database with the values on hobbies.php

if any code is need i will add right away...can any 1 help?
i have added a picture to how my ajax tabs look like

ajaxtab.jpg
Avatar of prokvk
prokvk

Hi there .. Well I understand what's your problem, what I don't understand is where are you trying to use those PHP path values ?? Can you describe it more concrete ?
Avatar of runnerjp

ASKER

yes sure!

here is my update.php where the tabs are... this is whats shown in the picture
<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
<link rel="stylesheet" type="text/css" href="include/profiletab/ajaxtabs/ajaxtabs.css">
<script type="text/javascript" src="include/profiletab/ajaxtabs/ajaxtabs.js"></script>
<script language = "Javascript">
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
 
maxL=1000;
var bName = navigator.appName;
function taLimit(taObj) {
	if (taObj.value.length==maxL) return false;
	return true;
}
 
function taCount(taObj,Cnt) { 
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=maxL-objVal.length;}
		else{objCnt.innerText=maxL-objVal.length;}
	}
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}
</script>
 
 
<?php 
require_once '../settings.php';
checkLogin('1 2');
include "../info.php"; // sets username/id ect
include "../getuser.php"; // records user view on page
$getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'"));
$getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" .
            $getuser['ID'] . "'"));
			$your_date = $getuserprofile['dob'];
$splitDate = explode("-", $your_date);
 
?>		
           <br /> Edit <?php echo $username;?>'s profile 
       
 <table width="100%" cellspacing="0" cellpadding="0">
   <tr>
     <td width="10%">&nbsp;</td>
     <td width="42%" valign="middle"> <br />       
       <br />     <br />     <br />  
<ul id="countrytabs" class="shadetabs">
      <li><a href="#" rel="#default" class="selected">User Details</a></li>
      <li><a href="include/profiletab/hobbies.php" rel="countrycontainer">About me</a></li>
      <li><a href="include/profiletab/goal.php" rel="countrycontainer">Goals</a></li>
      <li><a href="include/profiletab/idols.php" rel="countrycontainer">Idols</a></li>
      <li><a href="include/profiletab/thanks.php" rel="countrycontainer">Thanks to..</a></li>
</ul>
    
      <div id="countrydivcontainer" style="border:1px solid gray; width:800px; margin-bottom: 1em; padding: 10px">
      
       <?  
       if(isset($_POST['submitted']))
{
 
 
	   
	  foreach($_POST as $field => $value) {
   if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
      $err .= "$field cannot be empty. <br>";
      $warnings[$field] ="required";
   }
}   
 
if (!$_POST["First Name"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["First Name"])) {
   $warnings["First Name"] = " <label for=\"uname\" class=\"error\"><em>*</em>First name can only contain letters</label>";
   }
if (!$_POST["Last Name"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["Last Name"])) {
   $warnings["Last Name"] = " <label for=\"uname\" class=\"error\"><em>*</em>Last name can only contain letters</label>";
   }
   
if (!$_POST["about_me"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["about_me"])) {
   $warnings["about_me"] = " <label for=\"uname\" class=\"error\"><em>*</em>please only user words</label>";
   }
 
           $count  = count($warnings);
           }
if($count === 0)
{
   
if(array_key_exists('submit', $_POST))
{
 
 
 
$club = mysql_real_escape_string($_POST['club']);
$first_name = mysql_real_escape_string($_POST['First Name']);
$last_name =  mysql_real_escape_string($_POST['Last Name']);
$gender =  mysql_real_escape_string($_POST['gender']);
$year =  mysql_real_escape_string( $_POST['year']);
$month =  mysql_real_escape_string( $_POST['month']);
$day =  mysql_real_escape_string( $_POST['day']);
$dob = $day.'-'.$month.'-'.$year; 
$update = "UPDATE profile SET dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE ID='$id' ";
 
 
$result = mysql_query($update);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $er  = 'Invalid query: ' . mysql_error() . "\n";
    $er .= 'Whole query: ' . $query;
    die($er);
       }}
  echo '			<p class="error">' . $message . '</p>' . "\n";
}
 
 
 
            if ($err){?>
      <div class="errors">
		<p align="center"><em>Oops... the following errors were encountered:</em></p>
 
		<div align="center"><?php echo $err; ?>	      </div>
		<p align="center">&nbsp;</p>
		<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
      <fieldset>
		<legend>User Details</legend>	 
      <form  action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post" name="submit">
        <label>
        
          
          <div align="center">
            <table width="91%" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="28%"><div align="right">First Name:</div></td>
                <td >&nbsp;</td>
                <td width="70%"><input name="First Name" id="first name" <? if (count($warnings) > 0){ if ($warnings['First Name']) echo "class=\"inputerror\""; }?> value="<?php echo $getuserprofile['first_name'] ?>"  />
                <?php if (count($warnings) > 0){ echo $warnings["First Name"];} ?> </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Last Name: </div></td>
                <td><label></label></td>
                <td><input  type="text" name="Last Name" id="Last Name" <? if (count($warnings) > 0){ if ($warnings['Last Name']) echo "class=\"inputerror\"";} ?> value="<?php echo $getuserprofile['last_name'] ?>" />
                  <?php if (count($warnings) > 0){ echo $warnings["Last Name"];} ?>                </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Birthday :</div></td>
                <td>&nbsp;</td>
                <td valign="middle"><?php  
	$months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December');
$weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$days = range (1, 31);
$years = range (1910, 2015);
 
//**********************************************
 
echo "Day: <select name='day'>";
foreach ($days as $value) {
   echo '<option ';
   if($splitDate[0] == $value)
      echo 'selected="selected"';
   echo ' value="'.$value.'">'.$value.'</option>\n';
} echo '</select>';
 
echo "Month: <select name='month'>";
foreach ($months as $value) {
 
   echo '<option ';
   if($splitDate[1]==$value) 
      echo "selected='selected'";
   echo 'value="'.$value.'">'.$value.'</option>\n';
} echo '</select>';
 
echo "Year: <select name='year'>";
foreach ($years as $value) {
   echo '<option ';
   if($splitDate[2]==$value)
      echo 'selected="selected"';
   echo " value='".$value."'>".$value."</option>\n";
} 
 ?>                </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Gender : </div></td>
                <td>&nbsp;</td>
                <td><?php $true=$getuserprofile['gender'];?>
                  <select name='gender' id='gender'>
                    <option value='Male' <?php if ($true=='Male') {echo "selected";} ?>>Male</option>
                    <option value='Female'<?php if ($true=='Female') {echo "selected";} ?>>Female</option>
                </select></td>
              </tr>
              <tr>
                <td height="30"><div align="right">Club :</div></td>
                <td>&nbsp;</td>
                <td>
                  <?php $lines = file('runningclubs.txt');
echo '<select class="inputedit" id="club" name="club">';
foreach($lines as $line) {
if($getuserprofile['club'] == trim($line)){
echo '<option value="'.$line.'" selected="selected">'.$line.'</option>';
}else{
echo '<option value="'.$line.'">'.$line.'</option>';
}
}
echo "</select>";
?>
                    
                  <input type="hidden" name="submitted" value="1" />
                <input type="hidden" name="id" value="<?php echo $id ?>" /></td>
              </tr>
              <tr>
                <td colspan="3"><div align="center">
                    <p>&nbsp;                    </p>
                    <p>
                      <input name="submit"  type="submit"  value="Submit" />
                        </p>
                </div></td>
              </tr>
            </table>
          </div>
      </form>      
      </fieldset>  
      
      </div>
      </td>
     <td width="10%">&nbsp;</td>
   </tr>
 </table>
 <script type="text/javascript">
var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()
  </script>

Open in new window

as you can see i use links for the tabs such as  <li><a href="include/profiletab/hobbies.php" rel="countrycontainer">About me</a></li>


hobbies.php is here and this is what i cant get to update!
<?php error_reporting(E_ALL);
session_start();
require_once '../../../settings.php';
include "../../../info.php"; // sets username/id ect
 
$getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'"));
$getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" .
				$getuser['ID'] . "'"));
 
?>
 
<html>
<head>
    <title></title>
   </head>
 
<body>
  <?  
       if(isset($_POST['submitted']))
{
 
 
	   
	  foreach($_POST as $field => $value) {
   if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
      $err .= "$field cannot be empty. <br>";
      $warnings[$field] ="required";
   }
}   
 
if (!$_POST["about_me"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["about_me"])) {
   $warnings["about_me"] = " <label for=\"uname\" class=\"error\"><em>*</em>please only user words</label>";
   }
 
 
           $count  = count($warnings);
           }
if($count === 0)
{
   
if(array_key_exists('submit', $_POST))
{
 
 
 
$about_me = mysql_real_escape_string($_POST['about_me']);
$update = "UPDATE profile SET  about_me = '$about_me' WHERE ID='$id' ";
echo $update;
 
$result = mysql_query($update);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $er  = 'Invalid query: ' . mysql_error() . "\n";
    $er .= 'Whole query: ' . $query;
    die($er);
       }}
  echo '			<p class="error">' . $message . '</p>' . "\n";
}
 
 
 
            if ($err){?>
      <div class="errors">
		<p align="center"><em>Oops... the following errors were encountered:</em></p>
 
		<div align="center"><?php echo $err; ?>	      </div>
		<p align="center">&nbsp;</p>
		<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
    <fieldset>
        <legend>About me</legend> 
 
        <div class="c1">
          <p>&nbsp;</p>
 
                <form  action='<? $_SERVER["REQUEST_URI"]?>' method="post" name="submit">
              <p><em><strong>Tell everybody a little bit about yourself...</strong></em></p>
              <p>
                <textarea <? if (count($warnings) > 0){ if ($warnings['about_me']) echo "class=\"inputerror\""; }?> onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="about_me" rows="7" wrap="physical" cols="60">
<?php echo $getuserprofile['about_me']; ?><?php if (count($warnings) > 0){ echo $warnings["about_me"];} ?>
              </textarea>
                <br />
                <br />
                You have <b><span id="myCounter">1000</span></b> characters remaining</p>
                <input type="hidden" name="submitted" value="1" />
              <input name="submit"  type="submit"  value="Submit" />
 
                      </form>
    </div>
    </fieldset>
</body>
</html>

Open in new window

Now you've confused me a lot .. What's the deal with AJAX ?? What are you doing with AJAX ??? I looked at your code and it just makes no sense for me .. Your links are static links - for example the mentioned one -> <li><a href="include/profiletab/hobbies.php" rel="countrycontainer">About me</a></li>.

Can you show a little light there for me ?
ok what i want to do is have tabs..

so they look like the picture below,,

if u have ever used facebook or myspace you would know what i mean

so under each tab there are areas and all i want to do is update them areas... only way i know how to do this is ajax
Hmm ... so you want to save your data with AJAX when user clicks the Submit button ?
well no...basicly i have tabs and i want to save it like a normal form lol but obviusy each tab has a different form to save
I see .. and that tab switching is via AJAX / JS right ?
thats right..

ok i have set up some links so you can see it in action http://www.runningprofiles.com/test.php

if you want to run the hobbies page on it own then go to http://www.runningprofiles.com/members/include/ajaxtab/hobbies.php
Can you post the code where you set up the content of the current tab via AJAX ?
here is the ajax code :)
//** Ajax Tabs Content script v2.0- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
 
//** Updated Oct 21st, 07 to version 2.0. Contains numerous improvements
 
//** Updated Feb 18th, 08 to version 2.1: Adds a public "tabinstance.cycleit(dir)" method to cycle forward or backward between tabs dynamically. Only .js file changed from v2.0.
 
//** Updated April 8th, 08 to version 2.2:
 
//   -Adds support for expanding a tab using a URL parameter (ie: http://mysite.com/tabcontent.htm?tabinterfaceid=0) 
 
//   -Modified Ajax routine so testing the script out locally in IE7 now works 
 
 
 
var ddajaxtabssettings={}
 
ddajaxtabssettings.bustcachevar=1  //bust potential caching of external pages after initial request? (1=yes, 0=no)
 
ddajaxtabssettings.loadstatustext="<img src='include/profiletab/ajaxtabs/loading.gif' /> Requesting content..." 
 
 
 
 
 
////NO NEED TO EDIT BELOW////////////////////////
 
 
 
function ddajaxtabs(tabinterfaceid, contentdivid){
 
	this.tabinterfaceid=tabinterfaceid //ID of Tab Menu main container
 
	this.tabs=document.getElementById(tabinterfaceid).getElementsByTagName("a") //Get all tab links within container
 
	this.enabletabpersistence=true
 
	this.hottabspositions=[] //Array to store position of tabs that have a "rel" attr defined, relative to all tab links, within container
 
	this.currentTabIndex=0 //Index of currently selected hot tab (tab with sub content) within hottabspositions[] array
 
	this.contentdivid=contentdivid
 
	this.defaultHTML=""
 
	this.defaultIframe='<iframe src="about:blank" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" class="tabcontentiframe" style="width:100%; height:auto; min-height: 100px"></iframe>'
 
	this.defaultIframe=this.defaultIframe.replace(/<iframe/i, '<iframe name="'+"_ddajaxtabsiframe-"+contentdivid+'" ')
 
this.revcontentids=[] //Array to store ids of arbitrary contents to expand/contact as well ("rev" attr values)
 
	this.selectedClassTarget="link" //keyword to indicate which target element to assign "selected" CSS class ("linkparent" or "link")
 
}
 
 
 
ddajaxtabs.connect=function(pageurl, tabinstance){
 
	var page_request = false
 
	var bustcacheparameter=""
 
	if (window.ActiveXObject){ //Test for support for ActiveXObject in IE first (as XMLHttpRequest in IE7 is broken)
 
		try {
 
		page_request = new ActiveXObject("Msxml2.XMLHTTP")
 
		} 
 
		catch (e){
 
			try{
 
			page_request = new ActiveXObject("Microsoft.XMLHTTP")
 
			}
 
			catch (e){}
 
		}
 
	}
 
	else if (window.XMLHttpRequest) // if Mozilla, Safari etc
 
		page_request = new XMLHttpRequest()
 
	else
 
		return false
 
	var ajaxfriendlyurl=pageurl.replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/") 
 
	page_request.onreadystatechange=function(){ddajaxtabs.loadpage(page_request, pageurl, tabinstance)}
 
	if (ddajaxtabssettings.bustcachevar) //if bust caching of external page
 
		bustcacheparameter=(ajaxfriendlyurl.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
 
	page_request.open('GET', ajaxfriendlyurl+bustcacheparameter, true)
 
	page_request.send(null)
 
}
 
 
 
ddajaxtabs.loadpage=function(page_request, pageurl, tabinstance){
 
	var divId=tabinstance.contentdivid
 
	document.getElementById(divId).innerHTML=ddajaxtabssettings.loadstatustext //Display "fetching page message"
 
	if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){
 
		document.getElementById(divId).innerHTML=page_request.responseText
 
		ddajaxtabs.ajaxpageloadaction(pageurl, tabinstance)
 
	}
 
}
 
 
 
ddajaxtabs.ajaxpageloadaction=function(pageurl, tabinstance){
 
	tabinstance.onajaxpageload(pageurl) //call user customized onajaxpageload() function when an ajax page is fetched/ loaded
 
}
 
 
 
ddajaxtabs.getCookie=function(Name){ 
 
	var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
 
	if (document.cookie.match(re)) //if cookie found
 
		return document.cookie.match(re)[0].split("=")[1] //return its value
 
	return ""
 
}
 
 
 
ddajaxtabs.setCookie=function(name, value){
 
	document.cookie = name+"="+value+";path=/" //cookie value is domain wide (path=/)
 
}
 
 
 
ddajaxtabs.prototype={
 
 
 
	expandit:function(tabid_or_position){ //PUBLIC function to select a tab either by its ID or position(int) within its peers
 
		this.cancelautorun() //stop auto cycling of tabs (if running)
 
		var tabref=""
 
		try{
 
			if (typeof tabid_or_position=="string" && document.getElementById(tabid_or_position).getAttribute("rel")) //if specified tab contains "rel" attr
 
				tabref=document.getElementById(tabid_or_position)
 
			else if (parseInt(tabid_or_position)!=NaN && this.tabs[tabid_or_position].getAttribute("rel")) //if specified tab contains "rel" attr
 
				tabref=this.tabs[tabid_or_position]
 
		}
 
		catch(err){alert("Invalid Tab ID or position entered!")}
 
		if (tabref!="") //if a valid tab is found based on function parameter
 
			this.expandtab(tabref) //expand this tab
 
	},
 
 
 
	cycleit:function(dir, autorun){ //PUBLIC function to move foward or backwards through each hot tab (tabinstance.cycleit('foward/back') )
 
		if (dir=="next"){
 
			var currentTabIndex=(this.currentTabIndex<this.hottabspositions.length-1)? this.currentTabIndex+1 : 0
 
		}
 
		else if (dir=="prev"){
 
			var currentTabIndex=(this.currentTabIndex>0)? this.currentTabIndex-1 : this.hottabspositions.length-1
 
		}
 
		if (typeof autorun=="undefined") //if cycleit() is being called by user, versus autorun() function
 
			this.cancelautorun() //stop auto cycling of tabs (if running)
 
		this.expandtab(this.tabs[this.hottabspositions[currentTabIndex]])
 
	},
 
 
 
	setpersist:function(bool){ //PUBLIC function to toggle persistence feature
 
			this.enabletabpersistence=bool
 
	},
 
 
 
	loadajaxpage:function(pageurl){ //PUBLIC function to fetch a page via Ajax and display it within the Tab Content instance's container
 
		ddajaxtabs.connect(pageurl, this)
 
	},
 
 
 
	loadiframepage:function(pageurl){ //PUBLIC function to fetch a page and load it into the IFRAME of the Tab Content instance's container
 
		this.iframedisplay(pageurl, this.contentdivid)
 
	},
 
 
 
	setselectedClassTarget:function(objstr){ //PUBLIC function to set which target element to assign "selected" CSS class ("linkparent" or "link")
 
		this.selectedClassTarget=objstr || "link"
 
	},
 
 
 
	getselectedClassTarget:function(tabref){ //Returns target element to assign "selected" CSS class to
 
		return (this.selectedClassTarget==("linkparent".toLowerCase()))? tabref.parentNode : tabref
 
	},
 
 
 
	urlparamselect:function(tabinterfaceid){
 
		var result=window.location.search.match(new RegExp(tabinterfaceid+"=(\\d+)", "i")) //check for "?tabinterfaceid=2" in URL
 
		return (result==null)? null : parseInt(RegExp.$1) //returns null or index, where index (int) is the selected tab's index
 
	},
 
 
 
	onajaxpageload:function(pageurl){ //PUBLIC Event handler that can invoke custom code whenever an Ajax page has been fetched and displayed
 
		//do nothing by default
 
	},
 
 
 
	expandtab:function(tabref){
 
		var relattrvalue=tabref.getAttribute("rel")
 
		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
 
		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
 
		if (relattrvalue=="#default")
 
			document.getElementById(this.contentdivid).innerHTML=this.defaultHTML
 
		else if (relattrvalue=="#iframe")
 
			this.iframedisplay(tabref.getAttribute("href"), this.contentdivid)
 
		else
 
			ddajaxtabs.connect(tabref.getAttribute("href"), this)
 
		this.expandrevcontent(associatedrevids)
 
		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
 
			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("href")==tabref.getAttribute("href"))? "selected" : ""
 
		}
 
		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
 
			ddajaxtabs.setCookie(this.tabinterfaceid, tabref.tabposition)
 
		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
 
	},
 
 
 
	iframedisplay:function(pageurl, contentdivid){
 
		if (typeof window.frames["_ddajaxtabsiframe-"+contentdivid]!="undefined"){
 
			try{delete window.frames["_ddajaxtabsiframe-"+contentdivid]} //delete iframe within Tab content container if it exists (due to bug in Firefox)
 
			catch(err){}
 
		}
 
		document.getElementById(contentdivid).innerHTML=this.defaultIframe
 
		window.frames["_ddajaxtabsiframe-"+contentdivid].location.replace(pageurl) //load desired page into iframe
 
	},
 
 
 
 
 
	expandrevcontent:function(associatedrevids){
 
		var allrevids=this.revcontentids
 
		for (var i=0; i<allrevids.length; i++){ //Loop through rev attributes for all tabs in this tab interface
 
			//if any values stored within associatedrevids matches one within allrevids, expand that DIV, otherwise, contract it
 
			document.getElementById(allrevids[i]).style.display=(associatedrevids.indexOf(","+allrevids[i]+",")!=-1)? "block" : "none"
 
		}
 
	},
 
 
 
	setcurrenttabindex:function(tabposition){ //store current position of tab (within hottabspositions[] array)
 
		for (var i=0; i<this.hottabspositions.length; i++){
 
			if (tabposition==this.hottabspositions[i]){
 
				this.currentTabIndex=i
 
				break
 
			}
 
		}
 
	},
 
 
 
	autorun:function(){ //function to auto cycle through and select tabs based on a set interval
 
		this.cycleit('next', true)
 
	},
 
 
 
	cancelautorun:function(){
 
		if (typeof this.autoruntimer!="undefined")
 
			clearInterval(this.autoruntimer)
 
	},
 
 
 
	init:function(automodeperiod){
 
		var persistedtab=ddajaxtabs.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
 
		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
 
		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
 
		this.automodeperiod=automodeperiod || 0
 
		this.defaultHTML=document.getElementById(this.contentdivid).innerHTML
 
		for (var i=0; i<this.tabs.length; i++){
 
			this.tabs[i].tabposition=i //remember position of tab relative to its peers
 
			if (this.tabs[i].getAttribute("rel")){
 
				var tabinstance=this
 
				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
 
				this.tabs[i].onclick=function(){
 
					tabinstance.expandtab(this)
 
					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
 
					return false
 
				}
 
				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
 
					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
 
				}
 
				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
 
					selectedtab=i //Selected tab index, if found
 
				}
 
			}
 
		} //END for loop
 
		if (selectedtab!=-1) //if a valid default selected tab index is found
 
			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
 
		else //if no valid default selected index found
 
			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
 
		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
 
			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
 
		}
 
	} //END int() function
 
 
 
} //END Prototype assignment

Open in new window

Try this instead of your update.php:

Note: You will have to assign an id="form1" to your forms you want to be saved:



<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
<link rel="stylesheet" type="text/css" href="include/profiletab/ajaxtabs/ajaxtabs.css">
<script type="text/javascript" src="include/profiletab/ajaxtabs/ajaxtabs.js"></script>
<script language = "Javascript">
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
 
maxL=1000;
var bName = navigator.appName;
function taLimit(taObj) {
	if (taObj.value.length==maxL) return false;
	return true;
}
 
function taCount(taObj,Cnt) { 
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=maxL-objVal.length;}
		else{objCnt.innerText=maxL-objVal.length;}
	}
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}
</script>
 
 
<?php 
require_once '../settings.php';
checkLogin('1 2');
include "../info.php"; // sets username/id ect
include "../getuser.php"; // records user view on page
$getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'"));
$getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" .
            $getuser['ID'] . "'"));
			$your_date = $getuserprofile['dob'];
$splitDate = explode("-", $your_date);
 
?>		
           <br /> Edit <?php echo $username;?>'s profile 
       
 <table width="100%" cellspacing="0" cellpadding="0">
   <tr>
     <td width="10%">&nbsp;</td>
     <td width="42%" valign="middle"> <br />       
       <br />     <br />     <br />  
<ul id="countrytabs" class="shadetabs">
      <li><a href="#" rel="#default" class="selected">User Details</a></li>
      <li><a href="include/profiletab/hobbies.php" rel="countrycontainer">About me</a></li>
      <li><a href="include/profiletab/goal.php" rel="countrycontainer">Goals</a></li>
      <li><a href="include/profiletab/idols.php" rel="countrycontainer">Idols</a></li>
      <li><a href="include/profiletab/thanks.php" rel="countrycontainer">Thanks to..</a></li>
</ul>
    
      <div id="countrydivcontainer" style="border:1px solid gray; width:800px; margin-bottom: 1em; padding: 10px">
      
       <?  
       if(isset($_POST['submitted']))
{
 
 
	   
	  foreach($_POST as $field => $value) {
   if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
      $err .= "$field cannot be empty. <br>";
      $warnings[$field] ="required";
   }
}   
 
if (!$_POST["First Name"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["First Name"])) {
   $warnings["First Name"] = " <label for=\"uname\" class=\"error\"><em>*</em>First name can only contain letters</label>";
   }
if (!$_POST["Last Name"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["Last Name"])) {
   $warnings["Last Name"] = " <label for=\"uname\" class=\"error\"><em>*</em>Last name can only contain letters</label>";
   }
   
if (!$_POST["about_me"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["about_me"])) {
   $warnings["about_me"] = " <label for=\"uname\" class=\"error\"><em>*</em>please only user words</label>";
   }
 
           $count  = count($warnings);
           }
if($count === 0)
{
   
if(array_key_exists('submit', $_POST))
{
 
 
 
$club = mysql_real_escape_string($_POST['club']);
$first_name = mysql_real_escape_string($_POST['First Name']);
$last_name =  mysql_real_escape_string($_POST['Last Name']);
$gender =  mysql_real_escape_string($_POST['gender']);
$year =  mysql_real_escape_string( $_POST['year']);
$month =  mysql_real_escape_string( $_POST['month']);
$day =  mysql_real_escape_string( $_POST['day']);
$dob = $day.'-'.$month.'-'.$year; 
$update = "UPDATE profile SET dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE ID='$id' ";
 
 
$result = mysql_query($update);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $er  = 'Invalid query: ' . mysql_error() . "\n";
    $er .= 'Whole query: ' . $query;
    die($er);
       }}
  echo '			<p class="error">' . $message . '</p>' . "\n";
}
 
 
 
            if ($err){?>
      <div class="errors">
		<p align="center"><em>Oops... the following errors were encountered:</em></p>
 
		<div align="center"><?php echo $err; ?>	      </div>
		<p align="center">&nbsp;</p>
		<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
      <fieldset>
		<legend>User Details</legend>	 
      <form  action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post" name="submit" id="form1">
        <label>
        
          
          <div align="center">
            <table width="91%" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="28%"><div align="right">First Name:</div></td>
                <td >&nbsp;</td>
                <td width="70%"><input name="First Name" id="first name" <? if (count($warnings) > 0){ if ($warnings['First Name']) echo "class=\"inputerror\""; }?> value="<?php echo $getuserprofile['first_name'] ?>"  />
                <?php if (count($warnings) > 0){ echo $warnings["First Name"];} ?> </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Last Name: </div></td>
                <td><label></label></td>
                <td><input  type="text" name="Last Name" id="Last Name" <? if (count($warnings) > 0){ if ($warnings['Last Name']) echo "class=\"inputerror\"";} ?> value="<?php echo $getuserprofile['last_name'] ?>" />
                  <?php if (count($warnings) > 0){ echo $warnings["Last Name"];} ?>                </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Birthday :</div></td>
                <td>&nbsp;</td>
                <td valign="middle"><?php  
	$months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December');
$weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$days = range (1, 31);
$years = range (1910, 2015);
 
//**********************************************
 
echo "Day: <select name='day'>";
foreach ($days as $value) {
   echo '<option ';
   if($splitDate[0] == $value)
      echo 'selected="selected"';
   echo ' value="'.$value.'">'.$value.'</option>\n';
} echo '</select>';
 
echo "Month: <select name='month'>";
foreach ($months as $value) {
 
   echo '<option ';
   if($splitDate[1]==$value) 
      echo "selected='selected'";
   echo 'value="'.$value.'">'.$value.'</option>\n';
} echo '</select>';
 
echo "Year: <select name='year'>";
foreach ($years as $value) {
   echo '<option ';
   if($splitDate[2]==$value)
      echo 'selected="selected"';
   echo " value='".$value."'>".$value."</option>\n";
} 
 ?>                </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Gender : </div></td>
                <td>&nbsp;</td>
                <td><?php $true=$getuserprofile['gender'];?>
                  <select name='gender' id='gender'>
                    <option value='Male' <?php if ($true=='Male') {echo "selected";} ?>>Male</option>
                    <option value='Female'<?php if ($true=='Female') {echo "selected";} ?>>Female</option>
                </select></td>
              </tr>
              <tr>
                <td height="30"><div align="right">Club :</div></td>
                <td>&nbsp;</td>
                <td>
                  <?php $lines = file('runningclubs.txt');
echo '<select class="inputedit" id="club" name="club">';
foreach($lines as $line) {
if($getuserprofile['club'] == trim($line)){
echo '<option value="'.$line.'" selected="selected">'.$line.'</option>';
}else{
echo '<option value="'.$line.'">'.$line.'</option>';
}
}
echo "</select>";
?>
                    
                  <input type="hidden" name="submitted" value="1" />
                <input type="hidden" name="id" value="<?php echo $id ?>" /></td>
              </tr>
              <tr>
                <td colspan="3"><div align="center">
                    <p>&nbsp;                    </p>
                    <p>
                      <input name="submit"  type="submit"  value="Submit" />
                        </p>
                </div></td>
              </tr>
            </table>
          </div>
      </form>      
      </fieldset>  
      
      </div>
      </td>
     <td width="10%">&nbsp;</td>
   </tr>
 </table>
 <script type="text/javascript">
var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init();
document.getElementById('form1').action = countries.setselectedClassTarget("link");
  </script>

Open in new window

nope still didnt update it :( what did u chnage..was i just supposed to copy and poaste the code or do i have to add something?
I changed the line with the <form> to the following:

<form  action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post" name="submit" id="form1">

You see, there's a form id now, you'll have to add this id to the form on all those AJAX pages.

I also added this line before the end of the last <script>:

document.getElementById('form1').action = countries.setselectedClassTarget("link");
ok so the one saying form1 should work but it doent  lol
I also added this line before the end of the last <script>:

document.getElementById('form1').action = countries.setselectedClassTarget("link");

Add it to the end of that page after the line:

countries.init();

In fact, remove the countries.init() line and add the following instead:

countries.init();
document.getElementById('form1').action = countries.setselectedClassTarget("link");
BTW I am looking at that page now .. and the form doesn't have any ID .. You have to set the ID as I told you to make it work ..
Heh, my mistake .. You can easily do just this:

Use this as your hobbies.php:



<?php error_reporting(E_ALL);
session_start();
require_once '../../../settings.php';
include "../../../info.php"; // sets username/id ect
 
$getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'"));
$getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" .
				$getuser['ID'] . "'"));
 
?>
 
<html>
<head>
    <title></title>
   </head>
 
<body>
  <?  
       if(isset($_POST['submitted']))
{
 
 
	   
	  foreach($_POST as $field => $value) {
   if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
      $err .= "$field cannot be empty. <br>";
      $warnings[$field] ="required";
   }
}   
 
if (!$_POST["about_me"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["about_me"])) {
   $warnings["about_me"] = " <label for=\"uname\" class=\"error\"><em>*</em>please only user words</label>";
   }
 
 
           $count  = count($warnings);
           }
if($count === 0)
{
   
if(array_key_exists('submit', $_POST))
{
 
 
 
$about_me = mysql_real_escape_string($_POST['about_me']);
$update = "UPDATE profile SET  about_me = '$about_me' WHERE ID='$id' ";
echo $update;
 
$result = mysql_query($update);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $er  = 'Invalid query: ' . mysql_error() . "\n";
    $er .= 'Whole query: ' . $query;
    die($er);
       }}
  echo '			<p class="error">' . $message . '</p>' . "\n";
}
 
 
 
            if ($err){?>
      <div class="errors">
		<p align="center"><em>Oops... the following errors were encountered:</em></p>
 
		<div align="center"><?php echo $err; ?>	      </div>
		<p align="center">&nbsp;</p>
		<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
    <fieldset>
        <legend>About me</legend> 
 
        <div class="c1">
          <p>&nbsp;</p>
 
                <form  action='include/profiletab/hobbies.php' method="post" name="submit">
              <p><em><strong>Tell everybody a little bit about yourself...</strong></em></p>
              <p>
                <textarea <? if (count($warnings) > 0){ if ($warnings['about_me']) echo "class=\"inputerror\""; }?> onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="about_me" rows="7" wrap="physical" cols="60">
<?php echo $getuserprofile['about_me']; ?><?php if (count($warnings) > 0){ echo $warnings["about_me"];} ?>
              </textarea>
                <br />
                <br />
                You have <b><span id="myCounter">1000</span></b> characters remaining</p>
                <input type="hidden" name="submitted" value="1" />
              <input name="submit"  type="submit"  value="Submit" />
 
                      </form>
    </div>
    </fieldset>
</body>
</html>

Open in new window

still not working:(  the resons i didnt have it set is i set it back to orignal again when it didnt work but its back now lol... here is current code
<link rel="stylesheet" type="text/css" href="http://www.runningprofiles.com/css/login.css">
<link rel="stylesheet" type="text/css" href="members/include/profiletab/ajaxtabs/ajaxtabs.css">
<script type="text/javascript" src="members/include/profiletab/ajaxtabs/ajaxtabs.js"></script>
<script language = "Javascript">
/**
 * DHTML textbox character counter script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
 
maxL=1000;
var bName = navigator.appName;
function taLimit(taObj) {
	if (taObj.value.length==maxL) return false;
	return true;
}
 
function taCount(taObj,Cnt) { 
	objCnt=createObject(Cnt);
	objVal=taObj.value;
	if (objVal.length>maxL) objVal=objVal.substring(0,maxL);
	if (objCnt) {
		if(bName == "Netscape"){	
			objCnt.textContent=maxL-objVal.length;}
		else{objCnt.innerText=maxL-objVal.length;}
	}
	return true;
}
function createObject(objId) {
	if (document.getElementById) return document.getElementById(objId);
	else if (document.layers) return eval("document." + objId);
	else if (document.all) return eval("document.all." + objId);
	else return eval("document." + objId);
}
</script>
 
 
<?php 
require_once 'settings.php';
 
include "info.php"; // sets username/id ect
include "getuser.php"; // records user view on page
$getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='Admin'"));
$getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='1'"));
			$your_date = $getuserprofile['dob'];
$splitDate = explode("-", $your_date);
 
?>		
           <br /> Edit <?php echo $username;?>'s profile 
       
 <table width="100%" cellspacing="0" cellpadding="0">
   <tr>
     <td width="10%">&nbsp;</td>
     <td width="42%" valign="middle"> <br />       
       <br />     <br />     <br />  
<ul id="countrytabs" class="shadetabs">
      <li><a href="#" rel="#default" class="selected">User Details</a></li>
      <li><a href="members/include/profiletab/hobbies.php" rel="countrycontainer">About me</a></li>
      <li><a href="members/include/profiletab/goal.php" rel="countrycontainer">Goals</a></li>
      <li><a href="members/include/profiletab/idols.php" rel="countrycontainer">Idols</a></li>
      <li><a href="members/include/profiletab/thanks.php" rel="countrycontainer">Thanks to..</a></li>
</ul>
    
      <div id="countrydivcontainer" style="border:1px solid gray; width:800px; margin-bottom: 1em; padding: 10px">
      
       <?  
       if(isset($_POST['submitted']))
{
 
 
	   
	  foreach($_POST as $field => $value) {
   if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
      $err .= "$field cannot be empty. <br>";
      $warnings[$field] ="required";
   }
}   
 
if (!$_POST["First Name"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["First Name"])) {
   $warnings["First Name"] = " <label for=\"uname\" class=\"error\"><em>*</em>First name can only contain letters</label>";
   }
if (!$_POST["Last Name"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["Last Name"])) {
   $warnings["Last Name"] = " <label for=\"uname\" class=\"error\"><em>*</em>Last name can only contain letters</label>";
   }
   
if (!$_POST["about_me"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["about_me"])) {
   $warnings["about_me"] = " <label for=\"uname\" class=\"error\"><em>*</em>please only user words</label>";
   }
 
           $count  = count($warnings);
           }
if($count === 0)
{
   
if(array_key_exists('submit', $_POST))
{
 
 
 
$club = mysql_real_escape_string($_POST['club']);
$first_name = mysql_real_escape_string($_POST['First Name']);
$last_name =  mysql_real_escape_string($_POST['Last Name']);
$gender =  mysql_real_escape_string($_POST['gender']);
$year =  mysql_real_escape_string( $_POST['year']);
$month =  mysql_real_escape_string( $_POST['month']);
$day =  mysql_real_escape_string( $_POST['day']);
$dob = $day.'-'.$month.'-'.$year; 
$update = "UPDATE profile SET dob='$dob', club= '$club', first_name = '$first_name', gender = '$gender', last_name = '$last_name' WHERE ID='$id' ";
 
 
$result = mysql_query($update);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $er  = 'Invalid query: ' . mysql_error() . "\n";
    $er .= 'Whole query: ' . $query;
    die($er);
       }}
  echo '			<p class="error">' . $message . '</p>' . "\n";
}
 
 
 
            if ($err){?>
      <div class="errors">
		<p align="center"><em>Oops... the following errors were encountered:</em></p>
 
		<div align="center"><?php echo $err; ?>	      </div>
		<p align="center">&nbsp;</p>
		<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
      <fieldset>
		<legend>User Details</legend>	 
      <form  action='<?php echo $_SERVER['PHP_SELF']; ?>' method="post" name="submit" id="form1">
        <label>
        
          
          <div align="center">
            <table width="91%" align="left" cellpadding="0" cellspacing="0">
              <tr>
                <td width="28%"><div align="right">First Name:</div></td>
                <td >&nbsp;</td>
                <td width="70%"><input name="First Name" id="first name" <? if (count($warnings) > 0){ if ($warnings['First Name']) echo "class=\"inputerror\""; }?> value="<?php echo $getuserprofile['first_name'] ?>"  />
                <?php if (count($warnings) > 0){ echo $warnings["First Name"];} ?> </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Last Name: </div></td>
                <td><label></label></td>
                <td><input  type="text" name="Last Name" id="Last Name" <? if (count($warnings) > 0){ if ($warnings['Last Name']) echo "class=\"inputerror\"";} ?> value="<?php echo $getuserprofile['last_name'] ?>" />
                  <?php if (count($warnings) > 0){ echo $warnings["Last Name"];} ?>                </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Birthday :</div></td>
                <td>&nbsp;</td>
                <td valign="middle"><?php  
	$months = array (1 => 'January', 'February', 'March', 'April', 'May', 'June','July', 'August', 'September', 'October', 'November', 'December');
$weekday = array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
$days = range (1, 31);
$years = range (1910, 2015);
 
//**********************************************
 
echo "Day: <select name='day'>";
foreach ($days as $value) {
   echo '<option ';
   if($splitDate[0] == $value)
      echo 'selected="selected"';
   echo ' value="'.$value.'">'.$value.'</option>\n';
} echo '</select>';
 
echo "Month: <select name='month'>";
foreach ($months as $value) {
 
   echo '<option ';
   if($splitDate[1]==$value) 
      echo "selected='selected'";
   echo 'value="'.$value.'">'.$value.'</option>\n';
} echo '</select>';
 
echo "Year: <select name='year'>";
foreach ($years as $value) {
   echo '<option ';
   if($splitDate[2]==$value)
      echo 'selected="selected"';
   echo " value='".$value."'>".$value."</option>\n";
} 
 ?>                </td>
              </tr>
              <tr>
                <td height="30"><div align="right">Gender : </div></td>
                <td>&nbsp;</td>
                <td><?php $true=$getuserprofile['gender'];?>
                  <select name='gender' id='gender'>
                    <option value='Male' <?php if ($true=='Male') {echo "selected";} ?>>Male</option>
                    <option value='Female'<?php if ($true=='Female') {echo "selected";} ?>>Female</option>
                </select></td>
              </tr>
              <tr>
                <td height="30"><div align="right">Club :</div></td>
                <td>&nbsp;</td>
                <td>
                  <?php $lines = file('members/runningclubs.txt');
echo '<select class="inputedit" id="club" name="club">';
foreach($lines as $line) {
if($getuserprofile['club'] == trim($line)){
echo '<option value="'.$line.'" selected="selected">'.$line.'</option>';
}else{
echo '<option value="'.$line.'">'.$line.'</option>';
}
}
echo "</select>";
?>
                    
                  <input type="hidden" name="submitted" value="1" />
                <input type="hidden" name="id" value="<?php echo $id ?>" /></td>
              </tr>
              <tr>
                <td colspan="3"><div align="center">
                    <p>&nbsp;                    </p>
                    <p>
                      <input name="submit"  type="submit"  value="Submit" />
                        </p>
                </div></td>
              </tr>
            </table>
          </div>
      </form>      
      </fieldset>  
      
      </div>
      </td>
     <td width="10%">&nbsp;</td>
   </tr>
 </table>
 <script type="text/javascript">
var countries=new ddajaxtabs("countrytabs", "countrydivcontainer")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init();
document.getElementById('form1').action = countries.setselectedClassTarget("link");
  </script>

Open in new window

Use this instead of your hobbies.php (I just changed the action of the form):



<?php error_reporting(E_ALL);
session_start();
require_once '../../../settings.php';
include "../../../info.php"; // sets username/id ect
 
$getuser = mysql_fetch_assoc(mysql_query("SELECT * from users where Username='$username'"));
$getuserprofile = mysql_fetch_assoc(mysql_query("SELECT * from profile where ID='" .
				$getuser['ID'] . "'"));
 
?>
 
<html>
<head>
    <title></title>
   </head>
 
<body>
  <?  
       if(isset($_POST['submitted']))
{
 
 
	   
	  foreach($_POST as $field => $value) {
   if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
      $err .= "$field cannot be empty. <br>";
      $warnings[$field] ="required";
   }
}   
 
if (!$_POST["about_me"] || !preg_match("/^[a-zA-Z ]+$/", $_POST["about_me"])) {
   $warnings["about_me"] = " <label for=\"uname\" class=\"error\"><em>*</em>please only user words</label>";
   }
 
 
           $count  = count($warnings);
           }
if($count === 0)
{
   
if(array_key_exists('submit', $_POST))
{
 
 
 
$about_me = mysql_real_escape_string($_POST['about_me']);
$update = "UPDATE profile SET  about_me = '$about_me' WHERE ID='$id' ";
echo $update;
 
$result = mysql_query($update);
 
// Check result
// This shows the actual query sent to MySQL, and the error. Useful for debugging.
if (!$result) {
    $er  = 'Invalid query: ' . mysql_error() . "\n";
    $er .= 'Whole query: ' . $query;
    die($er);
       }}
  echo '			<p class="error">' . $message . '</p>' . "\n";
}
 
 
 
            if ($err){?>
      <div class="errors">
		<p align="center"><em>Oops... the following errors were encountered:</em></p>
 
		<div align="center"><?php echo $err; ?>	      </div>
		<p align="center">&nbsp;</p>
		<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
    <fieldset>
        <legend>About me</legend> 
 
        <div class="c1">
          <p>&nbsp;</p>
 
                <form  action='include/profiletab/hobbies.php' method="post" name="submit">
              <p><em><strong>Tell everybody a little bit about yourself...</strong></em></p>
              <p>
                <textarea <? if (count($warnings) > 0){ if ($warnings['about_me']) echo "class=\"inputerror\""; }?> onKeyPress="return taLimit(this)" onKeyUp="return taCount(this,'myCounter')" name="about_me" rows="7" wrap="physical" cols="60">
<?php echo $getuserprofile['about_me']; ?><?php if (count($warnings) > 0){ echo $warnings["about_me"];} ?>
              </textarea>
                <br />
                <br />
                You have <b><span id="myCounter">1000</span></b> characters remaining</p>
                <input type="hidden" name="submitted" value="1" />
              <input name="submit"  type="submit"  value="Submit" />
 
                      </form>
    </div>
    </fieldset>
</body>
</html>

Open in new window

ok it works but send me to http://www.runningprofiles.com/members/include/profiletab/hobbies.php and doesent send me to the tab page and do it... just looks messy lol
ASKER CERTIFIED SOLUTION
Avatar of prokvk
prokvk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
i suppose you have to go to the page to use the page... dam lolso i would have to use ajax form then?
Well, yes and no .. You can have such AJAX tabs as you have implemented, but you're using classic nonAJAX form actions. You are in the middle ^^ You can have it completely AJAX, but not with these actions ...
so you mean the whole form needs to be changed lol
No it doesn't ... You just have to make it submit via AJAX ..
ahh u any idea how to do that lol
Yes, first of all .. close this question, second of all - open a new question with AJAX submit ;)