i have now progressed since the post was made...
<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>
<?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'] . "'")); ?>
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="10%"> </td>
<td width="42%"><ul id="countrytabs" class="shadetabs">
<li><a href="#" rel="#default" class="selected">About me</a></li>
<li><a href="include/profiletab/edit1.htm" rel="countrycontainer">Hobbies</a></li>
<li><a href="include/profiletab/edit2.htm" rel="countrycontainer">Goals</a></li>
<li><a href="include/profiletab/edit3.htm" rel="#iframe">Films and Books</a> </li>
</ul>
<div id="countrydivcontainer" style="border:1px solid gray; width:800px; margin-bottom: 1em; padding: 10px">
<?
foreach($_POST as $field => $value) {
if (($field != 'submit') && ((!$value) || (trim($value) == ''))) {
$err .= "$field cannot be empty. <br>";
$warnings[$field] ="required";
}
}
if (!$_POST["firstname"] || !preg_match("/^[a-zA-Z]+$/", $_POST["firstname"])) {
$warnings["firstname"] = " <label for=\"uname\" class=\"error\"><em>*</em>First name can only contain letters</label>";
}
if (!$_POST["lastname"] || !preg_match("/^[a-zA-Z]+$/", $_POST["firstname"])) {
$warnings["lastname"] = " <label for=\"uname\" class=\"error\"><em>*</em>Last name can only contain letters</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['firstname']);
$last_name = mysql_real_escape_string($_POST['lastname']);
$gender = mysql_real_escape_string($_POST['gender']);
$dob = mysql_real_escape_string($_POST['date']);
$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">
<ul>
<?php echo $err; ?>
</ul>
</div>
<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>
<table width="75%" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="30"width="28%"><div align="right">FirstName:</div></td>
<td width="2%"> </td>
<td width="70%"><input name="firstname" id="firstname" <? if (count($warnings) > 0){ if ($warnings['firstname']) echo "class=\"inputerror\""; }?> value="<?php echo $getuserprofile['first_name'] ?>" />
<?php if (count($warnings) > 0){ echo $warnings["firstname"];} ?> </td>
</tr>
<tr>
<td height="30"><div align="right">Last Name: </div></td>
<td><label></label></td>
<td><input type="text" name="lastname" id="lastname" <? if (count($warnings) > 0){ if ($warnings['lastname']) echo "class=\"inputerror\"";} ?> value="<?php echo $getuserprofile['last_name'] ?>" />
<?php if (count($warnings) > 0){ echo $warnings["lastname"];} ?>
</td>
</tr>
<tr>
<td height="30"><div align="right">Birthday :</div></td>
<td> </td>
<td><?php
// include the class
require "datepicker/class.datepicker.php";
// instantiate the object
$dp = new datepicker();
?>
(dd-mm-yyyy)
<input name"date" id="date" value="<?php echo $getuserprofile['dob'] ?>" />
<input type="button" value="..." onclick="<?= $dp->show("date") ?>" /></td>
</tr>
<tr>
<td height="30"><div align="right">Gender : </div></td>
<td> </td>
<td><select id="gender" name="gender">
<option value="Male" >Male</option>
<option value="Female" >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 id="club" name="club">';
foreach ($lines as $line)
{
echo 'pclub = ' . $pclub . ' , line = ' . $line . '<br>';
if ($pclub == trim($line))
{
echo '<option value="' . $line . '" selected="selected">' . $line . '</option>';
}
else
{
echo '<option value="' . $line . '">' . $line . '</option>';
}
}
echo "</select>";
?>
<input type="hidden" name="id" value="<?php echo $id ?>" /></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<input name="submit" type="submit" class="submit-btn" value="" />
</div></td>
</tr>
</table>
</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>
1) why is it wheni go onto edit rofile it displays the error "name can only contain letters".. even though the name taken from the db is letters?
2) how comes both my
<?php $lines = file('runningclubs.txt');
echo '<select id="club" name="club">';
foreach ($lines as $line)
{
if ($pclub == trim($line))
{
echo '<option value="' . $line . '" selected="selected">' . $line . '</option>';
}
else
{
echo '<option value="' . $line . '">' . $line . '</option>';
}
}
echo "</select>";
?>
does not show the previous selected club from the db?
and when a dob is selcted how comes it does not save to my db :S