This question already has an answer here:
I have no idea what I'm doing wrong, keeps on saying HTTP 500 error. I am trying to make a registration form for businesses. have to add: referral, business name, industry, street Address 1, street Address 2, city, code, Compay registration number, vat number, email and phone. I have coded the html registration form as well as the php file to connect to the database, but nothing is working. Really need advice on how to fix this.
my html form code:
<!DOCTYPE HTML>
<html>
<head>
<title>Register Form</title>
</head>
<body>
<form action="insert1.php" method="POST">
<table>
<tr>
<td>Referral :</td>
<td><input type="text" name="referral" required></td>
</tr>
<tr>
<td>Business Name :</td>
<td><input type="text" name="busname" required></td>
</tr>
<tr>
<td>Industry :</td>
<td><input type="text" name="industry" required></td>
</tr>
<tr>
<td>Street Address :</td>
<td><input type="text" name="streetAddress1" required></td>
</tr>
<tr>
<td>Street Address 2 :</td>
<td><input type="text" name="streetAddress2"></td>
</tr>
<tr>
<td>City: </td>
<td><input type="text" name="city" required/></td>
</tr>
<tr>
<td>Code :</td>
<td>
<input type="text" name="code" required>
</td>
</tr>
<tr>
<td>Company registration No :</td>
<td><input type="text" name="regNo" required></td>
</tr>
<tr>
<td>VAT no :</td>
<td><input type="text" name="vat" required></td>
</tr>
<tr>
<td>Email :</td>
<td><input type="email" name="email" required></td>
</tr>
<tr>
<td>Phone no :</td>
<td>
<input type="phone" name="phone" required>
</td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>
php file:
<?php
$referral = filter_input(INPUT_POST,'referral');
$busName = filter_input(INPUT_POST,'busname');
$industry = filter_input(INPUT_POST,'industry');
$streetAddress1 = filter_input(INPUT_POST,'streetAddress1');
$streetAddress2 = filter_input(INPUT_POST,'streetAddress2');
$city = filter_input(INPUT_POST,'city');
$code = filter_input(INPUT_POST,'code');
$regNo = filter_input(INPUT_POST,'regNo');
$vat = filter_input(INPUT_POST,'vat');
$email = filter_input(INPUT_POST,'email');
$phone = filter_input(INPUT_POST,'phone'];
if (!empty($referral) || !empty($busName) || !empty($industry) || !empty($streetAddress1) ||
!empty($city) || !empty($code) || !empty($regNo) || !empty($vat) || !empty($email) !empty($phone)) {
$host = "localhost";
$dbUsername = "sdlmembe_4fin";
$dbPassword = "@2b4Stef1";
$dbname = "sdlmembe_4fin";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT email From 4finmembers Where email = ? Limit 1";
$INSERT = "INSERT Into 4finmembers (referral, busname, industry, streetAddress1, streetAddress2, city, code, regNo, vat, email, phone) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
//Prepare statement
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("ssssssssssi", $referral, $busName, $industry, $streetAddress1, $streetAddress2, $city, $code, $regNo, $vat, $email, $phone);
$stmt->execute();
echo "New record inserted sucessfully";
} else {
echo "Someone already register using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>
When adding it to the SQL database, must the Name field in the database be spelled exactly the same as the name= "email". Or can I change it in the database to "Email Address".
</div>