Hello,
I am new to this php language although I have been stuck on this particular problem for about 5 days now… I can copy tutorials letter for letter although for some reason I get an error every time no matter who I copy. It relates to Variables being undefined although they are clearly defined in my code below.
Any help would be greatly appreciated.
Current Connection code;
[i][b]<?php
$hostname = "localhost";
$username = "root";
$password = "";
$databasename = "registration";
$conn = mysqli_connect ($hostname, $username, $password, $databasename);[/b][/i]
Current page code;
[b][i]
<?php include("includes/dbh.inc.php"); //variables $firstname = $_POST['Fname']; $lastname = $_POST['Lname']; //Input fields to database $sql = "INSERT INTO `userss`(`Fname`, `Lname`) VALUES ('$firstname','$lastname')"; $result = mysqli_query($conn, $sql); ?> Register<form action="" method="POST" >
<input type="text" name="Fname" placeholder="First Name">
<input type="text" name="Lname" placeholder="Last Name">
<input type="submit" name="submit" value="Submit New User">
</form>
<div class="footer">
</div>
</div>
[/i][/b]
Even though I receive this error message & < Undefined index: Lname> I am still able to input information to the data base. Although while the variables are empty this error is displayed. Is there a way around this?
Thank you
Jamie