Permission denied for PHP application with xampp - php

I am trying to make my first php based website and have ran into a problem. The website is very basic and is intended to allow users to enter student information into a database. I built this website following a tutorial by Derek Banas which can be found here:
https://www.youtube.com/watch?v=mpQts3ezPVg&t=25s.
Whenever I try to open my getStudentInfo.php file in my browser, I receive the following error:
Warning: require_once(C:\xampp\htdocs\practiceWebDev): failed to open stream: Permission denied in C:\xampp\htdocs\practiceWebDev\practicePHPmySQL\getStudentInfo.php on line 3
Fatal error: require_once(): Failed opening required '../../practiceWebDev' (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\practiceWebDev\practicePHPmySQL\getStudentInfo.php on line 3
Does this error mean I have something wrong with my code? Or do I need to change the php.ini or httpd.conf files associated with XAMPP? Below are the files I have dealing with connections if they are of any use. Thank you very much for any feedback you all can give. Also, I make use of mysql for my database.
mysqli_connect.php:
<?php
//IMPORTANT! This file must be saved outside of where the rest of my files related to our website are saved so that no one may access them.
DEFINE ('DB_USER' 'studentweb');
DEFINE ('DB_PASSWORD' 'turtledove');
DEFINE ('DB_HOST' 'localhost');
DEFINE ('DB_NAME' 'studentdatabase');
$databaseConnection = #mysqli_connect(DB_USER, DB_PASSWORD, DB_HOST, DB_NAME)
//using the above # symbol before mysqli_connect makes it so errors will not appear in the browser.
//# is known as the 'error control operator', and makes PHP suppress error messages associated with the expression.
OR die('Could not connect to MySql lol' . mysqli_connect_error());
//mysqli_connect_error() is a function defined in the php synthax.
?>
getStudentInfo.php:
<?php
//now we require the file outside of the current directory called mysqli_connect.php
require_once('../../practiceWebDev');
//the query below will display the information from each student in the form of a table.
$query = "SELECT first_name, last_name, email, street, province,
postal_code, phone_num, birth_date, sex, date_entered,
lunch_cost, student_id, FROM students";
//the response below is all the info that we've gotten that we want to show in our table.
$response = #mysqli_query($databseConnection, $query);
//below we will see if the query executed properly.
if($response)
{
echo '<table align="left" cellspacing="5" cellpadding="8">
<tr><td align="left"><b>First Name</b></td>
<td align="left"><b>Last Name</b></td>
<td align="left"><b>Email</b></td>
<td align="left"><b>Street</b></td>
<td align="left"><b>City</b></td>
<td align="left"><b>State</b></td>
<td align="left"><b>Zip</b></td>
<td align="left"><b>Phone</b></td>
<td align="left"><b>Birth Day</b></td></tr>';
while($row = mysqli_fetch_array($response)){
echo '<tr>';
echo '<td align=left">'.$row['first_name'].'</td><td align="left">'.$row['last_name'].'</td><td align="left">'.$row['email'].'</td>';
echo '<td align="left">'.$row['street'].'</td><td align="left">'.$row['city'].'</td><td align="left">'.$row['state'].'</td>';
echo '<td align="left">'.$row['zip'].'</td><td align="left">'.$row['phone'].'</td><td align="left">'.$row['birth_date'].'</td>';
echo '</tr>';
}
echo '</table>';
}
else
{
echo "Couldn't issue database query";
echo mysqli_error($databseConnection);
}
mysqli_close($databseConnection);
?>
studentadded.php
<html>
<head>
<title>Add Student</title>
</head>
<body>
<!--First, we need to check if this page was actually reached when the form was submitted--->
<?php
//Below we check that a POST operation was completed by the button I have named "submitButton"
if(isset($_POST['submitButton']))
{
$data_missing = array();
/*If there is an empty field when a POST operation is completed, that field's name will be
added to the data_missing array so that we may visually see which fields are not being sent*/
if(empty($_POST['first_name']))
{
$data_missing[] = 'First Name';
}
else
{
$f_name = trim($POST['first_name']);
}
if(empty($_POST['lastName']))
{
$data_missing[] = 'Last Name';
}
else
{
$l_name = trim($POST['lastName']);
}
if(empty($_POST['email']))
{
$data_missing[] = 'email';
}
else
{
$email = trim($POST['email']);
}
if(empty($_POST['street']))
{
$data_missing[] = 'street';
}
else
{
$street = trim($POST['street']);
}
if(empty($_POST['province']))
{
$data_missing[] = 'province';
}
else
{
$province = trim($POST['province']);
}
if(empty($_POST['postal_code']))
{
$data_missing[] = 'postal_code';
}
else
{
$postal_code = trim($POST['postal_code']);
}
if(empty($_POST['phone_num']))
{
$data_missing[] = 'phone_num';
}
else
{
$phone_num = trim($POST['phone_num']);
}
if(empty($_POST['birth_date']))
{
$data_missing[] = 'birth_date';
}
else
{
$birth_date = trim($POST['birth_date']);
}
if(empty($_POST['sex']))
{
$sex[] = 'sex';
}
else
{
$sex = trim($POST['sex']);
}
if(empty($_POST['lunch_cost']))
{
$data_missing[] = 'lunch_cost';
}
else
{
$lunch_cost = trim($POST['lunch_cost']);
}
if(empty($_POST['student_id']))
{
$data_missing[] = 'student_id';
}
else
{
$student_id = trim($POST['student_id']);
}
//Now lets check
if(empty($data_missing))
{
require_once('../mysqli_connect.php');
$myQuery = "INSERT INTO students (first_name, last_name, email, street, province,
postal_code, phone_num, birth_date, sex, date_entered, lunch_cost,
student_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?, NULL)";
$statement = mysqli_prepare($databaseConnection, $myQuery);
//We have to represent the data type for each of the value that will be passed into our database.
/*i Integers
d Doubles
b Blobs
s Everything Else*/
//Now lets bind variables to the '?'s passed in with the myQuery query.
mysqli_stmt_bind_param($statement, "sssssssisssd", $f_name, $l_name, $email, $street, $province,
$postal_code, $phone_num, $birth_date, $sex, $lunch_cost, $student_id);
mysqli_statement_execute($statement);
$affected_rows = mysqli_stmt_addected_rows($statement);
if($affected_rows == 1)
{
echo 'Went through properly! Student entered correctly!';
mysqli_stmt_close($statement);
mysqli_close($databaseConnection);
}
else
{
echo 'Error occurred :(';
echo '<br />';
echo mysqli_error();
mysqli_stmt_close($statement);
mysqli_close($databaseConnection);
}
}
else
{
echo 'You need to enter the following data my dude: <br />';
foreach($data_missing as $missingData)
{
echo "$missingData<br />";
}
}
}
?>
<form action="http://localhost/studentadded.php" method="post">
<b>Add a New Student</b>
<p>First Name: <input type="text" name="first_name" size="30" value="" /></p>
<p>Last Name: <input type="text" name="lastName" size="30" value="" /></p>
<p>Email: <input type="text" name="email" size="60" value="" /></p>
<p>Street: <input type="text" name="street" size="50" value="" /></p>
<p>Province: <input type="text" name="province" size="3" value="" /></p>
<p>Postal Code: <input type="text" name="postal_code" size="6" value="" /></p>
<p>Phone Number: <input type="text" name="phone_num" size="20" value="" /></p>
<p>Birth Date (YYYY-MM-DD): <input type="text" name="birth_date" size="20" value="" /></p>
<p>Sex: <input type="text" name="sexField1" size="5" maxlength="1" value="" />
<!---<p>Sex: <input type="radio" name="sexField" value="M" />
<br>
<input type="radio" name="sexField" value="F" checked /></p>--->
<!--<p>Date Entered: <input type="" name="" size="" value="" /></p>--->
<p>Lunch Cost: <input type="text" name="lunch_cost" size="5" value="" /></p>
<p>Student ID: <input type="text" name="student_id" size="10" value="" /></p>
<input type="submit" name="submitButton" value="submitValue">
<!-- type="submit" is a predefined term in html--->
</form>
</body>
</html>
addStudent.php
<html>
<head>
<title>Add Student</title>
</head>
<body>
<form action="http://localhost/studentadded.php" method="post">
<b>Add a New Student</b>
<p>First Name: <input type="text" name="first_name" size="30" value="" /></p>
<p>Last Name: <input type="text" name="lastName" size="30" value="" /></p>
<p>Email: <input type="text" name="email" size="60" value="" /></p>
<p>Street: <input type="text" name="street" size="50" value="" /></p>
<p>Province: <input type="text" name="province" size="3" value="" /></p>
<p>Postal Code: <input type="text" name="postal_code" size="6" value="" /></p>
<p>Phone Number: <input type="text" name="phone_num" size="20" value="" /></p>
<p>Birth Date (YYYY-MM-DD): <input type="text" name="birth_date" size="20" value="" /></p>
<p>Sex: <input type="text" name="sexField1" size="5" maxlength="1" value="" />
<!---<p>Sex: <input type="radio" name="sexField" value="M" />
<br>
<input type="radio" name="sexField" value="F" checked /></p>--->
<!--<p>Date Entered: <input type="" name="" size="" value="" /></p>--->
<p>Lunch Cost: <input type="text" name="lunch_cost" size="5" value="" /></p>
<p>Student ID: <input type="text" name="student_id" size="10" value="" /></p>
<input type="submit" name="submitButton" value="submitValue">
<!-- type="submit" is a predefined term in html--->
</form>
</body>
</html>

From what I can see in the tutorial files at this address:
http://www.newthinktank.com/2014/09/php-mysql-tutorial/
In the file getstudentinfo.php at the beginning of the file
You should have require_once('../mysqli_connect.php');
But you have require_once('../../practiceWebDev');
(there is no filename in this line of your code!)
So I think just changing this line of code and using correct path + the filename should solve your error
Update:
Again from what I can see in your code, in studentadded.php file you have this line of code:
require_once('../mysqli_connect.php');
So if your studentadded.php file is working without errors, then just change the line which is generating the error in getstudentinfo.php file with this line.

Related

PostgreSQL Data Table will not update from PHP code

I am using postgreSQL, PHP, and an HTML form. The form is a simple scholarship application. My connection script seems to work fine because when I click submit on the HTML form it echos "connected" and doesn't die, however no data from the form is transferred to my table. Please any guidance.
My PHP connection script: connect.php
try {
$dbConn = new PDO('pgsql:host=' . DB_HOST . ';'
. 'port=' . DB_PORT . ';'
. 'dbname=' . DB_NAME . ';'
. 'user=' . DB_USER . ';'
. 'password=' . DB_PASS);
$dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // Set error mode to exception
echo “Connected”;
} catch (PDOException $e) {
$fileName = basename($e->getFile(), ".php"); // File that triggers the exception
$lineNumber = $e->getLine(); // Line number that triggers the exception
die("[$fileName][$lineNumber] Database connect failed: " . $e->getMessage() . '<br/>');
}
?>
My PHP submission script: form.php
<?php
require 'connect.php';
$sid = $_POST['sid'];
$firstName = $_POST['fname'];
$preferredName = $_POST['pname'];
$lastName = $_POST['lname'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$inSchool = $_POST['inSchool'];
$gDate = $_POST['gDate'];
$gpa = $_POST['gpa'];
$essay = $_POST['essay'];
$submit = $_POST['submit'];
if ($sid = ''){
$query = 'insert into student(firstname,lastname,prefname,address,city,state,zip,phone,email) values (?,?,?,?,?,?,?,?,?)';
$statement = $dbConn->prepare($query);
$statement->execute([$firstname, $lastname,$preferredname,$address,$city,$state,$zip,$phone,$email]);
}
else{
$query = 'insert into student(firstname,lastname,prefname,address,city,state,zip,phone,email) values (?,?,?,?,?,?,?,?,?)';
$statement = $dbConn->prepare($query);
$statement->execute([$firstname, $lastname,$preferredname,$address,$city,$state,$zip,$phone,$email]);
}
$query = 'select sid from student where firstname = ? and lastname = ? limit 1';
$statement = $dbConn->prepare($query);
$statement->execute([$firstname, $lastname,$preferredname,$address,$city,$state,$zip,$phone,$email]);
$results = $statement->fetch();
echo $results[0];
?>
My HTML Form: Application.html
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="Style.css">
<title>Application</title>
</head>
<body>
<form action="form.php" method="post">
<header>
<img class="logo" src="" alt="logo">
<div>Asterisks Corporation Scholarship Application</div>
</header>
<p class="general">Please fill in all information to apply for the Asterisk's Scholarship.<p>
First Name:
<input type="text" size="15" name="fname" required />
Preferred Name:
<input type="text" size="15" name="pname" >
Last Name:
<input type="text" size="15" name="lname" required />
<p class="newSection">Contact Information</p>
Address:
<input type="text" size="50" name="address" required />
City:
<input type="text" size="15" name="city" required />
State:
<input type="text" size="15" name="state" required />
Zip Code:
<input type="text" size="1" name="zip" placeholder="####" required /><br><br>
Phone Number:
<input type="text" size="10" name="phone" placeholder="(###)-###-###">
Email Address:
<input type="text" size="50" name="email" required />
<p class="newSection">Academic Information</p>
Are you currently enrolled in school?
<input type="checkbox" id="Yes" name="yesBox">
<label for="Yes">Yes</label>
<input type="checkbox" id="No" name="noBox">
<label for="No">No</label><br><br>
What school are you enrolled?
<input type="text" size="50" name="schoolsEnrolled"><br><br>
What is/was your date of Graduation?
<input type="date" name="graduationDate"><br><br>
GPA
<input type="text" size="1" name="gpa">
<p class="newSection">What institutions have you applied?</p>
<input type="text" name="" value="" id="school" name="schoolsApplied">
<button onclick="addToList()" type="button" name="button" id="addButton">Add School</button><br>
<ul id="schoolList"></ul>
<p class="newSection">Please write a small essay as to why you should receive this scholarship and what your plans are after graduation.</p>
<textarea id="essay" style="width: 500px; height: 200px;" alignment="left" onkeyup="wordCounter(),wordsRemaining()" name="essay"></textarea>
<div>
300 Words Minimum & 500 Words Maximum
<div> Word Count: <span id="wordCount">0</span></div>
<div> Words Remaining: <span id="wordsRemaining">0</span></div>
</div>
<p class="newSection">Please confirm each of the following:</p>
<input type="checkbox" id="Transcript" name="transcriptConfirm" required />
<label for="Transcript">I have sent in all of my transcripts</label><br>
<input type="checkbox" id="Schools" name="schoolConfirm" required />
<label for="Schools">All schools that I am considering are in the US</label><br>
<input type="checkbox" id="Awards" name="awardConfirm" required />
<label for="Awards">I understand that the award is $5,000 per year for four years</label><br>
<input type="checkbox" id="Confirm" name="amountConfirm" required />
<label for="Confirm">I have received confirmation that my recommenders have emailed their letters to the Scholarship's Coordinator</label><br><br>
Please type your signature in the text box below: <br><br>
<input type="text" size="20" name="signature" required />
<div><br>
<input type="submit" value ="Submit" name="submit">
<input type="reset" value="Start Over" onclick="MinMax()">
</div>
<script>
function addToList(){
let school= document.getElementById("school").value;
document.getElementById("schoolList").innerHTML += ('<li>'+ school+'</li>');
};
function wordCounter(text){
var count= document.getElementById("wordCount");
var input= document.getElementById("essay");
var text=essay.value.split(' ');
var wordCount = text.length;
count.innerText=wordCount
}
function wordsRemaining(text){
var count= document.getElementById("wordCount");
var input= document.getElementById("essay");
var remaining = document.getElementById("wordsRemaining");
var text=essay.value.split(' ');
var wordCount = text.length;
remaining.innerText=300-wordCount
}
</script>
</form>
</body>
</html>

PHP form not submitting to the next page

The landing page has form but it is not submitting and not redirecting to the next page.After submitting the form, it stays on the same page.
It was alright and was working before but I cant figure out where is the problem.
Code in formPage.php is below:
<form action="insert.php" enctype="multipart/form-data" class="contact_form" method="post" name="htmlform" >
<input class="frm-input" name="name" type="text" size="30" maxlength="50" placeholder="Enter Name" required="required" />
<input class="frm-input" name="email" type="text" size="30" maxlength="80" placeholder="Enter Email" required="required"/>
<input class="frm-input" name="jobtype" type="text" size="30" maxlength="30" placeholder="Job Type" required="required"/>
<input class="frm-input" name="ent_type" type="text" size="30" maxlength="80" placeholder="Entity Type" required="required"/>
<input class="frm-input" name="tas_out" type="text" size="30" maxlength="80" placeholder="Task Outline" required="required"/>
<input class="frm-input" name="l_st" type="text" size="30" maxlength="80" placeholder="Logo style of interest (optional)" />
<textarea required="required" class="frm-input frm-txtarea" name="message" placeholder="Task Description!!" maxlength="1000" cols="25" rows="6" ></textarea>
<input style="float: left;" type="file" name="image" size="66"/>
<input type="submit" class="btn btn-success btn-lg" name="submitt" value="submit" style="float: right" />
</form>
In this file I am trying to get the form information and storing them in database.But this page is not loading after the form submission.
Code in insert.php is below:
<?php
/*
$name = "";
$text = "";
$post = "";
*/
//echo $name;
if (isset($_POST['submitt']))
{
$name = $_POST["name"];
$mail = $_POST["email"];
$j_type = $_POST["jobtype"];
$e_type = $_POST["ent_type"];
$task = $_POST["tas_out"];
$l_st = $_POST["l_st"];
$task_des = $_POST["message"];
$image_name=$_FILES['image']['name'];
$image_type=$_FILES['image']['type'];
$image_size=$_FILES['image']['size'];
$image_temp=$_FILES['image']['tmp_name'];
//$date = date(m-d-y);
echo $name;
echo $mail;
echo $j_type;
echo $e_type;
echo $task;
echo $l_st;
echo $task_des;
if ($image_type=='image/jpeg' || $image_type=='image/png' || $image_type=='image/gif') {
move_uploaded_file($image_temp, "img/$image_name");
}
$connection=mysqli_connect("localhost", "root", "","com");
$query="insert into details (name, mail, j_type, e_type, task_outline, l_style, task_desc, image) values('".$name."','".$mail."','".$j_type."','".$e_type."','".$task."','".$l_st."','".$task_des."','".$image_name."')";
if(mysqli_query($connection,$query)){
//include('test.php');
echo '<h2>Data submitted successfully!!</h2>';
header("refresh:1; url=login.php");
//echo 'Back';
}else{
echo "Data not Submitted!";
# code...
}
}
echo "Data not Submitted!";
?>
echo "Data not Submitted!"; // put this line inside the last bracket
Sorry it was my fault,there was a typo mistake in the form action.Everything else is fine.

Can't write data to database

I am trying to write a simple application with PHP to write and receive data from a database. I am able to retrieve data already in the database through my PHP script, but I can not write anything to it. When I try, I do not get any errors - just the title of my script and a blank screen.
My code is as follows:
My HTML
<form action="insert_book.php" method="post">
<fieldset>
<p><label for="ISBN">ISBN</label>
<input type="text" id="ISBN" name="ISBN" maxlength="13" size="13" /></p>
<p><label for="Author">Author</label>
<input type="text" id="Author" name="Author" maxlength="30" size="30" /></p>
<p><label for="Title">Title</label>
<input type="text" id="Title" name="Title" maxlength="60" size="30" /></p>
<p><label for="Price">Price</label>
$ <input type="text" id="Price" name="Price" maxlength="7" size="7" /></p>
</fieldset>
<p><input type="submit" value="Add New Book" /></p>
</form>
PHP
<?php
if(!isset($_POST['ISBN']) || !isset($_POST['Author'])
|| !isset($_POST['Title']) || !isset($_POST['Price'])) {
echo "<p>You have not entered all the details.<br/>
Go back and try again.</p>";
exit;
}
// create short variable names
$isbn=$_POST['ISBN'];
$author=$_POST['Author'];
$title=$_POST['Title'];
$price=$_POST['Price'];
$price = doubleval($price);
#$db = new mysqli('localhost', 'jay', '******', 'Books');
if (msqli_connect_errno()) {
echo '<p>Error: Could not connect to database.<br/>
Please try again.</p>';
exit;
}
$query = "INSERT INTO Books VALUES (?, ?, ?, ?)";
$stmt = $db->prepare($query);
$stmt->bind_param('sssd', $isbn, $author, $title, $price);
$stmt->execute();
if ($stmt->affected_rows > 0) {
echo '<p>Submission successful.</p>';
} else {
echo '<p>An Aweful error occured.<br/>
Nothing was added.</p>';
}
$db->close();
?>
Please let me know if you can see any issues.
Thanks!
You have an error in this line:
if (msqli_connect_errno()) {
It should be
if (mysqli_connect_errno()) {
You missed a y.

How do I post information from a <form> and get information into the form from that also needs to be posted into the same database?

I'm making a form that puts student information into a student table. Part of this information requires the foreign key as the parent_guardian_id from the parents table . I'd like to offer the parents' names as a choice from a select or dropdown to input the foreign key. It seems like I need to GET and POST at the same time? I would need to do this with at least 2 other pages. Thanks for any insight.
//Check for student first name:
if (empty($_POST['student_first_name'])) {
$errors[] = "Please enter the student\'s first name.";
} else {
$student_first_name = mysqli_real_escape_string($dbc,($_POST['student_first_name']));
}
if (empty($errors)){//If requirements met:
$query="INSERT INTO student (student_first_name, student_last_name,
student_street, student_city, student_zip, student_phone,
student_email, parent_guardian_id)
Values ('$student_first_name', '$student_last_name',
'$student_street', '$student_city', '$student_zip', '$student_phone',
'$student_email', '$parent_guardian_id')";
$result=mysqli_query($dbc,$query);
if ($result){
echo "<center><p><b>A new STUDENT has been added.</b></p><br/>";
echo "<center><a href=studentadd.php>Show All STUDENTS</a> </center>";
exit();
} else {
$errors[] = "<p>The record could not be added due to a system error. </p>";
$errors[] = mysqli_error($dbc) . "</p>";
}
}
}
mysqli_close($dbc);}
?>
<form action="studentadd.php" method="post">
<p>First Name: <input type="text" name="student_first_name" size="50" value=
"<?php echo $_POST['student_first_name']; ?>"/><p><br />
<p>Last Name: <input type="text" name="student_last_name" size="50" value=
"<?php echo $_POST['student_last_name']; ?>" /><p><br />
<p>Street Address: <input type="text" name="student_street" size="50" value=
"<?php echo $_POST['student_street']; ?>" /><p><br />
<p>City: <input type="text" name="student_city" size="50" value=
"<?php echo $_POST['student_city']; ?>"/><p><br />
<p>State: <input type="text" name="student_state" size="50" value=
"<?php echo $_POST['student_state']; ?>"/><p><br />
<p>Zip: <input type="text" name="student_zip" size="50" value=
"<?php echo $_POST['student_zip']; ?>"/><p><br />
<p>Phone: <input type="text" name="student_phone" size="50" value=
"<?php echo $_POST['student_phone']; ?>"/><p><br />
<p>Email Address: <input type="text" name="student_email" size="50" value=
"<?php echo $_POST['student_email']; ?>"/><p><br /></form>
<p>Parent/Guardian: <select name="parent_guardian"
id="parent_guardian" size="20"
value="<?php echo $row['mother_guardian_first_name'] . "
, " . $row['mother_guardian_last_name'] . "
, " . $row['father_guardinan_first_name'] . "
, " . $row['father_guardian_last_name'];
$_POST['parent_guardian_id']; ?>"/>Name Goes Here</select><p><br />
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" value="Reset" />
<input type="hidden" name="submitted" value="true" /></p>
</form>
<?php
//include the footer
include ("footer.php");
?>

Error in modifying mysql database using netbeans

I'm working on a php code that connects to mysql database using beans.
I have written this code for inserting record into the database using a form.
However, the recode cannot be added to the database, and I dont know why.
the same problem happens with the update..
Please anybody can check the code and tell me where is the problem.
<?php
if(isset($_POST['submitted'])) {
$dbhost='localhost:8888';
$dbuser='root';
$dbpass='root';
$dbname='clients';
$conn=mysql_connect($dbhost,$dbuser,$dbpass,$dbname);
$cardnum = $_POST['cardnum'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$idnum = $_POST['idnum'];
$mobnum = $_POST['mobnum'];
$visit = $_POST['visit'];
$sqlinsert = "INSERT INTO clients (cardnum, fname, lname, idnum, mobnum, visit)
VALUES ('$cardnum', '$fname', '$lname', '$idnum', '$mobnum', '$visit')";
if(!mysqli_query($conn, $sqlinsert)) {
die("Error inserting new record");
}
$newrecord = "One record added successfuly";
}
?>
<html>
<head>
<title>
<b>Add New Client</b>
</title>
</head>
<body bgcolor="#F0FFFF">
<br/> <br/> <br/>
<font size="4" face="WildWest" color="#4EE2EC"><b>Insert Data for the Client</b></font>
<br/>
<form method="post" action="Add.php">
<input type="hidden" name="submitted" value="true"/>
<fieldset>
<lable><font color="#48CCCD"> Card Number: </font><input type="text" name="cardnum" size="30"/> </lable><br/>
<lable><font color="#48CCCD"> First Name: </font><input type="text" name="fname" size="30"/> </lable><br/>
<lable><font color="#48CCCD"> Last Name: </font><input type="text" name="lname" size="30"/> </lable><br/>
<lable><font color="#48CCCD">ID Number: </font><input type="text" name="idnum" size="30"/> </lable><br/>
<lable><font color="#48CCCD"> Mobile Number: </font><input type="text" name="mobnum" size="30"/> </lable><br/>
<lable><font color="#48CCCD"> Visits:</font><input type="text" name="visit" size="30"/> </lable><br/>
</fieldset>
<br/>
<input type="submit" value="Add" aligh="right"/>
<?php
echo $newrecord
?>
</form>
</body>
</html>

Categories