SBste01
Member
- Dec 16, 2013
- 44
- 3
Hey,
I've seen on a lot of hotels staff applications build into the CMS but cannot find releases anywhere. Therefore, I've attempted to code it myself by looking online and have a SQL syntax error. I'll include all three files below, a screengrab of the error and a screengrab of the table in the database.
connection.php
thankyou.php
form.php
Table design for staffapps (photo)
Form (photo):
Error (photo):
If you're able to help, please comment below.
Thanks
I've seen on a lot of hotels staff applications build into the CMS but cannot find releases anywhere. Therefore, I've attempted to code it myself by looking online and have a SQL syntax error. I'll include all three files below, a screengrab of the error and a screengrab of the table in the database.
connection.php
<?php
function Connect()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = ""; (has been filled in)
$dbname = ""; (has been filled in)
// Create connection
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname) or die($conn->connect_error);
return $conn;
}
?>
function Connect()
{
$dbhost = "localhost";
$dbuser = "root";
$dbpass = ""; (has been filled in)
$dbname = ""; (has been filled in)
// Create connection
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbname) or die($conn->connect_error);
return $conn;
}
?>
thankyou.php
require 'connection.php';
$conn = Connect();
$ip = $conn->real_escape_string($_POST['ip']);
$username = $conn->real_escape_string($_POST['username']);
$why = $conn->real_escape_string($_POST['why']);
$real = $conn->real_escape_string($_POST['real']);
$location = $conn->real_escape_string($_POST['location']);
$age = $conn->real_escape_string($_POST['age']);
$dif = $conn->real_escape_string($_POST['dif']);
$additional = $conn->real_escape_string($_POST['additional']);
$query = "INSERT into staffapps (ip,username,why,real,location,age,dif,additional) VALUES('" . $ip . "','" . $username . "','" . $why . "','" . $real . "','" . $location . "','" . $age . "','" . $dif . "','" . $additional . "')";
$success = $conn->query($query);
if (!$success) {
die("Couldn't enter data: ".$conn->error);
}
echo "Thank you for contacting us. Your application will be read within 24-48 hours. You'll be contacted directly. <br>";
$conn->close();
$conn = Connect();
$ip = $conn->real_escape_string($_POST['ip']);
$username = $conn->real_escape_string($_POST['username']);
$why = $conn->real_escape_string($_POST['why']);
$real = $conn->real_escape_string($_POST['real']);
$location = $conn->real_escape_string($_POST['location']);
$age = $conn->real_escape_string($_POST['age']);
$dif = $conn->real_escape_string($_POST['dif']);
$additional = $conn->real_escape_string($_POST['additional']);
$query = "INSERT into staffapps (ip,username,why,real,location,age,dif,additional) VALUES('" . $ip . "','" . $username . "','" . $why . "','" . $real . "','" . $location . "','" . $age . "','" . $dif . "','" . $additional . "')";
$success = $conn->query($query);
if (!$success) {
die("Couldn't enter data: ".$conn->error);
}
echo "Thank you for contacting us. Your application will be read within 24-48 hours. You'll be contacted directly. <br>";
$conn->close();
form.php
<form action="thankyou" method="post">
<input type="hidden" name="ip" value="{ip_last}" required>
<input type="hidden" name="username" value="{username}" required>
What is your real name?:<br>
<input type="text" name="real" required><br><br>
Where are you from?:<br>
<input type="text" name="location" required><br><br>
How old are you?:<br>
<input type="text" name="age" required><br><br>
Why do you want to be a staff member?:<br>
<textarea rows="5" cols="50" name="why" required></textarea><br><br>
What makes you different from other candidates applying?:<br>
<textarea rows="5" cols="50" name="dif" required></textarea><br><br>
Do you have any additional information or questions to ask?:<br>
<textarea rows="3" cols="50" name="additional"></textarea><br><br>
<input type="submit" value="Submit"><br>
</form>
<input type="hidden" name="ip" value="{ip_last}" required>
<input type="hidden" name="username" value="{username}" required>
What is your real name?:<br>
<input type="text" name="real" required><br><br>
Where are you from?:<br>
<input type="text" name="location" required><br><br>
How old are you?:<br>
<input type="text" name="age" required><br><br>
Why do you want to be a staff member?:<br>
<textarea rows="5" cols="50" name="why" required></textarea><br><br>
What makes you different from other candidates applying?:<br>
<textarea rows="5" cols="50" name="dif" required></textarea><br><br>
Do you have any additional information or questions to ask?:<br>
<textarea rows="3" cols="50" name="additional"></textarea><br><br>
<input type="submit" value="Submit"><br>
</form>
Table design for staffapps (photo)
You must be registered for see images attach
Form (photo):
You must be registered for see images attach
Error (photo):
You must be registered for see images attach
If you're able to help, please comment below.
Thanks