Jump to content

Recommended Posts

what i have done is use tabs so that you can pick what area of the profile you want to edit.

 

that ist page shown below where the tab code is on wors perfect and updates anything done!

 

the code provided in the next part is hobbies.php

 

it wont add it to the db or validate any errors... i think its because i use <?php "$_SERVER

[php_SELF]" ?> and it wont use the hobbies.php ... can ne1 help..if more info is needed just ask!

here is my update.php page with the tab script on it

<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%"> </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"> </p>
	<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
      <fieldset>
	<legend>User Details</legend>	 
      <form  action='<?php "$_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 > </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> </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> </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> </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>                     </p>
                    <p>
                      <input name="submit"  type="submit"  value="Submit" />
                        </p>
                </div></td>
              </tr>
            </table>
          </div>
      </form>      
      </fieldset>  
      
      </div>
      </td>
     <td width="10%"> </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>

 

and like i said heres hobbies.php where validation nor insertion into db works...alothough i can get php to work to echo from the db?!?!?!

 

<?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['Description']);
$update = "UPDATE profile SET  about_me = '$about_me' 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"> </p>
	<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
    <fieldset>
        <legend>About me</legend> 

        <div class="c1">
          <p> </p>

                <form  action='<?php "$_SERVER[php_SELF]" ?>' 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="Description" 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 name="submit"  type="submit"  value="Submit" />

                      </form>
    </div>
    </fieldset>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/146092-tabs-and-php-not-working-together/
Share on other sites

The textarea you use to allow users to fill in their "About Me" profile you have named it Description. However your code is looking for a field called about_me

 

Also your code will not run if you don't name your submit button as submitted, as this is what this line is looking for

      if(isset($_POST['submitted']))

 

You should also avoid using short tags. Always use full PHP syntax

hey thanks but the problem is when i use <?php echo $_SERVER['PHP_SELF']; ?>

 

sends me to this page members/include/profiletab/hobbies.php rather then refresing the tab on here /members/index.php?page=update

 

it also still doesnt update the db

 

here is my current code

 

<?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"> </p>
	<p align="center">Data has <strong>not</strong> been saved.</p>
     </div>
     <p>
      <?php } ?>
   <fieldset>
       <legend>About me</legend> 

       <div class="c1">
         <p> </p>

               <form  action='<?php echo $_SERVER['PHP_SELF']; ?>' 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 name="submitted"  type="submit"  value="Submit" />

                     </form>
   </div>
   </fieldset>
</body>
</html>

maybe should address 1 problem at a time!

 

ok first off when i hot submit all it does is show this "hey this is the about me part <label for="uname" class="error"><em>*</em>please only user words</label> " in my textbox and does not update the information inserted ??

ok i have been able to make it enter into the db...here is my next problem

 

 

in stuck on what to put in my action area of my form <form  action='' method="post" name="submit">

 

on this url http://www.runningprofiles.com/members/index.php?page=update is where my tab area is...

 

it looks like this

 

<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>

 

 

so if i click the about me tab it shows "include/profiletab/hobbies.php" in the tab area!.. so if i want to use php on "include/profiletab/hobbies.php" in the tab area what would i need to put in the action script so it doesnt take me to "include/profiletab/hobbies.php" but uses the tab of this instead?

ok i have tried using       

 

action="<?=$_SERVER["REQUEST_URI"]?>" and action="<?=$_SERVER["PHP_SELF"]?>" but it just doesnt update the dbd on run the script on hobbies.php

 

<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%"> </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"> </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 > </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> </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> </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> </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>                     </p>
                    <p>
                      <input name="submit"  type="submit"  value="Submit" />
                        </p>
                </div></td>
              </tr>
            </table>
          </div>
      </form>      
      </fieldset>  
      
      </div>
      </td>
     <td width="10%"> </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>

 

below ihave added hobbies.php and above you have update.php if this helps

 

<?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"> </p>
	<p align="center">Data has <strong>not</strong> been saved.</p>
      </div>
      <p>
       <?php } ?>
    <fieldset>
        <legend>About me</legend> 

        <div class="c1">
          <p> </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>

so once again, i fill in my form and click submit and it just sends me back to the update.php and doesnt update the db or anything BUT if i go to hobbies.php and fill it in everything works

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.