Hello there, I’m wondering if anyone can help me? I am adding an enrolment and diary logging system to a company website and as i am a novice with PHP this problem is giving me some hassle.
What i want is to provide the learners with a pre-made username and password. Then once they log in it loads up the Enrolment.php and once they fill in the form on that page and click submit it puts their information on the users table on my mysql DB. Instead i get something that looks like this (ID is auto increment and username as passwors are made by me:)
ID | Username | Password | First Name | Last Name |
1 Test 1234
Test Testingsworth
It treats it as a new entry. This was my code that did the above.
[php]<?php
error_reporting(0);
session_start();
if (!isset($_POST[‘submit’]))
{
$male= $_POST [‘m_14’];
$female= $_POST [‘f_15’];
$fname= $_POST [‘fn_21’];
$lname= $_POST [‘ln_22’];
$dob= $_POST [‘dob_25’];
$housename= $_POST [‘hn_23’];
$housestreet= $_POST [‘hs_24’];
$pcode= $_POST [‘pc_31’];
$nino= $_POST [‘ni_26’];
$homephone= $_POST [‘ht_28’];
$mobilephone= $_POST [‘mt_30’];
$email= $_POST [‘em_32’];
$emergencyname= $_POST [‘ecn_33’];
$emergencynum= $_POST [‘ecn_34’];
$connect = mysql_connect("127.0.0.1","root","") or die ("Could not Connect to DB");
mysql_select_db("users") or die ("Could not find Database");
$query = mysql_query("INSERT INTO user VALUES ('','','','$male','$female','$fname','$lname','$dob','$housename','$housestreet','$pcode','$nino','$homephone','$mobilephone','$email','$emergencyname','$emergencynum')") or
die ("Thankyou");
}
?>[/php]
Then someone suggested this. Now no data will go in the data base but apparently the WHERE statement should work.
New code (as described above)
[php]<?php
error_reporting(0);
session_start();
if (!isset($_POST[‘submit’]))
{
$male= $_POST ['m_14'];
$female= $_POST ['f_15'];
$fname= $_POST ['fn_21'];
$lname= $_POST ['ln_22'];
$dob= $_POST ['dob_25'];
$housename= $_POST ['hn_23'];
$housestreet= $_POST ['hs_24'];
$pcode= $_POST ['pc_31'];
$nino= $_POST ['ni_26'];
$homephone= $_POST ['ht_28'];
$mobilephone= $_POST ['mt_30'];
$email= $_POST ['em_32'];
$emergencyname= $_POST ['ecn_33'];
$emergencynum= $_POST ['ecn_34'];
$connect = mysql_connect("127.0.0.1","root","") or die ("Could not Connect to DB");
mysql_select_db("users") or die ("Could not find Database");
$query = mysql_query("UPDATE `user` SET '$male', '$female', `fn_21`='$fname', `ln_22`='$ln', `dob_25`='$dob', `hn_23`='$housename', `hs_24`='$housestreet', `pc_31`='$pcode', `ni_26`='$nino', `ht_28`='$homephone', `mt_30`='$mobilephone, em_32`='$email', `ecn_33`='$emergencyname', `ecn_34`='$emergencynum' WHERE `ID`='1'");
}
?>[/php]
Can anyone help/suggest or even fix this? I would be Hugely apprechaiteive. I am more then happy to Zip up my site and send it if it helps. Also please find a ScreenShot of my Database here Never mind it wont let me add an image…I can e-mail it if it helps…

