...

View Full Version : getitng users dob and sex into db



runnerjp
02-14-2008, 11:47 AM
hey guys little stuck with this one wundering if any 1 has code i could use/edit

i need to have my form so users can add their dob and age into a db

i have no idea how to do this... i would like it so male/female can be chose so it chnages a colour so male = blue female = pink
and dob displays like so day/month/year

Andrew Johnson
02-14-2008, 12:40 PM
Do you have code for getting the rest of the user's information into your database ?

runnerjp
02-14-2008, 12:44 PM
at the moment i use this


<?php
session_start();
require_once '../../settings.php';
checkLogin ('1 2');
$id = $_SESSION['user_id'];

$qProfile = "SELECT * FROM users WHERE id='$id' ";
$rsProfile = mysql_query($qProfile);
$row = mysql_fetch_array($rsProfile);
extract($row);
$dob = ($dob);
$about_me = ($about_me);
$events = ($events);
$first_name = ($first_name);
$last_name = ($last_name);

mysql_close();?>

<form id="FormName" action="updated.php" method="post" name="FormName">
<table width="448" border="0" cellspacing="2" cellpadding="0">
<tr><td width="150"><div align="right">
<label for="dob">dob</label></div>
</td>
<td>
<input id="dob" name="dob" type="text" size="25" value="" maxlength="255"></td>
</tr>
<tr><td width="150"><div align="right">
<label for="about_me">about_me</label></div>
</td>
<td>
<textarea id="about_me" name="about_me" rows="4" cols="40"><?php echo $about_me ?></textarea></td>
</tr>
<tr><td width="150"><div align="right">
<label for="events">events</label></div>
</td>
<td>
<input id="events" name="events" type="text" size="25" value="<?php echo $events ?>" maxlength="255"></td>
</tr>
<tr><td width="150"><div align="right">
<label for="first_name">first_name</label></div>
</td>
<td>
<input id="first_name" name="first_name" type="text" size="25" value="<?php echo $first_name ?>" maxlength="255"></td>
</tr>
<tr><td width="150"><div align="right">
<label for="last_name">last_name</label></div>
</td>
<td>
<input id="last_name" name="last_name" type="text" size="25" value="<?php echo $last_name ?>" maxlength="255"></td>
</tr>
<tr>
<td width="150"></td>
<td><input type="submit" name="submitButtonName" value="Update"><input type="hidden" name="id" value="<?php echo $id ?>"></td>
</tr>
</table>
</form>


to update it wich goes onto

updated.php


<a href="index.php">Back to List</a><br>
<br>
<?php


include("connect.php");

$id = $_POST['id'];
$dob = $_POST['dob'];
$about_me = $_POST['about_me'];
$events = $_POST['events'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];

$update = "UPDATE users SET dob = '$dob', about_me = '$about_me', events = '$events', first_name = '$first_name', last_name = '$last_name' WHERE id='$id' ";
$rsUpdate = mysql_query($update);
if ($rsUpdate)
{
echo "Update successful.";
} mysql_close();
?>

runnerjp
02-14-2008, 05:12 PM
any ideas any 1?

all i want to do simpky is add users date of birth and sex into a db



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum