I am trying to create a page where my members can upload information to a mysql table using an on page form - I would want my form to have two inputs one for first name and one for last name and then a submit button which when pressed will send the info to mysql database. I also have two other fields in my mysql database (date uploaded and person who uploaded) With these I need to find a way that will instruct the database to date/time stamp the info and as for the person uploading I am going to password protect the page for individual users so I will know who is on the page and need to somehow send this to the database. I have made a start on some of the functions and pasted the form I am using and my php file below (these are snippets from the web which I am struggling to make work) as you may have guessed I am a beginner with php and mysql so any help needs to be dumbed down so I can understand it ha. <form action="contact_insert.php" method="POST" id="insert"> <table> <tr> <td >First Name</td> <td ><input type="text" size=40 name="fname"></td> </tr> <tr> <td >Last Name</td> <td ><input type="text" size=40 name="lname"></td> </tr> <tr> <td colspan=2 id="sub"><input type="submit" name="submit" value="Add to Guestlist" ></td> </tr> </Table> </form> and the contact_insert.php file is: <?php // contact to database $connect = mysql_connect("localhost", "user", "pass") or die ("Error , check your server connection."); mysql_select_db("database"); //Get data in local variable $v_fname=$_POST['fname']; $v_lname=$_POST['lname']; // check for null values if ($v_fname=="" or $v_lname=="") echo "All fields must be entered, hit back button and re-enter information"; else{ $query=insert into "database","table"("fname","lname") values("$v_fname","$v_lname",); mysql_query($query) or die(mysql_error()); echo "Your guest has been added"; } ?> Thanks in advance for any help
For the date/time you just need to add a new column to the database with a type of TimeStamp and set the default to the current timestamp thus when you insert a new row it will set the time for you ColumnName TIMESTAMP DEFAULT CURRENT_TIMESTAMP Code (markup): For the Username, it will depend on how you are doing the user aspect but its a simple new column and adding the username to the insert query