Why wont this work? It does not put anything in my DB! :'(

code (this one chucks a million and one of these Notice: Undefined index: username in C:\wamp\www\HOME\rarpa3.php on line 8… so on and so forth)
[php]

<?php error_reporting(E_ALL); session_start(); if (!isset($_POST['submit'])) { $username= $_POST ['username']; $password= $_POST ['password']; $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 ('','$username','$password','$male','$female','$fname','$lname','$dob','$housename','$housestreet','$pcode','$nino','$homephone','$mobilephone','$email','$emergencyname','$emergencynum')") or die ("Thankyou"); } else { echo "dont work"; } ?> RARPA body{margin:0;padding:0;} .Artistic-Body-C { font-family:"Verdana", sans-serif; font-size:107.0px; line-height:1.21em; } .Body-C { font-family:"Verdana", sans-serif; font-size:16.0px; line-height:1.13em; } .Artistic-Body-C-C0 { font-family:"Verdana", sans-serif; font-size:40.0px; line-height:1.20em; }
RARPA
<?php if ($_SESSION['username']) { echo "You are Logged in as: ".$_SESSION['username']; } ?>

Username

Password

Male

Female

First Name

Last Name

Date Of Birth

House Number

Street Name

Postcode

National Insurance Number

House Telephone

Mobile Telephone

E-mail Address

Emergency Contact Name

Emergency Contact Number

Enrollee Information
Hello, Welcome.
[/php]

I cannot see why!

This says execute the code if submit is NOT set. Why do that? :o

[php]if (!isset($_POST[‘submit’]))[/php]

Where? Im a Complete novice. How do l fix?

Get rid of the ! on that line. The ! basically says “isn’t”. So your code is saying if the form HAS NOT been submitted run the query, rather than run the query if the form HAS been submitted

Sponsor our Newsletter | Privacy Policy | Terms of Service