PDA

View Full Version : Beginners guide.....help plz


moe122
02-15-2008, 07:53 PM
hey was jus goin thru your tutorial to do with databses and and i think it was lesson 7 where youve created a connections page and then another page linked to that page and then you test it by viewing it in your web browser, i cant seem to get it 2 work and get the usual 404 error. Hope you could help, looking forward to hearing from you thanx
moe

davidj
02-15-2008, 08:01 PM
a 404 error means the page cant be found

this points to the fact your server is not setup correctly

you need to point the server to the working directory or move your site to the default directory which the install defined

the default PHP dir is...

C:/wamp/www/

if you want to chang this you need to setup an alias which you can do through the wamp icon in the systems tray. Run the alias option and follow the on screen instruction

davidj
02-15-2008, 08:09 PM
oh

welcome to the forum moe

moe122
02-15-2008, 08:11 PM
hi, that was a fast reply, and they say no1z willing to help nowadays..........i now have the error 403........you use msn?

davidj
02-15-2008, 08:22 PM
sorry i dont help via msn

im guessing you havnt setup your directory properly

probably pointing to wrong path or file

moe122
02-15-2008, 09:28 PM
thnx mate got it 2 wrk, soz 4 l8 reply my net woz dwn

davidj
02-15-2008, 09:31 PM
thnx mate got it 2 wrk, soz 4 l8 reply my net woz dwn


hehe

your really young arnt you ?

this text jargon

i sound like a grandpa

moe122
02-15-2008, 09:55 PM
lolz yh i am, infact im only 19 and u?

i got the following error after doing tutorial 8

Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\Web Root\Test\Images\TMP1l3yoway2b.php on line 11

davidj
02-15-2008, 09:58 PM
lolz yh i am, infact im only 19 and u?

im old

im............ 39!

planet sanatogen

i got the following error after doing tutorial 8
Parse error: syntax error, unexpected T_ECHO in C:\wamp\www\Web Root\Test\Images\TMP1l3yoway2b.php on line 11


look at line 10 and see if you forgot a semi colon (;) to terminate the line

moe122
02-15-2008, 10:04 PM
39 ent old.....

u sure i've got:

line 10 do(
echo $row["First Name"]."<br>";
)while ($row = mysql_fetch_array($result))
?>

btw dint get your name?

davidj
02-15-2008, 10:05 PM
the clue is in the title

david

davidj
02-15-2008, 10:06 PM
post ya code

moe122
02-15-2008, 10:11 PM
yh i was thinkin david but who knows there might be a few guys running the site.........
n ere u go


<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
do(
echo $row["First Name"]."<br>";
)while ($row = mysql_fetch_array($result))
?>

davidj
02-15-2008, 10:19 PM
<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
do(
echo $row["First Name"]."<br>";
)while ($row = mysql_fetch_array($result))
?>

ok

your do loop should use braces {} not brackets ()

moe122
02-15-2008, 10:28 PM
yup ur a genius....its workin

btw in ur tutorial do u cover anything on adding new users from the website.......so any random geeza wants to join from my website, how he would do it etc? like a registration thing?

davidj
02-15-2008, 10:30 PM
follow the tuts

they give you the basic lego bricks. The basics

you take them and build what you want using them

davidj
02-15-2008, 10:34 PM
yup ur a genius


and attractive to the ladies

moe122
02-15-2008, 10:39 PM
lolz genius n gd lukin..........i c dat evry mornin wen i luk in da mirror :P n 1 mre fing..........im stil young.........

btw im on tut 8.....

say i got a user....hu logz in den wud he b able to bring up only hiz/her data.....so database recognises hiz/her username n den shows der record?

davidj
02-15-2008, 10:43 PM
right thats it... im putting my foot down ... like a parent

post so i can understand your request or ill slap the back of ya legs

and ground ya!

moe122
02-15-2008, 10:47 PM
sorry what bit dont you get?

davidj
02-15-2008, 10:48 PM
post your last question...

but using english

or ill knack ya

moe122
02-15-2008, 10:57 PM
well
say im a user and i go to this website i want to see all my data........can the website automatically display all my data......like view my profile on many website...........how do i do that or is it covered in the tutorials?

davidj
02-15-2008, 11:25 PM
your talking about a user account app

where a user logs on and has access to his data only

follow the tuts and get an understanding then return and we will build your app together

when you build the next youtube clone i want 20%

moe122
02-15-2008, 11:58 PM
your talking about a user account app

where a user logs on and has access to his data only

follow the tuts and get an understanding then return and we will build your app together

when you build the next youtube clone i want 20%

yes that what im talking about and 20% 4 what? :P
im stuck again :(

tut 9 finished it n tested it got following error

Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Web Root\Test\Images\TMP65fypwb3za.php on line 5

moe122
02-15-2008, 11:58 PM
by the way where you from?

davidj
02-16-2008, 12:00 AM
the toon

newcastle uk

moe122
02-16-2008, 12:02 AM
and about the error after tut 9


Parse error: syntax error, unexpected T_STRING in C:\wamp\www\Web Root\Test\Images\TMP65fypwb3za.php on line 5

moe122
02-16-2008, 12:03 AM
btw (by the way :P) im frm cov

davidj
02-16-2008, 12:04 AM
you forgot a semi colon

check your syntax

post your code

davidj
02-16-2008, 12:05 AM
cov ??????????????????

moe122
02-16-2008, 12:09 AM
coventry.............like you ent heard of it.........(weve got the largest tescos in europe :P)
here you go
<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$First Name = $_POST['First Name'];
$Surname = $_POST['Surname'];
$Date of Birth = $_POST['Date of Birth'];
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
/////
if($submit && $First Name && $Surname && $Date of Birth && $Country){
/////
$query = sprintf("INSERT into table1(First Name, Surname, Date of Birth, Country) values ('$First Name', '$Surname', '$Date Of Birth', '$Country')");
mysql_query ($query) or die (mysql());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////

davidj
02-16-2008, 12:13 AM
parents lived in meriden for a few years which is the center of england for the rest of you...

http://mysite.wanadoo-members.co.uk/heartofengland/meriden.htm

moe122
02-16-2008, 12:24 AM
yh meriden n berkwell itz on da way to birmingham so its like 15mins drive

and do i get some help with code problem?

davidj
02-16-2008, 08:53 AM
this is not a valid variable name

you cant use spaces


$First Name

moe122
02-16-2008, 09:22 AM
hey gd mornin, stil cnt get it 2 wrk :s

davidj
02-16-2008, 09:23 AM
post your code

moe122
02-16-2008, 09:31 AM
ive got the page to show..........but when i enter new data and click submit nothing happens


<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$FirstName = $_POST['First Name'];
$Surname = $_POST['Surname'];
$DateofBirth = $_POST['Date of Birth'];
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
/////
if($Submit && $FirstName && $Surname && $DateofBirth && $Country){
/////
$query = sprintf("INSERT into table1(First Name, Surname, Date of Birth, Country) values ('$First Name', '$Surname', '$Date Of Birth', '$Country')");
mysql_query ($query) or die (mysql());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>

davidj
02-16-2008, 09:39 AM
ok you have forgot to change your SQL and possibly your database. You cant use spaces in form fields and database columns.

$query = sprintf("INSERT into table1(First Name, Surname, Date of Birth, Country) values ('$First Name', '$Surname', '$Date Of Birth', '$Country')");

moe122
02-16-2008, 09:52 AM
Nope cant get it 2 work :s


<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Date_of_Birth = $_POST['Date_of_Birth'];
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
/////
if($Submit && $First_Name && $Surname && $Date_of_Birth && $Country){
/////
$query = sprintf("INSERT into table1(First_Name, Surname, Date_of_Birth, Country) values ('$First_Name', '$Surname', '$Date_Of_Birth', '$Country')");
mysql_query ($query) or die (mysql());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIJ</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PMP_SELF'];?>">
<table width="296" border="1">
<tr>
<td width="60">First_Name</td>
<td width="53">Surname</td>
<td width="88">Date_of_Birth</td>
<td width="67">Country</td>
</tr>
<tr>
<td><label>
<input type="text" name="First Nme" id="First Nme" />
</label></td>
<td><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td><label>
<input type="text" name="Date of Birth" id="Date of Birth" />
</label></td>
<td><label>
<input type="text" name="textfield4" id="textfield4" />
</label></td>
</tr>
<tr>
<td colspan="4" align="center"><label>
<input type="submit" name="button" id="button" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
<table width="389" height="54" border="1">
<tr>
<td width="41" height="23">ID</td>
<td width="81">First_Name</td>
<td width="81">Surname</td>
<td width="87">Date_of_Birth</td>
<td width="65">Country</td>
</tr>

<?php do { ?>
<tr>
<td height="23"><?php echo $row["field1_id"];?></td>
<td><?php echo $row["First_Name"];?></td>
<td><?php echo $row["Surname"];?></td>
<td><?php echo $row["Date_of_Birth"];?></td>
<td width="65"><?php echo $row["Country"];?></td>
</tr>
<?php }while ($row = mysql_fetch_array($result));?>

</table>
</body>
</html>


plase use code tags when posting code - dj

davidj
02-16-2008, 10:05 AM
again

you are not listening to me

you cant have spaces in form fields.

<input type="text" name="First Nme" id="First Nme" />


also your making up your own functions

<?php $_SERVER['PMP_SELF'];?>

You have to check your code over and over. Its acceptable to miss the odd semi colon and mis-spell a variable. Even i fall into those traps.

double check your code before posting

moe122
02-16-2008, 10:19 AM
:( not working


<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Date_of_Birth = $_POST['Date_of_Birth'];
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
/////
if($Submit && $First_Name && $Surname && $Date_of_Birth && $Country){
/////
$query = sprintf("INSERT into table1(First_Name, Surname, Date_of_Birth, Country) values ('$First_Name', '$Surname', '$Date_Of_Birth', '$Country')");
mysql_query ($query) or die (mysql());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIJ</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="296" border="1">
<tr>
<td width="60">First_Name</td>
<td width="53">Surname</td>
<td width="88">Date_of_Birth</td>
<td width="67">Country</td>
</tr>
<tr>
<td><label>
<input type="text" name="First_Name" id="First_Name" />
</label></td>
<td><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td><label>
<input type="text" name="Date_of_Birth" id="Date_of_Birth" />
</label></td>
<td><label>
<input type="text" name="textfield4" id="textfield4" />
</label></td>
</tr>
<tr>
<td colspan="4" align="center"><label>
<input type="submit" name="button" id="button" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
<table width="389" height="54" border="1">
<tr>
<td width="41" height="23">ID</td>
<td width="81">First_Name</td>
<td width="81">Surname</td>
<td width="87">Date_of_Birth</td>
<td width="65">Country</td>
</tr>



<?php do { ?>
<tr>
<td height="23"><?php echo $row["field1_id"];?></td>
<td><?php echo $row["First_Name"];?></td>
<td><?php echo $row["Surname"];?></td>
<td><?php echo $row["Date_of_Birth"];?></td>
<td width="65"><?php echo $row["Country"];?></td>
</tr>
<?php }while ($row = mysql_fetch_array($result));?>


</table>
</body>
</html>

moe122
02-16-2008, 10:33 AM
ok got it to work but the date comes out as 0000-00-00

davidj
02-16-2008, 10:37 AM
nice one

yes the date does do that as its a universal db format

you need to swap it about to get the date right

wana write a function?

moe122
02-16-2008, 10:39 AM
go for it.....btw you know how i just entered data to add it 2 the previous data could i have a drop down menu to add the data, such as for 'Country' have a drop down menu with all the countries?

davidj
02-16-2008, 10:41 AM
yes of course you can use a dropdown

just replace it keeping the name the same

moe122
02-16-2008, 10:50 AM
so i jus replace the text field with a list/menu right?

the what about the date problem?

davidj
02-16-2008, 10:52 AM
first look at the functions tutorial i wrote then come back

to give you an understanding

moe122
02-16-2008, 10:57 AM
you on about this 1
PHP date() function introduction


cant access the tut, account suspended...........:s

moe122
02-16-2008, 12:03 PM
ok found the right tut and i have managed to get the datechanger function to work but still got the problem with it giving 00-00-0000 when i enter a ner record

davidj
02-16-2008, 02:01 PM
you have to catch the date thats been keyed and then pass that into a function which switches the date into the correct format

this can be done using one function so see if you can write one yourself. If you manage it then ill award you with a medal

if you need help then come back and we will tackle it together

let me know how you get on

moe122
02-16-2008, 06:30 PM
so how do i do that then? :S

davidj
02-16-2008, 06:38 PM
i was hoping you could have worked it out

moe122
02-16-2008, 06:50 PM
well i ent an IT person and the last time i worked on dreamweaver was almost a year back and that was on html not php

davidj
02-16-2008, 07:18 PM
here is the function

place it in your PHP above the html (at the top)

***** read the comments and learn what im doing here ****

/// create function with argument $date ///
function dateswapper($date){

/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);

/// determin which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}


}it will sort the date automatically depending on what you want to do

where you want the date displayed from the database do this...

<php echo dateswapper($row['date_of_birth']; ?>also wrap it around a $_POST then it will format dd/mm/yyyy to yyyy-mm-dd which is database friendly

like this

$date_of_birth = dateswapper($_POST['date_of_birth']);

moe122
02-16-2008, 11:13 PM
hey jus tried out the code you told me and i still get the same problem :s

davidj
02-17-2008, 10:13 AM
this mean your doing it wrong

post your code

moe122
02-17-2008, 01:28 PM
hey

heres my code, also you know that tutorial on login script....have you got anything on registration process?


<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
$del = $_GET['del'];
/////
if ($del){
/////
$query = sprintf("DELETE FROM table1 where field1_id='$del'");
mysql_query ($query) or die (mysql_error());
/////
}

if($Submit && $First_Name && $Surname && $Date_of_Birth && $Country){
/////
$query = sprintf("INSERT into table1(First_Name, Surname, Date_of_Birth, Country) values ('$First_Name', '$Surname', '$Date_Of_Birth', '$Country')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determin which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////

/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIJ</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="604" border="1">
<tr>
<td width="134">First Name</td>
<td width="144">Surname</td>
<td width="144">Date of Birth</td>
<td width="144">Country</td>
</tr>
<tr>
<td><label>
<input type="text" name="First Name" id="First Name" />
</label></td>
<td><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td><label>
<input type="text" name="Date of Birth" id="Date of Birth" />
</label></td>
<td><label>
<input type="text" name="Country" id="Country" />
</label></td>
</tr>
<tr>
<td colspan="4" align="center"><label>
<input type="submit" name="button" id="button" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
<table width="481" height="54" border="1">
<tr>
<td width="41" height="23">ID</td>
<td width="109">First Name</td>
<td width="85">Surname</td>
<td width="122">Date of Birth</td>
<td width="90">Country</td>
<td width="90">&nbsp;</td>
</tr>

<?php do { ?>
<tr>
<td height="23"><?php echo $row["field1_id"];?></td>
<td><?php echo $row["First_Name"];?></td>
<td><?php echo $row["Surname"];?></td>
<td><?php echo dateswapper ($row["Date_of_Birth"]);?></td>
<td width="90"><?php echo $row["Country"];?></td>
<td width="90"><label>

<input type="button" name="Submit2" id="Submit2" value="Delete" onclick="document.location.href='TIJ.php?del=<?php echo $row["field1_id"] ?>'"/>
</label></td>
</tr>
<?php }while ($row = mysql_fetch_array($result));?>
</table>
<p>&nbsp;</p>
</body>
</html>

davidj
02-17-2008, 03:26 PM
have you got anything on registration process?


in my basic tuts i have insert, update and delete tutorials

use those to make what you want

moe122
02-17-2008, 05:09 PM
and what about my code problem with the date?

davidj
02-17-2008, 06:45 PM
where you have


<?php echo dateswapper ($row["Date_of_Birth"]);?>


you remove the space like this...


dateswapper($row["Date_of_Birth"])

moe122
02-17-2008, 07:16 PM
no luck david :(

davidj
02-17-2008, 07:21 PM
let me see your code

my function works!

USE CODE TAGS WHEN POSTING CODE PLEASE

moe122
02-17-2008, 07:24 PM
here you go


<?php
require_once("../Connections/Connection.php"); // Database Connection
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
$del = $_GET['del'];
/////
if ($del){
/////
$query = sprintf("DELETE FROM table1 where field1_id='$del'");
mysql_query ($query) or die (mysql_error());
/////
}

if($Submit && $First_Name && $Surname && $Date_of_Birth && $Country){
/////
$query = sprintf("INSERT into table1(First_Name, Surname, Date_of_Birth, Country) values ('$First_Name', '$Surname', '$Date_Of_Birth', '$Country')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determin which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////

/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIJ</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="604" border="1">
<tr>
<td width="134">First Name</td>
<td width="144">Surname</td>
<td width="144">Date of Birth</td>
<td width="144">Country</td>
</tr>
<tr>
<td><label>
<input type="text" name="First Name" id="First Name" />
</label></td>
<td><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td><label>
<input type="text" name="Date of Birth" id="Date of Birth" />
</label></td>
<td><label>
<input type="text" name="Country" id="Country" />
</label></td>
</tr>
<tr>
<td colspan="4" align="center"><label>
<input type="submit" name="button" id="button" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
<table width="481" height="54" border="1">
<tr>
<td width="41" height="23">ID</td>
<td width="109">First Name</td>
<td width="85">Surname</td>
<td width="122">Date of Birth</td>
<td width="90">Country</td>
<td width="90">&nbsp;</td>
</tr>

<?php do { ?>
<tr>
<td height="23"><?php echo $row["field1_id"];?></td>
<td><?php echo $row["First_Name"];?></td>
<td><?php echo $row["Surname"];?></td>
<td><?php echo dateswapper($row["Date_of_Birth"]);?></td>
<td width="90"><?php echo $row["Country"];?></td>
<td width="90"><label>

<input type="button" name="Submit2" id="Submit2" value="Delete" onclick="document.location.href='TIJ.php?del=<?php echo $row["field1_id"] ?>'"/>
</label></td>
</tr>
<?php }while ($row = mysql_fetch_array($result));?>
</table>
<p>&nbsp;</p>
</body>
</html>

davidj
02-17-2008, 07:26 PM
move the function to the top of the page but below this line

require_once("../Connections/Connection.php"); // Database Connection

moe122
02-17-2008, 07:38 PM
nope not working :( what if i jus have three values that come together to represent the date?


<?php
require_once("../Connections/Connection.php"); // Database Connection
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determin which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
$del = $_GET['del'];
/////
if ($del){
/////
$query = sprintf("DELETE FROM table1 where field1_id='$del'");
mysql_query ($query) or die (mysql_error());
/////
}

if($Submit && $First_Name && $Surname && $Date_of_Birth && $Country){
/////
$query = sprintf("INSERT into table1(First_Name, Surname, Date_of_Birth, Country) values ('$First_Name', '$Surname', '$Date_Of_Birth', '$Country')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($submit){
echo"One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////

/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIJ</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="604" border="1">
<tr>
<td width="134">First Name</td>
<td width="144">Surname</td>
<td width="144">Date of Birth</td>
<td width="144">Country</td>
</tr>
<tr>
<td><label>
<input type="text" name="First Name" id="First Name" />
</label></td>
<td><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td><label>
<input type="text" name="Date of Birth" id="Date of Birth" />
</label></td>
<td><label>
<input type="text" name="Country" id="Country" />
</label></td>
</tr>
<tr>
<td colspan="4" align="center"><label>
<input type="submit" name="button" id="button" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
<table width="481" height="54" border="1">
<tr>
<td width="41" height="23">ID</td>
<td width="109">First Name</td>
<td width="85">Surname</td>
<td width="122">Date of Birth</td>
<td width="90">Country</td>
<td width="90">&nbsp;</td>
</tr>

<?php do { ?>
<tr>
<td height="23"><?php echo $row["field1_id"];?></td>
<td><?php echo $row["First_Name"];?></td>
<td><?php echo $row["Surname"];?></td>
<td><?php echo dateswapper($row["Date_of_Birth"]);?></td>
<td width="90"><?php echo $row["Country"];?></td>
<td width="90"><label>

<input type="button" name="Submit2" id="Submit2" value="Delete" onclick="document.location.href='TIJ.php?del=<?php echo $row["field1_id"] ?>'"/>
</label></td>
</tr>
<?php }while ($row = mysql_fetch_array($result));?>
</table>
<p>&nbsp;</p>
</body>
</html>

davidj
02-17-2008, 07:41 PM
whats happening

moe122
02-17-2008, 07:51 PM
well no matter what i enter into the date field or even if i dont enter anything i get 00-00-0000 as the date for the new record.

davidj
02-17-2008, 09:03 PM
have you successfully displayed data from the database like a date

have you successfully entered a date into the database through your form

have you done the above without the date function i wrote

moe122
02-18-2008, 06:29 AM
hi,
i can only view the dates i enter via the database not the ones i enter via the form.

davidj
02-18-2008, 06:46 AM
try keying in the date in the form in reverse

yyyy/mm/dd

moe122
02-18-2008, 07:06 AM
yh i've tried that and it didnt work.....

davidj
02-18-2008, 07:07 AM
this means your insert function isnt working

davidj
02-18-2008, 07:08 AM
is it just your date field that is not being populated

or all fields

remember you have to populate all fields for the insert to work as per your condition in your script

moe122
02-18-2008, 07:19 AM
:):):) finally got it 2 wrk......i wrote 'Date Of Birth' instead of 'Date of Birth'. anyways im off. im going to have a go at tut 8 later. bye

davidj
02-18-2008, 08:16 AM
that would do it

moe122
02-18-2008, 03:46 PM
hi,
you know ive got my connection to mysql database could i use microsoft access instead? if so how would i do it? would my whole code change?

moe122
02-18-2008, 05:55 PM
Also jus did the last tut on update a=but cant get it 2 work, basically i press update and it send the info to the form where when i change it and press submit nothing happens and but changes back what it was :(


<?php
require_once("../Connections/Connection.php"); // Database Connection
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determine which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$Country = $_POST['Country'];
$Submit = $_POST['Submit'];
$update_id = $_POST['update_id'];
$del = $_GET['del'];
$upd = $_GET['upd'];
/////
/////
$query = sprintf("SELECT * FROM table1 where field1_id='$upd'");
$result = @mysql_query($query);
$rowUpdate = @mysql_fetch_array($result);
/////

if($Submit && $First_Name && $Surname && $Date_of_Birth && $Country && ! $update_id){
/////
$query = sprintf("INSERT into table1(First_Name, Surname, Date_of_Birth, Country) values ('$First_Name', '$Surname', '$Date_of_Birth', '$Country')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($submit && $update_id){
/////
$query = sprintf("UPDATE table1 set First_Name='&First_Name', Surname='$Surname', Date_of_Birth='$Date_of_Birth', Country='$Country' where field1_id='$update_id'");
$result = @mysql_query($query);
/////
}

//del record
if ($del){
/////
$query = sprintf("DELETE FROM table1 where field1_id='$del'");
mysql_query ($query) or die (mysql_error());
/////
}
/////
$query = sprintf("SELECT * FROM table1");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////

/*do{
echo $row["First Name"]."<br>";
}while ($row = mysql_fetch_array($result))
*/
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TIJ</title>
</head>
<body>
<p>&nbsp;</p>
<form id="form1" name="form1" method="post" action="<?php $_SERVER['PHP_SELF'];?>">
<table width="901" border="1">
<tr>
<td width="146">First Name</td>
<td width="146">Surname</td>
<td width="287">DOB</td>
<td width="144">Date of Birth</td>
<td width="144">Country</td>
</tr>
<tr>
<td><label>
<input name="First Name" type="text" id="First Name" value="<?php echo $rowUpdate["First_Name"] ?>" />
</label></td>
<td><label>
<input name="Surname" type="text" id="Surname" value="<?php echo $rowUpdate["Surname"] ?>" />
</label></td>
<td><label>
<input name="Date of Birth" type="text" id="Date of Birth" value="<?php echo $rowUpdate["Date_of_Birth"] ?>" />
</label></td>
<td><label>
<input name="Country" type="text" id="Country" value="<?php echo $rowUpdate["Country"] ?>" />
</label></td>
</tr>
<tr>
<td colspan="5" align="center"><label>
<input type="reset" name="Submit4" id="Submit4" value="Reset" />
<input type="submit" name="button" id="button" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
<input name="update_id" type="hidden" id="update_id" value="<?php echo $rowUpdate["field1_id"] ?>" />
</label></td>
</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
</form>
<table width="624" height="54" border="1">
<tr>
<td width="41">&nbsp;</td>
<td width="41" height="23">ID</td>
<td width="109">First Name</td>
<td width="85">Surname</td>
<td width="122">Date of Birth</td>
<td width="90">Country</td>
<td width="90">&nbsp;</td>
</tr>

<?php do { ?>
<tr>
<td><label>
<input type="button" name="Submit3" id="Submit3" value="Update" onclick="document.location.href='TIJ.php?upd=<?php echo $row["field1_id"] ?>'"/>
</label></td>
<td height="23"><?php echo $row["field1_id"];?></td>
<td><?php echo $row["First_Name"];?></td>
<td><?php echo $row["Surname"];?></td>
<td><?php echo dateswapper($row["Date_of_Birth"]);?></td>
<td width="90"><?php echo $row["Country"];?></td>
<td width="90"><label>

<input type="button" name="Submit2" id="Submit2" value="Delete" onclick="document.location.href='TIJ.php?del=<?php echo $row["field1_id"] ?>'"/>
</label></td>
</tr>
<?php }while ($row = mysql_fetch_array($result));?>
</table>
<p>
<label></label>
</p>
</body>
</html>

davidj
02-18-2008, 06:27 PM
you need to learn how to debug code

inside the IF condition add an echo like this...


}elseif($submit && $update_id){
/////

echo "test"; ///<< echo here

$query = sprintf("UPDATE table1 set First_Name='&First_Name', Surname='$Surname', Date_of_Birth='$Date_of_Birth', Country='$Country' where field1_id='$update_id'");
$result = @mysql_query($query);
/////
}


run the code and perform an update to see if the echo returns. This will tell you that the IF condition is working

also you can add an echo to the $query variable so you can see the update and check its correct


}elseif($submit && $update_id){
/////

echo $query = sprintf("UPDATE table1 set First_Name='&First_Name', Surname='$Surname', Date_of_Birth='$Date_of_Birth', Country='$Country' where field1_id='$update_id'");
$result = @mysql_query($query);
/////
}

moe122
02-18-2008, 06:42 PM
jus entered the code u told me to enter and it worked, but said test in text form after i click submit after updating i then deleted your code and so it shouldnt work again but it still works and no test in text form ??????

davidj
02-18-2008, 06:52 PM
i didnt understand that at all

moe122
02-18-2008, 06:58 PM
well i entered your code it worked but at the top of the browser page it said test after i click on submit after updating
so i got rid off your code and so it didnt say test anymore, and you would fink because i deleted your code i would be at the start again with the problem
but it still worked so updated successfully
is that more clear or shall i go back to the basics?

davidj
02-18-2008, 07:20 PM
ok so its working

great

moe122
02-18-2008, 08:43 PM
hey
i need to reinstall mysql, so i do would that wreck everything ive done?

moe122
02-18-2008, 09:15 PM
hey,
u know in the database what is varchar, is it like text so anything? also what would be just text as in jus letters?

davidj
02-18-2008, 09:20 PM
you could export the tables, database and data if its not broken

are you using the EMS mysql IDE for controlling your db?

there is a option in there to export your database to a file (Tools menu)

davidj
02-18-2008, 09:24 PM
david why you gotta be like that 4? :PLike what ???

Like not helping through the PM system.....

Mmmm maybe im rude or maybe by helping you that way wont help anyone else who have the same problems as you.

What you reckon?

also this is not a help desk or system support. Its a community.

go figure...

moe122
02-18-2008, 09:28 PM
lolz tru bt u dint actually help me or any1.........because u havent answered the question yet( about varchar etc....if you've forgotten) , and ive sorted the database problem out so dont worry about it......

davidj
02-18-2008, 09:32 PM
bt u dint actually help me or any1.
so in the last 87 posts you got no help?

because u havent answered the question yet( about varchar etc....if you've forgotten)

because i didnt reply in the fifteen minutes between your question and the above remark doesn't mean i have forgot.... Some forums you could be waiting days for a reply

moe122
02-18-2008, 09:36 PM
lolz i know, and i am gr8ful, u have helped alot thnx..........n i hope u'l continue to help :D

davidj
02-18-2008, 09:36 PM
in answer to your question (sorry its late)

a varchar is a field type of a string. This will accept anything (numerical alpha)

Values in VARCHAR columns are variable-length strings. The length can be specified as a value from 0 to 255 before MySQL 5.0.3, and 0 to 65,535 in 5.0.3 and later versions.

moe122
02-18-2008, 09:41 PM
cool thanx.....and whats the one for jus text so just letters

davidj
02-18-2008, 09:51 PM
some reading here...

http://dev.mysql.com/doc/refman/5.0/en/data-types.html

moe122
02-18-2008, 09:59 PM
sorry about the questions...........this was the main ques i needed 2 ask but i forgot.........you know at the moment you got user enters 1 value it goes into the database and then is shown on the website.......is it possible for the user 2 enter a few values, which combine to enter 1 cell in the database and is shown as 1 item on the website

e.g user enters 01 .........01............1982 which are 3 values which then combine and enter database as 01-01-1982 (in other words a date) and then shown on the website as 01-01-1982


?????sorry to bother you :D

davidj
02-18-2008, 10:02 PM
this is a strange scenario

why would you do this that way?

give me an example of why... Maybe there is a better way if i understand the process

moe122
02-18-2008, 10:07 PM
you know some forumz when you sign up and they have the date but they have drop down menus
dd which has values 1-31
mm " " 1-12
yyyy which can b entered as text

3 values...........goes into 1..........

davidj
02-18-2008, 10:14 PM
ok gotcha

your 3 selects (dropdowns) like so..

<select id="day" name="day">
<option .......

<select id="month" name="month">
<option .......

<select id="year" name="year">
<option .......

then in your php...

$day = $_POST['day'];
$month= $_POST['month'];
$year= $_POST['year'];

$date = "$year-$month-$day"; // << concatenate the date parts

/// $date is used for the database entry

moe122
02-20-2008, 02:58 PM
hey david, dont know if you can help....got this problem with dreamweaver and flash, i've imported a flash file into dreamweaver and when i preview it in explorer i get an error on page.... in dreamweaver it says.....Line 15 The tag name: "embed2 Not found in currently active versions.[XHTML 1.0 transitional] when validating the page....also in explorer it says....Line: 11 Char: 1 Object: expected Code: 0

Heres my code



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Homepage</title>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','800','heigh t','200','title','Logo2','src','logo2','quality',' high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movi e','logo2' ); //end AC code
</script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="800" height="200" title="Logo2">
<param name="movie" value="logo2.swf" />
<param name="quality" value="high" />
<embed src="logo2.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="800" height="200"></embed>
</object></noscript>
</body>
</html>

davidj
02-20-2008, 03:00 PM
new question new thread please

moe122
02-23-2008, 10:56 AM
hey
i jus made my own submit form so its like a registration page, so it purpose is only you get data entered and put it into my database, but it dont seem to work, any ideas?

<?php
require_once("Connections/Connection.php"); // Database Connection
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determine which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Email_Address = $_POST['Email_Address'];
$Gender = $_POST['Gender'];
$Day = $_POST['Day'];
$Month= $_POST['Month'];
$Year= $_POST['Year'];
$Date_of_Birth = dateswapper("$Day-$Month-$Year"); // << concatenate the date parts
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$City = $_POST['City'];
$Region = $_POST['Region'];
$Country = $_POST['Country'];
$Postcode = $_POST['Postcode'];
$Religion = $_POST['Religion'];
$Ethnic_Origin = $_POST['Ethnic_Origin'];
$Occupation = $_POST['Occupation'];
$Marital_Status = $_POST['Marital_Status'];
$Number_of_Children = $_POST['Number_of_Children'];
$Phone_Number = $_POST['Phone_Number'];
$Submit = $_POST['Submit'];

/// $date is used for the database entry
if($Submit && $First_Name && $Surname && $Username && $Password && $Email_Address && $Gender && $Date_of_Birth && $City && $Region && $Country && $Postcode && $Religion && $Ethnic_Origin && $Phone_Number && $Marital_Status && $Number_of_Children && $Occupation){
/////
$query = sprintf("INSERT into clients('$First_Name', '$Surname', '$Username', '$Password', '$Email_Address', '$Gender', '$Date_of_Birth', '$City', '$Region', '$Country', '$Postcode', '$Religion', '$Ethnic_Origin', '$Phone_Number', '$Marital_Status', '$Number_of_Children', '$Occupation')");
mysql_query ($query) or die (mysql_error());
/////
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #000000}
.style5 {font-size: 24px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="563" border="0">
<tr bordercolor="0">
<td bgcolor="#E4E4E4"><span class="style5">Personal Details</span></td>
<td bgcolor="#E4E4E4">&nbsp;</td>
<td bgcolor="#E4E4E4">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td width="266" bgcolor="#F1F1F1"><span class="style1">First Name</span></td>
<td width="123" bgcolor="#FAFAFA"><label>
<input type="text" name="First_Name" id="First_Name" />
</label></td>
<td width="160" bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Surname</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Surname2" id="Surname2" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Username</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Username" id="Username" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1">Password</td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Password" id="Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Verify Password</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Verify_Password" id="Verify_Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Email Address</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Email_Address" id="Email_Address" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Gender</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Gender" id="Gender">
<option>Male</option>
<option>Female</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Date of Birth</span></td>
<td bgcolor="#FAFAFA">Day
<select name="Day" id="Day">
<option selected="selected">01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
Month
<select name="Month" id="Month">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
Year
<input name="Month" type="text" id="Month" value="YYYY" size="2" maxlength="4" /></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">City</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="City" id="City" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Region</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Region" id="Region" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Country</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Country" id="Country">
<option>Afghanistan</option>
<option>Argentina</option>
<option>Australia</option>
<option>Austria</option>
<option>Bangladesh</option>
<option>Belgium</option>
<option>Bolivia</option>
<option>Brazil</option>
<option>Bulgaria</option>
<option>Canada</option>
<option>Chile</option>
<option>China</option>
<option>Colombia</option>
<option>Costa Rica</option>
<option>Croatia</option>
<option>Czech Republic</option>
<option>Denmark</option>
<option>Dominican Republic</option>
<option>Ecuador</option>
<option>Egypt</option>
<option>El Salvador</option>
<option>Estonia</option>
<option>Europe</option>
<option>Finland</option>
<option>France</option>
<option>Germany</option>
<option>Greece</option>
<option>Guatemala</option>
<option>Honduras</option>
<option>Hong Kong</option>
<option>Hungary</option>
<option>India</option>
<option>Indonesia</option>
<option>Iraq</option>
<option>Ireland</option>
<option>Israel</option>
<option>Italy</option>
<option>Jamaica</option>
<option>Japan</option>
<option>Jordan</option>
<option>Kenya</option>
<option>Korea</option>
<option>Kazakhstan</option>
<option>Latvia</option>
<option>Lithuania</option>
<option>Latin America</option>
<option>Luxembourg</option>
<option>Macedonia</option>
<option>Malaysia</option>
<option>Mexico</option>
<option>Moldova</option>
<option>Morocco</option>
<option>Netherlands</option>
<option>New Zealand</option>
<option>Norway</option>
<option>Pakistan</option>
<option>Panama</option>
<option>Paraguay</option>
<option>Peru</option>
<option>Philippines</option>
<option>Poland</option>
<option>Portugal</option>
<option>Puerto Rico</option>
<option>Romania</option>
<option>Russia</option>
<option>Saudi Arabia</option>
<option>Serbia and Montenegro</option>
<option>Singapore</option>
<option>Slovakia</option>
<option>Slovenia</option>
<option>South Africa</option>
<option>Spain</option>
<option>Sri Lanka</option>
<option>Sweden</option>
<option>Switzerland</option>
<option>Syria</option>
<option>Taiwan</option>
<option>Thailand</option>
<option>Trinidad and Tobago</option>
<option>Tunisia</option>
<option>Turkey</option>
<option>Ukraine</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Uruguay</option>
<option>Venezuela</option>
<option>Vietnam</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Country_Other" id="Country_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Postcode</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Postcode" id="Postcode" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Religion</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Religion" id="Religion">
<option>Sunni Hanafi</option>
<option>Sunni Humblie</option>
<option>Sunni Maliki</option>
<option>Sunni Shafi</option>
<option>Shia</option>
<option>Just a Muslim</option>
<option>Buddhism</option>
<option>Christianity</option>
<option>Judaism</option>
<option>Hinduism</option>
<option>Sikhism</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Religion_Other" id="Religion_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Ethnic Origin</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Ethnic_Origin" id="Ethnic_Origin">
<option>White English</option>
<option>White Irish</option>
<option>White Scottish</option>
<option>White Welsh</option>
<option>White Other</option>
<option>Asain Bangladeshi</option>
<option>Asain Indian</option>
<option>Asain Pakistani</option>
<option>Asain Other</option>
<option>Black African</option>
<option>Black Carribean</option>
<option>Black Other</option>
<option>Mixed (Please Specify)</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Ethnic Origin_Mixed_Other" id="Ethnic Origin_Mixed_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Occupation</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Occupation" id="Occupation" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Marital Status</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Marital_Status" id="Marital_Status">
<option>Married</option>
<option>Single</option>
<option>Separated</option>
<option>Divorved</option>
<option>Widowed</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Number of Children (if any)</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Number_of_Children" id="Number_of_Children">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>More than 5</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Phone Number (will only be used by us to contact you and will not be shown to any third parties)</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Phone_Number" id="Phone_Number" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bordercolor="0" bgcolor="#F1F1F1">&nbsp;</td>
<td bordercolor="0" bgcolor="#FAFAFA"><label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

moe122
02-23-2008, 11:51 AM
tweaked a little bit, and now get the following error

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''moe', 'yas', 'mymy', 'jan', 'moe122@hotmail.co.uk', 'Male', '--', 'cov', 'westm' at line 1


<?php
require_once("Connections/Connection.php"); // Database Connection
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determine which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Email_Address = $_POST['Email_Address'];
$Gender = $_POST['Gender'];
$Day = $_POST['Day'];
$Month= $_POST['Month'];
$Year= $_POST['Year'];
$Date_of_Birth = dateswapper("$Day-$Month-$Year"); // << concatenate the date parts
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$City = $_POST['City'];
$Region = $_POST['Region'];
$Country = $_POST['Country'];
$Postcode = $_POST['Postcode'];
$Religion = $_POST['Religion'];
$Ethnic_Origin = $_POST['Ethnic_Origin'];
$Occupation = $_POST['Occupation'];
$Marital_Status = $_POST['Marital_Status'];
$Number_of_Children = $_POST['Number_of_Children'];
$Phone_Number = $_POST['Phone_Number'];
$Submit = $_POST['Submit'];

/// $date is used for the database entry
if($Submit && $First_Name && $Surname && $Username && $Password && $Email_Address && $Gender && $Date_of_Birth && $City && $Region && $Country && $Postcode && $Religion && $Ethnic_Origin && $Phone_Number && $Marital_Status && $Number_of_Children && $Occupation){
/////
$query = sprintf("INSERT into clients('$First_Name', '$Surname', '$Username', '$Password', '$Email_Address', '$Gender', '$Date_of_Birth', '$City', '$Region', '$Country', '$Postcode', '$Religion', '$Ethnic_Origin', '$Phone_Number', '$Marital_Status', '$Number_of_Children', '$Occupation')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($Submit) {
echo "One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM clients");
$result = @mysql_query($query);
$row = mysql_fetch_array($result);
/////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.style1 {color: #000000}
.style5 {font-size: 24px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="563" border="0">
<tr bordercolor="0">
<td colspan="3" bgcolor="#E4E4E4"><span class="style5">Personal Details</span></td>
</tr>
<tr bordercolor="0">
<td width="266" bgcolor="#F1F1F1"><span class="style1">First Name</span></td>
<td width="123" bgcolor="#FAFAFA"><label>
<input type="text" name="First_Name" id="First_Name" />
</label></td>
<td width="160" bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Surname</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Username</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Username" id="Username" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1">Password</td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Password" id="Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Verify Password</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Verify_Password" id="Verify_Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Email Address</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Email_Address" id="Email_Address" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Gender</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Gender" id="Gender">
<option>Male</option>
<option>Female</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Date of Birth</span></td>
<td bgcolor="#FAFAFA">Day
<select name="Day" id="Day">
<option selected="selected">01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
Month
<select name="Month" id="Month">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
Year
<input name="Month" type="text" id="Month" value="YYYY" size="2" maxlength="4" /></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">City</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="City" id="City" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Region</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Region" id="Region" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Country</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Country" id="Country">
<option>Afghanistan</option>
<option>Argentina</option>
<option>Australia</option>
<option>Austria</option>
<option>Bangladesh</option>
<option>Belgium</option>
<option>Bolivia</option>
<option>Brazil</option>
<option>Bulgaria</option>
<option>Canada</option>
<option>Chile</option>
<option>China</option>
<option>Colombia</option>
<option>Costa Rica</option>
<option>Croatia</option>
<option>Czech Republic</option>
<option>Denmark</option>
<option>Dominican Republic</option>
<option>Ecuador</option>
<option>Egypt</option>
<option>El Salvador</option>
<option>Estonia</option>
<option>Europe</option>
<option>Finland</option>
<option>France</option>
<option>Germany</option>
<option>Greece</option>
<option>Guatemala</option>
<option>Honduras</option>
<option>Hong Kong</option>
<option>Hungary</option>
<option>India</option>
<option>Indonesia</option>
<option>Iraq</option>
<option>Ireland</option>
<option>Israel</option>
<option>Italy</option>
<option>Jamaica</option>
<option>Japan</option>
<option>Jordan</option>
<option>Kenya</option>
<option>Korea</option>
<option>Kazakhstan</option>
<option>Latvia</option>
<option>Lithuania</option>
<option>Latin America</option>
<option>Luxembourg</option>
<option>Macedonia</option>
<option>Malaysia</option>
<option>Mexico</option>
<option>Moldova</option>
<option>Morocco</option>
<option>Netherlands</option>
<option>New Zealand</option>
<option>Norway</option>
<option>Pakistan</option>
<option>Panama</option>
<option>Paraguay</option>
<option>Peru</option>
<option>Philippines</option>
<option>Poland</option>
<option>Portugal</option>
<option>Puerto Rico</option>
<option>Romania</option>
<option>Russia</option>
<option>Saudi Arabia</option>
<option>Serbia and Montenegro</option>
<option>Singapore</option>
<option>Slovakia</option>
<option>Slovenia</option>
<option>South Africa</option>
<option>Spain</option>
<option>Sri Lanka</option>
<option>Sweden</option>
<option>Switzerland</option>
<option>Syria</option>
<option>Taiwan</option>
<option>Thailand</option>
<option>Trinidad and Tobago</option>
<option>Tunisia</option>
<option>Turkey</option>
<option>Ukraine</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Uruguay</option>
<option>Venezuela</option>
<option>Vietnam</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Country_Other" id="Country_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Postcode</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Postcode" id="Postcode" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Religion</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Religion" id="Religion">
<option>Sunni Hanafi</option>
<option>Sunni Humblie</option>
<option>Sunni Maliki</option>
<option>Sunni Shafi</option>
<option>Shia</option>
<option>Just a Muslim</option>
<option>Buddhism</option>
<option>Christianity</option>
<option>Judaism</option>
<option>Hinduism</option>
<option>Sikhism</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Religion_Other" id="Religion_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Ethnic Origin</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Ethnic_Origin" id="Ethnic_Origin">
<option>White English</option>
<option>White Irish</option>
<option>White Scottish</option>
<option>White Welsh</option>
<option>White Other</option>
<option>Asain Bangladeshi</option>
<option>Asain Indian</option>
<option>Asain Pakistani</option>
<option>Asain Other</option>
<option>Black African</option>
<option>Black Carribean</option>
<option>Black Other</option>
<option>Mixed (Please Specify)</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Ethnic Origin_Mixed_Other" id="Ethnic Origin_Mixed_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Occupation</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Occupation" id="Occupation" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Marital Status</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Marital_Status" id="Marital_Status">
<option>Married</option>
<option>Single</option>
<option>Separated</option>
<option>Divorved</option>
<option>Widowed</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Number of Children (if any)</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Number_of_Children" id="Number_of_Children">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>More than 5</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Phone Number (will only be used by us to contact you and will not be shown to any third parties)</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Phone_Number" id="Phone_Number" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bordercolor="0" bgcolor="#F1F1F1">&nbsp;</td>
<td bordercolor="0" bgcolor="#FAFAFA"><label>
<input type="submit" name="Submit" id="Submit" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

davidj
02-23-2008, 12:37 PM
your INSERT statement is incorrect

you have ...


INSERT into clients('$First_Name', '$Surname', '$Username', '$Password', '$Email_Address', '$Gender', '$Date_of_Birth', '$City', '$Region', '$Country', '$Postcode', '$Religion', '$Ethnic_Origin', '$Phone_Number', '$Marital_Status', '$Number_of_Children', '$Occupation')");



It should be


INSERT INTO clients (fields1, fields2, fields3) values ('$variable1', '$variable2');


where fields1 etc are the name of your fields and $variable1 etc is your variables above.. Change my example to suit your needs

davidj
02-23-2008, 12:45 PM
can i just say moe

i admire your interest in this and the fact you chose to learn how to hand code. It will be you who will be taking this to a professional level not the drag-n-drop brigade... You know who you are

give yourself a big highfive from me

moe122
02-23-2008, 09:18 PM
hey,
thnx 4 the comment, jus want it 2 b professional, and you kinda feel better when you do it yourself.......got a lil proplem.....i enter the data but it echos field empty and ive tracked down that its the field 'Number_of_Children' but cant seem to figure out whats actually wrong..........

davidj
02-24-2008, 09:49 AM
post the code

moe122
02-24-2008, 12:11 PM
<?php
require_once("Connections/Connection.php"); // Database Connection
/// create function with argument $date ///
function dateswapper($date){
/// take $date variable and grab the first 4 chars using substr
$y = substr($date,0,4);
/// determine which way round the date is by using an is_numeric boolean function on the first 4 chars
if(is_numeric($y)){

/// if its true then the date is yyyy/mm/dd and therefore needs to be switched for display
$m = substr($date,5,2);
$d = substr($date,8,2);

/// switch the display
$display = $d."-".$m."-".$y;

/// return the value
return $display;

}else{

/// the 4 chars are not numeric so we have detected dd/m

/// lets grab the date elements dd mm yyyy
$d = substr($date,0,2);
$m = substr($date,3,2);
$y = substr($date,6,4);

/// sort them ready for database insert
$input = $y."-".$m."-".$d;

/// return the value
return $input;

}

}
/////
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Email = $_POST['Email'];
$Gender = $_POST['Gender'];
$Day = $_POST['Day'];
$Month= $_POST['Month'];
$Year= $_POST['Year'];
$Date_of_Birth = dateswapper("$Day-$Month-$Year"); // << concatenate the date parts
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);
$City = $_POST['City'];
$Region = $_POST['Region'];
$Country = $_POST['Country'];
$Postcode = $_POST['Postcode'];
$Religion = $_POST['Religion'];
$Ethnic_Origin = $_POST['Ethnic_Origin'];
$Occupation = $_POST['Occupation'];
$Marital_Status = $_POST['Marital_Status'];
$Number_of_Children = $_POST['Number_of_Children'];
$Phone_Number = $_POST['Phone_Number'];
$Submit = $_POST['Submit'];

/// $date is used for the database entry
if($Submit && $First_Name && $Surname && $Username && $Password && $Email && $Gender && $Date_of_Birth && $City && $Region && $Country && $Postcode && $Religion && $Ethnic_Origin && $Phone_Number && $Marital_Status && $Number_of_Children && $Occupation){
/////
$query = sprintf("INSERT into clients (First_Name, Surname, Username, Password, Email, Gender, Date_of_Birth, City, Region, Country, Postcode, Religion, Ethnic_Origin, Phone_Number, Marital_Status, Number_of_Children, Occupation) values ('$First_Name', '$Surname', '$Username', '$Password', '$Email', '$Gender', '$Date_of_Birth', '$City', '$Region', '$Country', '$Postcode', '$Religion', '$Ethnic_Origin', '$Phone_Number', '$Marital_Status', '$Number_of_Children', '$Occupation')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($Submit) {
echo "One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM clients");
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);
/////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form</title>
<style type="text/css">
<!--
.style1 {color: #000000}
.style5 {font-size: 24px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="563" border="0">
<tr bordercolor="0">
<td colspan="3" bgcolor="#E4E4E4"><span class="style5">Personal Details</span></td>
</tr>
<tr bordercolor="0">
<td width="266" bgcolor="#F1F1F1"><span class="style1">First Name</span></td>
<td width="123" bgcolor="#FAFAFA"><label>
<input type="text" name="First_Name" id="First_Name" />
</label></td>
<td width="160" bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Surname</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Username</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Username" id="Username" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1">Password</td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Password" id="Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Verify Password</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Verify_Password" id="Verify_Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Email Address</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Email" id="Email" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Gender</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Gender" id="Gender">
<option>Male</option>
<option>Female</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Date of Birth</span></td>
<td bgcolor="#FAFAFA">Day
<select name="Day" id="Day">
<option selected="selected">01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
Month
<select name="Month" id="Month">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
Year
<input name="Year" type="text" id="Year" value="YYYY" size="2" maxlength="4" /></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">City</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="City" id="City" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Region</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Region" id="Region" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Country</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Country" id="Country">
<option>Afghanistan</option>
<option>Argentina</option>
<option>Australia</option>
<option>Austria</option>
<option>Bangladesh</option>
<option>Belgium</option>
<option>Bolivia</option>
<option>Brazil</option>
<option>Bulgaria</option>
<option>Canada</option>
<option>Chile</option>
<option>China</option>
<option>Colombia</option>
<option>Costa Rica</option>
<option>Croatia</option>
<option>Czech Republic</option>
<option>Denmark</option>
<option>Dominican Republic</option>
<option>Ecuador</option>
<option>Egypt</option>
<option>El Salvador</option>
<option>Estonia</option>
<option>Europe</option>
<option>Finland</option>
<option>France</option>
<option>Germany</option>
<option>Greece</option>
<option>Guatemala</option>
<option>Honduras</option>
<option>Hong Kong</option>
<option>Hungary</option>
<option>India</option>
<option>Indonesia</option>
<option>Iraq</option>
<option>Ireland</option>
<option>Israel</option>
<option>Italy</option>
<option>Jamaica</option>
<option>Japan</option>
<option>Jordan</option>
<option>Kenya</option>
<option>Korea</option>
<option>Kazakhstan</option>
<option>Latvia</option>
<option>Lithuania</option>
<option>Latin America</option>
<option>Luxembourg</option>
<option>Macedonia</option>
<option>Malaysia</option>
<option>Mexico</option>
<option>Moldova</option>
<option>Morocco</option>
<option>Netherlands</option>
<option>New Zealand</option>
<option>Norway</option>
<option>Pakistan</option>
<option>Panama</option>
<option>Paraguay</option>
<option>Peru</option>
<option>Philippines</option>
<option>Poland</option>
<option>Portugal</option>
<option>Puerto Rico</option>
<option>Romania</option>
<option>Russia</option>
<option>Saudi Arabia</option>
<option>Serbia and Montenegro</option>
<option>Singapore</option>
<option>Slovakia</option>
<option>Slovenia</option>
<option>South Africa</option>
<option>Spain</option>
<option>Sri Lanka</option>
<option>Sweden</option>
<option>Switzerland</option>
<option>Syria</option>
<option>Taiwan</option>
<option>Thailand</option>
<option>Trinidad and Tobago</option>
<option>Tunisia</option>
<option>Turkey</option>
<option>Ukraine</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Uruguay</option>
<option>Venezuela</option>
<option>Vietnam</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Country_Other" id="Country_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Postcode</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Postcode" id="Postcode" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Religion</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Religion" id="Religion">
<option>Sunni Hanafi</option>
<option>Sunni Humblie</option>
<option>Sunni Maliki</option>
<option>Sunni Shafi</option>
<option>Shia</option>
<option>Just a Muslim</option>
<option>Buddhism</option>
<option>Christianity</option>
<option>Judaism</option>
<option>Hinduism</option>
<option>Sikhism</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Religion_Other" id="Religion_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Ethnic Origin</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Ethnic_Origin" id="Ethnic_Origin">
<option>White English</option>
<option>White Irish</option>
<option>White Scottish</option>
<option>White Welsh</option>
<option>White Other</option>
<option>Asain Bangladeshi</option>
<option>Asain Indian</option>
<option>Asain Pakistani</option>
<option>Asain Other</option>
<option>Black African</option>
<option>Black Carribean</option>
<option>Black Other</option>
<option>Mixed (Please Specify)</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Ethnic Origin_Mixed_Other" id="Ethnic Origin_Mixed_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Occupation</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Occupation" id="Occupation" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Marital Status</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Marital_Status" id="Marital_Status">
<option>Married</option>
<option>Single</option>
<option>Separated</option>
<option>Divorved</option>
<option>Widowed</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Number of Children (if any)</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Number_of_Children" id="Number_of_Children">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>More than 5</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Phone Number (will only be used by us to contact you and will not be shown to any third parties)</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Phone_Number" id="Phone_Number" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bordercolor="0" bgcolor="#F1F1F1">&nbsp;</td>
<td bordercolor="0" bgcolor="#FAFAFA"><label>
<input type="Submit" name="Submit" id="Submit" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

davidj
02-24-2008, 12:16 PM
dont know what your doing here


$Date_of_Birth = dateswapper("$Day-$Month-$Year"); // << concatenate the date parts
$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);


You have 2 vars doing the same thing

only need


$Date_of_Birth = dateswapper($_POST['Date_of_Birth']);

davidj
02-24-2008, 12:20 PM
Tip..

cut your dateswapper function and paste it into a separate blank page. Remove all HTML from that page but wrap the function in php tags. Call the page say... dateswapper.php then include the page into your main page. This will tidy your code and condense the dateswapper code into one line. Don't forget to comment the line though

moe122
02-24-2008, 12:33 PM
like this? i still get date enterered as 0000-00-00 and what about the other problem with the field Number_of_Children?



<?php
require_once("Connections/Connection.php"); // Database Connection
require_once("Function/Dateswapper.php"); // Dateswapper Function
$First_Name = $_POST['First_Name'];
$Surname = $_POST['Surname'];
$Username = $_POST['Username'];
$Password = $_POST['Password'];
$Email = $_POST['Email'];
$Gender = $_POST['Gender'];
$Day = $_POST['Day'];
$Month= $_POST['Month'];
$Year= $_POST['Year'];
$Date_of_Birth = dateswapper($_POST['$Day-$Month-$Year']); // << concatenate the date parts
$City = $_POST['City'];
$Region = $_POST['Region'];
$Country = $_POST['Country'];
$Postcode = $_POST['Postcode'];
$Religion = $_POST['Religion'];
$Ethnic_Origin = $_POST['Ethnic_Origin'];
$Occupation = $_POST['Occupation'];
$Marital_Status = $_POST['Marital_Status'];
$Number_of_Children = $_POST['Number_of_Children'];
$Phone_Number = $_POST['Phone_Number'];
$Submit = $_POST['Submit'];

/// $date is used for the database entry
if($Submit && $First_Name && $Surname && $Username && $Password && $Email && $Gender && $Date_of_Birth && $City && $Region && $Country && $Postcode && $Religion && $Ethnic_Origin && $Phone_Number && $Marital_Status && $Number_of_Children && $Occupation){
/////
$query = sprintf("INSERT into clients (First_Name, Surname, Username, Password, Email, Gender, Date_of_Birth, City, Region, Country, Postcode, Religion, Ethnic_Origin, Phone_Number, Marital_Status, Number_of_Children, Occupation) values ('$First_Name', '$Surname', '$Username', '$Password', '$Email', '$Gender', '$Date_of_Birth', '$City', '$Region', '$Country', '$Postcode', '$Religion', '$Ethnic_Origin', '$Phone_Number', '$Marital_Status', '$Number_of_Children','$Occupation')");
mysql_query ($query) or die (mysql_error());
/////
}elseif($Submit) {
echo "One of your fields is empty !";
}
/////
$query = sprintf("SELECT * FROM clients");
$result = @mysql_query($query);
$row = @mysql_fetch_array($result);
/////
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Form</title>
<style type="text/css">
<!--
.style1 {color: #000000}
.style5 {font-size: 24px}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="563" border="0">
<tr bordercolor="0">
<td colspan="3" bgcolor="#E4E4E4"><span class="style5">Personal Details</span></td>
</tr>
<tr bordercolor="0">
<td width="266" bgcolor="#F1F1F1"><span class="style1">First Name</span></td>
<td width="123" bgcolor="#FAFAFA"><label>
<input type="text" name="First_Name" id="First_Name" />
</label></td>
<td width="160" bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Surname</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Surname" id="Surname" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Username</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Username" id="Username" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1">Password</td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Password" id="Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Verify Password</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="password" name="Verify_Password" id="Verify_Password" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Email Address</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Email" id="Email" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Gender</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Gender" id="Gender">
<option>Male</option>
<option>Female</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Date of Birth</span></td>
<td bgcolor="#FAFAFA">Day
<select name="Day" id="Day">
<option selected="selected">01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
<option>13</option>
<option>14</option>
<option>15</option>
<option>16</option>
<option>17</option>
<option>18</option>
<option>19</option>
<option>20</option>
<option>21</option>
<option>22</option>
<option>23</option>
<option>24</option>
<option>25</option>
<option>26</option>
<option>27</option>
<option>28</option>
<option>29</option>
<option>30</option>
<option>31</option>
</select>
Month
<select name="Month" id="Month">
<option>01</option>
<option>02</option>
<option>03</option>
<option>04</option>
<option>05</option>
<option>06</option>
<option>07</option>
<option>08</option>
<option>09</option>
<option>10</option>
<option>11</option>
<option>12</option>
</select>
Year
<input name="Year" type="text" id="Year" value="YYYY" size="2" maxlength="4" /></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">City</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="City" id="City" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Region</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Region" id="Region" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Country</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Country" id="Country">
<option>Afghanistan</option>
<option>Argentina</option>
<option>Australia</option>
<option>Austria</option>
<option>Bangladesh</option>
<option>Belgium</option>
<option>Bolivia</option>
<option>Brazil</option>
<option>Bulgaria</option>
<option>Canada</option>
<option>Chile</option>
<option>China</option>
<option>Colombia</option>
<option>Costa Rica</option>
<option>Croatia</option>
<option>Czech Republic</option>
<option>Denmark</option>
<option>Dominican Republic</option>
<option>Ecuador</option>
<option>Egypt</option>
<option>El Salvador</option>
<option>Estonia</option>
<option>Europe</option>
<option>Finland</option>
<option>France</option>
<option>Germany</option>
<option>Greece</option>
<option>Guatemala</option>
<option>Honduras</option>
<option>Hong Kong</option>
<option>Hungary</option>
<option>India</option>
<option>Indonesia</option>
<option>Iraq</option>
<option>Ireland</option>
<option>Israel</option>
<option>Italy</option>
<option>Jamaica</option>
<option>Japan</option>
<option>Jordan</option>
<option>Kenya</option>
<option>Korea</option>
<option>Kazakhstan</option>
<option>Latvia</option>
<option>Lithuania</option>
<option>Latin America</option>
<option>Luxembourg</option>
<option>Macedonia</option>
<option>Malaysia</option>
<option>Mexico</option>
<option>Moldova</option>
<option>Morocco</option>
<option>Netherlands</option>
<option>New Zealand</option>
<option>Norway</option>
<option>Pakistan</option>
<option>Panama</option>
<option>Paraguay</option>
<option>Peru</option>
<option>Philippines</option>
<option>Poland</option>
<option>Portugal</option>
<option>Puerto Rico</option>
<option>Romania</option>
<option>Russia</option>
<option>Saudi Arabia</option>
<option>Serbia and Montenegro</option>
<option>Singapore</option>
<option>Slovakia</option>
<option>Slovenia</option>
<option>South Africa</option>
<option>Spain</option>
<option>Sri Lanka</option>
<option>Sweden</option>
<option>Switzerland</option>
<option>Syria</option>
<option>Taiwan</option>
<option>Thailand</option>
<option>Trinidad and Tobago</option>
<option>Tunisia</option>
<option>Turkey</option>
<option>Ukraine</option>
<option>United Kingdom</option>
<option>United States</option>
<option>Uruguay</option>
<option>Venezuela</option>
<option>Vietnam</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Country_Other" id="Country_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Postcode</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Postcode" id="Postcode" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Religion</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Religion" id="Religion">
<option>Sunni Hanafi</option>
<option>Sunni Humblie</option>
<option>Sunni Maliki</option>
<option>Sunni Shafi</option>
<option>Shia</option>
<option>Just a Muslim</option>
<option>Buddhism</option>
<option>Christianity</option>
<option>Judaism</option>
<option>Hinduism</option>
<option>Sikhism</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Religion_Other" id="Religion_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Ethnic Origin</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Ethnic_Origin" id="Ethnic_Origin">
<option>White English</option>
<option>White Irish</option>
<option>White Scottish</option>
<option>White Welsh</option>
<option>White Other</option>
<option>Asain Bangladeshi</option>
<option>Asain Indian</option>
<option>Asain Pakistani</option>
<option>Asain Other</option>
<option>Black African</option>
<option>Black Carribean</option>
<option>Black Other</option>
<option>Mixed (Please Specify)</option>
<option>Other (Please Specify)</option>
</select>
</label></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Ethnic Origin_Mixed_Other" id="Ethnic Origin_Mixed_Other" />
</label></td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Occupation</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Occupation" id="Occupation" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Marital Status</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Marital_Status" id="Marital_Status">
<option>Married</option>
<option>Single</option>
<option>Separated</option>
<option>Divorved</option>
<option>Widowed</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Number of Children (if any)</span></td>
<td bgcolor="#FAFAFA"><label>
<select name="Number_of_Children" id="Number_of_Children">
<option>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
<option>5</option>
<option>More than 5</option>
</select>
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bgcolor="#F1F1F1"><span class="style1">Phone Number (will only be used by us to contact you and will not be shown to any third parties)</span></td>
<td bgcolor="#FAFAFA"><label>
<input type="text" name="Phone_Number" id="Phone_Number" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
<tr bordercolor="0">
<td bordercolor="0" bgcolor="#F1F1F1">&nbsp;</td>
<td bordercolor="0" bgcolor="#FAFAFA"><label>
<input type="Submit" name="Submit" id="Submit" value="Submit" />
<input name="Submit" type="hidden" id="Submit" value="1" />
</label></td>
<td bgcolor="#FAFAFA">&nbsp;</td>
</tr>
</table>
</form>
</body>
</html>

davidj
02-24-2008, 12:36 PM
ok

i have checked your code

regarding your dateswapper function

you are already accepting the date in its component parts and as i pointed out you are using 2 vars which do the same thing

ok

you dont need the dateswapper function when inserting data into the db because you can catch the values from the fields and format them normally

example...


$date = "$year-$month-$day";


so in that example you would use $date in your SQL

there is no need to use the function i wrote in that example

you should use the function when displaying a date from the db though

davidj
02-24-2008, 12:37 PM
use code (PHP) tags please when posting code

davidj
02-24-2008, 12:42 PM
what is this field for...

Ethnic Origin_Mixed_Other


Its not going into the db

davidj
02-24-2008, 12:44 PM
use an include on the dateswapper instead of a require_once

davidj
02-24-2008, 12:51 PM
you have this ...


elseif($Submit) {
echo "One of your fields is empty !";
}

i advise that you use a variable and assign the message to that

never echo a string outside the HTML

do this instead


elseif($Submit) {
$error = "One of your fields is empty !";
}


now you have control over where you output the $error var

moe122
02-24-2008, 12:53 PM
ok i have sorted the problem with the date but still got the other problem :(

davidj
02-24-2008, 01:00 PM
and the reason for the original problem...

you dont have any values in your <options> for the <select> fields

i can understand the basic errors that your doing in your php but this is a very basic day 1 HTML error. You should know this level of HTML. You need to study HTML before you post. This should jump out at you.

moe122
02-24-2008, 01:15 PM
ok i need to write some rules/validations on some fields like

1 text only then enter into database
2 if both field match .........
3 must contain '@'......
4 number only
5 if this option is selected enter such a field in.....

and what validation would you have on postcode?

davidj
02-24-2008, 01:16 PM
new topic new post