MySQL Forums
Forum List  »  PHP

Connecting myPHPadmin to web page
Posted by: None None
Date: October 01, 2017 03:08AM

Hi everyone!

Hope someone doesn't mind answering this question for me. I know it's probably been asked a million times over but the information I have come across seems to be over my head, so please forgive me.

I have been trying to enter data onto a web page and have it entered into a database. The database I use is through Mamp for Windows. I seem to be connected when I put localhost:8888 into my web browser (Chrome) but I cannot seem to get the form to enter data directly to the database.

Here's the code I came upon and altered somewhat...

<head><title>Insert People</title></head>
<form action="connect.php" method="post">
<label>* First Name<br><input type="text" name="fName" size="33" value="First" required></label><br>
<label>* Last Name<br><input type="text" name="lName" size="33" value="Last" required></label><br>

<input type="submit" value="add">



mysql_connect("localhost", "root", "root") or die ("not connected");
mysql_select_db("test") or die("no db found");

$fName = $_POST['fName'];
$lName = $_POST['lName'];

$query = "INSERT INTO test_people (fName, lName) VALUES ('$fName', '$lName')";
echo "Data entered successfully!";



The name of my database is test and the database that contains the fields is named test_people. The name of this file is connect.php and is located within my htdocs folder in Mamp. The names in the fields of the database are id, fName and lName.

Can someone PLEASE tell me what I have missed? I would really, really appreciate it.

Thanks in advance for any help you can offer.

Options: ReplyQuote

Written By
Connecting myPHPadmin to web page
October 01, 2017 03:08AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.