Okay, so this is the first time ever that I have posted to get help with code so I am kind of shy to display my work. Here is my problem that I am having. I am NEW to php and I am creating a website. Eventually, I want to be able to to have a login system in which users have to login to view the site. I started tonight by learning about the databases and how they can be manipulated to add data from a user input. I use cPanel, myPHPadmin and have created the database, a user for the database with all privileges granted.
- I have created the form in a .html page with the following code:
[code]
For testing purposes, please enter in your information Your Name: Your Email: [/code] The submit button on this page, sends the user to insert.php which has this code: [php]<?phpmysql_connect(“localhost”, “daddyhog_first”, “kt041609”) or die(mysql_error());
mysql_select_db(“daddyhog_firstTesting”) or die(mysql_error());
$username=$_POST[‘name’];
$email=$_POST[‘email’];
$sql=“INSERT INTO People(name, email)VALUES(’$name’, ‘$email’)”;
$result=mysql_query($sql);
if($result){
echo “Successful”;
echo “
”;
echo “Back to main page”;
}
else {
echo “ERROR”;
}
?>
Now in the mysql_connect(“localhost”, “daddyhog_first”, “kt041609”) I have a few questionis please.
The localhost. Does this have to be localhost or where is this supposed to get directed from.
The user name is daddyhog_first which has all permissions
kt041609 is the password for the user.
Now when I go to the index.html and enter information in the form, i’m redirected to the .php page with the word ERROR, as suggested in the echo call out if something is going wrong. I have been at this for a few hours, what is it that i’m not understanding.
Please and thank you for your time in this matter.
I look forward to actively learning more