There are two buttons on the form, a submit button and a clear button. If the user pushes the clear button, your code sh

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

There are two buttons on the form, a submit button and a clear button. If the user pushes the clear button, your code sh

Post by answerhappygod »

There Are Two Buttons On The Form A Submit Button And A Clear Button If The User Pushes The Clear Button Your Code Sh 1
There Are Two Buttons On The Form A Submit Button And A Clear Button If The User Pushes The Clear Button Your Code Sh 1 (94.73 KiB) Viewed 72 times
There are two buttons on the form, a submit button and a clear button. If the user pushes the clear button, your code should clear out all the entries in the form. Submit button. Once the user pushes the submit button the data will be available to a php script. Use the $_POST to retrieve the data from the form. Your code will need to: 1. Connect to the database. 2. Check for a valid connection. 3. Create the php to insert the form data. Here is a sample set of code: <?php include_once 'db.php'; // in this example, this file does the connection to the database if (isset($_POST['submit'])) { $name = $_POST['name']; $email = $_POST['email']; $mobile = $_POST['mobile']; $sql = "INSERT INTO users (name, email, mobile) VALUES ('$name', '$email', 'mobile')"; if (mysqli_query($conn, $sql)) { echo "New record has been added successfully !"; } else { echo "Error: ". $sql . ":-". mysqli_error($conn); ] mysqli_close($conn); } ?> The db.php code is: <?php $servername='localhost'; $username='root'; $password=''; $dbname = "my_db"; $conn=mysqli_connect($servername, $username, $password, "$dbname"); if(!$conn) { die ('Could not Connect Mysql Server:' .mysql_error()); ?>
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply