keykeeper Posted April 7, 2014 Report Share Posted April 7, 2014 hi all i am looking to set up a simple php page the idea is that someone would come on to the web page and see a form like add name ( textbox ) click send ( button ) once they add there name i want to display it in a table below and have a counter which will count up the number of names on the list automatically any ideas on how i could do this ? it a very simple idea and i know it would be simple to make but not sure how too Link to comment Share on other sites More sharing options...
keykeeper Posted April 7, 2014 Author Report Share Posted April 7, 2014 so i been trying this <?php if (isset($_POST['submit'])) { if(empty($_POST['fname'])) { die("Fill in the first name field."); } if(empty($_POST['lname'])) { die("Fill in the last name field."); } include('connect-mysql.php'); $fname = mysqli_real_escape_string($dbcon,trim($_POST['fname'])); $lname = mysqli_real_escape_string($dbcon,trim($_POST['lname'])); $sqlinsert = "INSERT INTO `users` (firstname, lastname) VALUES ('" . $fname . "','" . $lname . "')"; if (!mysqli_query($dbcon, $sqlinsert)) { die('error inserting new record'); } //end of nested if echo "1 record added to the database"; } // end of the main if statement ?> <html> <head> <title>Insert Data into DB</title> </head> <body> <hl>Insert Data into DB</hl> <form method="post" action=""> <fieldset> <legend>New People</legend> <label>First Name:<input type="text" name="fname" /></label> <label>Last Name:<input type="text" name="lname" /></label> </fieldset> <br /> <input type="submit" name="submit" value="add new person" /> </form> <?php echo $newrecord; ?> </body> </html> how ever i keep getting ( error inserting new record ) what do i need to create in the table ? and how do i display it then ? any help would be great Link to comment Share on other sites More sharing options...
keykeeper Posted April 7, 2014 Author Report Share Posted April 7, 2014 so got it to add names to database. any ideas on how to count and display list on a page now ? Link to comment Share on other sites More sharing options...
marclewis Posted April 3, 2015 Report Share Posted April 3, 2015 Thanks for the code help Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now