Hello everyone,
I’m a complete beginner to php. I’m trying to learn PHP through self-study and have reached an obstacle which I’ve not been able to overcome and need.
The problem is that when I open my php form in a web browser, the following error message appears:
Notice: Undefined index: firstname in C:\xampp\htdocs\form_1\CONTACT_DETAILS_dataentry.php
on line 20
Notice: Undefined index: surname in C:\xampp\htdocs\form_1\CONTACT_DETAILS_dataentry.php on line 21
Notice: Undefined index: telephone_no in C:\xampp\htdocs \form_1\CONTACT_DETAILS_dataentry.php on line 22
Notice: Undefined index: emailaddress in C:\xampp\htdocs\form_1\CONTACT_DETAILS_dataentry.php on line 23
I’m using the following script
[php]<?php
include “cdconnect.php”;
?>
Enter Design
FirstnameSurname:
Telephone_no:
Emailaddress:
<?php //variables get values from form $firstname = $_POST['firstname']; $surname = $_POST['surname']; $telephone_no = $_POST['telephone_no']; $emailaddress = $_POST['emailaddress']; $query = "INSERT INTO contact_details (firstname,surname,telephone_no,emailaddress) VALUES ( '$firstname', '$surname', '$telephone_no', '$emailaddress')"; mysql_query($query) OR die(mysql_error()); if(isset($_POST['firstname'])) { $firstname = $_POST['firstname']; } if(isset($_POST['surname'])) { $surname = $_POST['surname']; } if(isset($_POST['telephone_no'])) { $telephone_no = $_POST['telephone_no']; } if(isset($_POST['emailaddress'])) { $emailaddress = $_POST['emailaddress']; } mysql_CLOSE(); ?> [/php]
I’ll be grateful for any assistance. Thanks