How to make a contact form database? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

How to make a contact form database?

I have tried but I couldn't bcz I didn't learn yet php. I had created database and table but I couldn't connect. I had collect some code and edited: https://code.sololearn.com/wD22XwjqhHqT/?ref=app

6th May 2020, 9:28 AM
Md Azim Hossen
Md Azim Hossen - avatar
8 Answers
+ 2
Follow Following steps. 1. Start the server 2. Create New Database and table using phpmyadmin http://localhost/phpmyadmin 3. Connect MySQL in PHP code <?php $servername = "localhost"; $username = "username"; $password = "password"; // Create connection $conn = new mysqli($servername, $username, $password); ?> 4. Get form value and run insert query in php code. $sql = "INSERT INTO table_name (name, email, phone) VALUES ('Lokesh', '[email protected]', '8764335768')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; } else { echo "Error: " . $sql . "<br>" . $conn->error; } $conn->close();
11th May 2020, 5:55 PM
Lokesh Gupta
Lokesh Gupta - avatar
+ 5
Thanks bro
7th May 2020, 4:33 AM
Md Azim Hossen
Md Azim Hossen - avatar
+ 4
Thank you
12th May 2020, 1:26 AM
Md Azim Hossen
Md Azim Hossen - avatar
+ 4
I had created in this way. I am success but it's so simple I didn't khow. 😃
12th May 2020, 1:30 AM
Md Azim Hossen
Md Azim Hossen - avatar
+ 2
🌳Azim🐝 Hello there, you can not connect the database here on SoloLearn. Nevertheless, you can make a local server on your phone. How to install a local server? I am assuming, you are working with an Android phone. 1) So, go to play store and search for the app 'Penguin Server Apk', download and install it. 2) Start the server 3) Go to phpmyadmin, create a database and get the username and password 4) Then write the same php code in your phone with an editor and run it. If you can do all the steps correctly, you will be able to connect the database :))
7th May 2020, 4:30 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 2
Let me know if you could successfully do it :))
7th May 2020, 4:36 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 1
You cannot connect because SoloLearn don't have database support for the code playground in PHP if I remember correctly
6th May 2020, 3:17 PM
Ahnaf
Ahnaf - avatar
+ 1
Ok! Bro.
7th May 2020, 4:40 AM
Md Azim Hossen
Md Azim Hossen - avatar