Make sure to watch the UPDATED version of this tutorial here: https://www.youtube.com/watch?v=BmHLvUdkCA0&list=PL530D33D6E548481F&index=1 For …
Original source
Make sure to watch the UPDATED version of this tutorial here: https://www.youtube.com/watch?v=BmHLvUdkCA0&list=PL530D33D6E548481F&index=1 For …
Original source
47 responses to “How to Create an HTML Form That Stores Data in a MySQL Database Using PHP Part 3 of 4”
good tutorial, but the "watch updated version" is blocking the screen.
what is this mysqli……..it is creating many difficulties
when i use your codes this the result:
Fatal error: Uncaught Error: Call to undefined function mysql_connect() in C:xampphtdocsgsdemo.php:8 Stack trace: #0 {main} thrown in C:xampphtdocsgsdemo.php on line 8
I am getting the following when execute the connection:
Warning: mysql_connect(): php_network_getaddresses: getaddrinfo failed: The requested name is valid, but no data of the requested type was found. in C:xampphtdocstutorialsphpbasicsdemo.php on line 9
My code is:
<?php
//defining constants syntax: define('constants', 'value');
define('DB_NAME', 'mysql');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST','localhost');
//connecting the host
$link = mysql_connect(DB_USER, DB_PASSWORD, DB_HOST);
if(!$link){
die('Could not connect: '.mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if(!$db_selected){
die('Can/t use '.DB_NAME. ':'.mysql_error());
}
echo 'Connected Successfully!';
?>
Please help
Hi, I dont know why it show me the whole php code for me… ?
<?php
DEFINE ('DB_USER', 'root');
DEFINE ('DB_PASSWORD','');
DEFINE ('DB_HOST','localhost');
DEFINE ('DB_NAME','aptc');
$dbc =mysql_connect(DB_NAME,DB_HOST,DB_PASSWORD,DB_USER)
if (!$dbc)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME,$dbc);
if (!$db_selected){
die ('cant use' . DB_NAME . ': ' . mysql_error());
}
echo 'Connected Successfully';
?>
Do you have a tutorial on how to create a form that uploads to an SQL database and sends a confirmation e-mail?
what is problem with my code:
<?php
define('DB_NAME','info');
define('DB_USER','usename');
define('DB_PASSWORD','');
define('DB_HOST','localhost');
$link=mysql_connect(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
if(!$link)
{
die("couldnt connect". mysql_error());
}
$db_selected=mysql_select_db(DB_NAME,$link);
if(!$db_selected)
{
die("couldnt connect" . DB_NAME . ":" mysql_error());
}
echo"connected successfully";
?>
Make sure to watch the UPDATED version of this tutorial here: https://www.youtube.com/watch?v=BmHLvUdkCA0&list=PL530D33D6E548481F&index=1
I've followed tutorial exactly and love it. But on my server side, there is no data that is showing up? Any suggestions?
Thanks for the tutorial, but I have a quick question for you, if I want to have more than one input in the form (lets say first name and last name), how can I differentiate between those two? Will I need something like $value1 = $_POST['input1']; and $value2 = $_POST['input2']; and do the SQL query for those inputs?
thanks you i have a massive grin on my face :)))))
my code returns " MySQL returned an empty result set (i.e. zero rows). (Query took 0.0008 sec)
What is the problem with my code?
<?php
define('DB_NAME', 'forms1');
define('DB_USER', 'root');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db(DB_NAME, $link);
if (!$db_selected) {
die('Cant use ' . DB_NAME . ': ' . mysql_error());
}
echo 'Connected Successfully';
mysql_close();
?>
thanks done bro 😉
how can i fix these:
Undefined index: input1 in C:wampwwwdemo.php on line 20
How do i fix this? 😮 "Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in C:wampwwwdemo.php on line 8"
I get the error "Warning: mysql_select_db() expects parameter 2 to be resource, object given in C:wampwwwcontact.php on line 14"
i wish i could have a better look in line 21 .. please!
4 years later, this is EXACTLY what I need. Thank you very much sir!
it said i cant use form1, and iono why and how to fix error.
Hai Sir … Thank you very much it was very useful for me…but please help me to add one more tab like input 1.Please sir !
Thank You John U tha Man Helped me out Big Time
Thanks so much. I am heading to your site now.
Ok, I've just watched your final video (4/4) and I got it. Can you please post the link for the video "advanced form construction" you have mentioned.
Thank you
Fábio
$value = $_POST ['input1'];
$value2 = $_POST['input2'];
$sql = "INSERT INTO demo (input1, input2) VALUES ('$value', '$value2')";
That's a very rudimentary way of doing. I'd loop through the $_POST array and build everything dynamically. Also, this isn't secure at all. Dropping $_POST data straight into your database is a huge no-no. Nowadays you use prepared statements. Go to my site (in description) /mysql if you just want all the answers.
Nice tutorial.
My question is:
You've got the following code:
==========
$value = $_POST ['input1'];
$sql = "INSERT INTO demo (input1) VALUES ('$value')";
==========
So, considering i've got input2, input3 in my database, how do I send those multiples values to my database?
Appreciate your time.
this is awesome, thanks a ton.
Best place to go to see them all is the playlist here:
/watch?v=J2-neLr7MXM&list=PL530D33D6E548481F
Hi there and thanks a lot for your tutorails.
Could you put a link to the next 'episode' ? because i can't find the last part .
Thanks
Well, I don't have this code anymore otherwise I would have it linked up on my website. So, I don't have anything to send you.
The thing is, though, you say you're getting "syntax" errors. I'm going to push back and say you need to figure those out. If you were getting some other kind of error… ok
But, syntax is really basic PHP. And, my goal is to teach you the code… not just give it to you. So, I feel like you need to figure out the syntax errors. I think I'd be doing you a dis-service.
shanebloem@gmail.com
iv raped google, on the verge of going to a library!
Please could you send me the complete html and php as well as detailed info on how to link up the php to mysql. reason is because i get syntax errors when copying ur script off ur video, would be much appreciated and would be a noble worrier for helpful programming expertise if ur interested. kind regards contact +2776 147 9134 only or respond to my query
I did a test demo the exact way you did. I was taken to a blank page on submit…
thanks john
Ok, I am following along, but is there anywhere that you explain how to put in a success message? Like, once someone uses my form and the information has been successfully submitted, they should get a message like "thank you for submitting." Do you explain that anywhere? Or can you tell me how to do that PLEASE? I'm so close to having this all worked out!!!
Thank you
oh, one more thing. My form has multiple values, and I have described them carefully on the php file.
I have followed your instruction carefully step by step. But when I tried to submit my form,there's a undefined index notice on my browser, and the input didn't get to mysql. where did I go wrong? I use dreamweaver as an editor, and xampp package. Thanks bro.
Your code was missing an = sign. It should be name="input1"
Is your form field named "input1". If not, you'll need to change $_POST['input1'] to whatever the name of your form field is.
I made a form in html, then I use action="sampledb.php" method="post".. When I input data from the html page, the data won't show in mysql database..
this videos helped me a lot with my assignment.
Fatal error: Function name must be a string in / ***/script.php on line 27
it was working up until I did the sql query??
Excellent tutorial. I was having some issues on a school assignment and this tutorial straightened it right up. Thanks!
do you have to upload the image with a name?
Hey dude, what a great video-serie it is!
Thank you for your great way of explaining, however….. the demo.php (i've called it save.php) doesn't do anything! it just stays blank, no echo and no error…. could you help me out?
What information do you need?
the same as me bro