Hi Guys,
Completely new to PHP! Just wanted to play around with Fields and submit stuff to a database on localhost through xampp.
This code writes to the database no problem, except no insert is happening with 'Telephone' and it throws this error;
Notice: Undefined index: Telephone in C:\xampp\htdocs\Inputs\update.php on line 9
Could you please inform me how i can maybe improve this code, and sort this error out?
Logic behind it is when the fields are all filled in great! However I was to bring into this if the same email has
been entered then it will throw an exception. I have set in the database 'Code' to be UNIQUE when tested it throws a message
saying duplicate entry. How can I improve this?
Many Thanks! :)
<!DOCTYPE html>
<html>
<head>
<title>Wowcher Code Submission</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<div class="container">
<form method ="post" action="update.php">
<label>First name:</label><br>
<input type="text" name="First_Name"><br>
<label>Last name:</label><br>
<input type="text" name="Last_Name"><br>
<label>Email:</label><br>
<input type="text" name="Email"><br>
<label>Wowcher Code:</label><br>
<input type="text" name="Code"><br>
<label>Telephone Number:</label><br>
<input type="text" name="Phone"><br>
<input type="submit" value="Submit">
</form>
</div>
</body>
</html>
<?php
mysql_connect ("localhost", "root", "root") or die ('Error: ' . mysql_error());
mysql_select_db ("wowcher") or die ('Error: ' . mysql_error());
$First_name = $_POST['First_Name'];
$Surname = $_POST['Last_Name'];
$Email = $_POST['Email'];
$Code = $_POST['Code'];
$Telephone = $_POST['Telephone'];
$id=isset($_POST['$Telephone']) ? trim($_POST["$Telephone"]) : "";
$query="INSERT INTO wowcher_code(First_name, Last_Name, Email, Code, Telephone)VALUES ('".$First_name."', '".$Surname."', '".$Email."', '".$Code."', '".$Telephone."')";
mysql_query($query) or die ('Error updating database because: '.mysql_error());
//if(isset($_POST['notify_box'])){ $notify = $_POST['notify_box']; }
echo "Details succesfully added!!"
?>