The following code is to import a csv file into database.
<?php
include("includes/config.php");
if ($_POST['frmSubmit']) {
$file = $_FILES['frmUpload']['tmp_name']; // Get Temporary filename
if ($file) {
$handle = fopen($file,"r"); // Open the file and read
while ($strBookData = fgetcsv($handle, 10000, ",")) { // To get Array from CSV
$strDatas[] = $strBookData;
$strTableColumn = count($strBookData); // To Get Column count
}
if ($strDatas) {
$strInsertRecords = 0;
$strDuplicationRecords = 0;
$duplicateEmails = array();
$strDup = "";
if ($strTableColumn == 5) {
for($k=1; $k<count($strDatas); $k++) {
$strStatus = doCheckDuplication($strDatas[$k]['2']);
if ($strStatus==0) {
// Insert Code
doInsertEmployeeDetails($strDatas[$k]['0'], $strDatas[$k]['1'], $strDatas[$k]['2'], $strDatas[$k]['3'], $strDatas[$k]['4']);
$strInsertRecords++; // To Get Inserted Records Count.
} else {
$strDuplicationRecords++; // To Get Duplication Records Count.
$duplicateEmails[$strDuplicationRecords] = $strDatas[$k]['2'];
$strDup.= $duplicateEmails[$strDuplicationRecords]. "\n";
}
}
//printArray($duplicateEmails);
if (count($strDatas)-1 == $strInsertRecords) {
$strMsg = 'Employee details inserted successfully';
$strClass = 'Succes';
}
if (count($strDatas)-1 != $strInsertRecords) {
$strMsg = 'Employee details inserted successfully, some of names already exists';
$strClass = 'Error';
}
if (count($strDatas)-1 == $strDuplicationRecords) {
$strMsg = 'Employee details are already exists';
$strClass = 'Error';
}
} else {
$strMsg = 'Column mis-match, Please verify the file.';
$strClass = 'Error';
}
}
} else {
$strMsg = 'Please upload the valid file.';
$strClass = 'Error';
}
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Employee Details</title>
<link href="css/employee.css" rel="stylesheet" type="text/css"/>
<script src="js/employee.js" type="text/javascript"></script>
</head>
<body>
<form id="frmEmployee" name="frmEmployee" enctype="multipart/form-data" method="post" action="" onsubmit="return validation();">
<div class="all">
<div class="alls">
<div class="main">
<div class="inner">
<div class="top">
<p> </p>
<div class="text" align="center">
<p class="det">EMPLOYEE DETAILS</p>
</div>
<p> </p>
</div>
<p> </p>
<div align="center"><p class="<?php echo $strClass; ?>"><?php echo $strMsg; ?></p></div>
<p> </p>
<div class="ntop">
<div class="nnn">
<div class="name">CSV Upload:</div>
<div class="field">
<label>
<input type="file" name="frmUpload" id="frmUpload" onblur="checkEmpty('frmUpload', 'error_file', 'Please upload your file');"/>
</label>
</div>
<p> </p>
</div>
<div class="span">
<div class="span2"><span id="error_file" class="spans"></span></div>
<p> </p>
</div>
</div>
<p> </p>
<p> </p>
<div class="submit">
<div class="sub">
<div class="but">
<label>
<input type="submit" name="frmSubmit" id="frmSubmit" value="Submit" class="subb" />
</label>
</div>
<div class="but">
<label>
<input type="reset" name="frmReset" id="frmReset" value="Reset" class="subb" />
</label>
</div>
</div>
<p> </p>
</div>
</div>
<p> </p>
<?php if ($_POST['frmSubmit']) { ?>
<div class="info" id="one">
<table width="59%" border="1" bordercolor="#DEDEDE" class="tabb">
<tr>
<td width="72%"><p class="rec">Total Records:</p> </td>
<td width="28%"><p class="rec"><?php echo count($strDatas)-1; ?></p></td>
</tr>
<tr>
<td><p class="rec">Inserted Records:</p></td>
<td><p class="rec"><?php echo $strInsertRecords; ?></p></td>
</tr>
<tr>
<td><p class="rec">Duplicate Records:</p></td>
<td><p class="rec"><?php echo $strDuplicationRecords; ?></p></td>
</tr>
</table>
</div>
<div class="dup">
<div class="duplicate">
<div class="hea">
<p class="rec">Duplicate Records</p>
</div>
<p style="height: 10px;"></p>
<div style="padding-left: 10px;"><?php echo $strDup. "<br>"; ?></div>
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</form>
</body>
</html>
Now i want to export it from the database. Please help me.
you can download adminer.php from this "http://www.adminer.org/" and that will do that job for you. It has all the option to download database in different formats like XML, CSV and text.
Related
I am creating a seat reservation system. In my system, the code check number of seats a bus contains then pass it inside a for loop. When a user pick 2 passengers, it means two seats will be booked. How can I validate the checkbox in the for loop depending on the number of passenger(s) selected.
Using the GUI for more explanation.
on the main page, 2 there indicates number of passenger(s) selected.
When you come to the second page where the values are passed to, you can see 2 Adults as the selected number of passengers. When you click on Submit Button it does not validate the checkbox based on the number of passenger(s) selected. And if I should put required in the checkbox it validates the whole checkbox since it is in a loop
$_SESSION['seat_no'] is the number of seat(s) a bus contains. Let assume a user that want to book a seat selected two passengers which means two seats is booked, how can I validate the checkbox based on the number of seat(s) selected?
Here is my code:
<?php
for ($i = 1; $i <= $_SESSION['seat_no']; $i++) {
if(in_array($i,$mseat)){
echo "<div class='checkbox_wrapper_pick'>
<label>".$i."</label>
</div>";
}else{
echo "<div class='checkbox_wrapper'>
<input type='checkbox' value=".$i." name='seat_book[]' />
<label>".$i."</label>
</div>";
}
}
?>
The full source code:
<?php include("header.php"); error_reporting(0); ?>
<?php
if(isset($_POST['submit'])){
$from = $_POST['from'];
$to = $_POST['to'];
$date = $_POST['d_date'];
$nop = $_POST['nop'];
$_SESSION['from'] = $from;
$_SESSION['to'] = $to;
$_SESSION['date'] = $date;
$_SESSION['nop'] = $nop;
$get = mysqli_query($mysqli,"SELECT * FROM routes WHERE present_loc = '$from' and destination = '$to' ");
while($roys = mysqli_fetch_array($get)){
//get bus details
$bno = $roys['bus_no'];
$ploc = $roys['present_loc'];
$des = $roys['destination'];
$time = $roys['dept_time'];
$_SESSION['time'] = $time;
$amt = $roys['amount'];
$_SESSION['amt'] = $amt;
$b = str_replace( ',', '',$_SESSION['amt'] );
if( is_numeric($b) ) {
$a = $b;
}
$bus = mysqli_query($mysqli,"select * from bus where bus_no = '$bno'");
while($bu = mysqli_fetch_array($bus)){
$_SESSION['model'] = $bu['model'];
$_SESSION['seat_no'] = $bu['seat_no'];
$_SESSION['ac'] = $bu['bus_type'];
$_SESSION['excess_luggage'] = $bu['excess_luggage'];
$_SESSION['more_legs'] = $bu['more_legs'];
$_SESSION['id'] = $bu['id'];
}
$coun = mysqli_query($mysqli, "select count(booking_id) as seat, seats from booking where bus_no = '$bno' and seats !='' GROUP by booking_id" );
$mseat = array();
while($e = mysqli_fetch_array($coun)){
$bseat = $e['seat'];
$mseat[] = $e['seats'];
}
//$seatss = array();
$seat_string = implode(",",$mseat);
//get seats
$couns = mysqli_query($mysqli, "select sum(counter) as seat from booking where bus_no = '$bno' and seats !='' GROUP by bus_no" );
$rseats = mysqli_fetch_array($couns);
$lseat = $rseats['seat'];
if($_SESSION['seat_no'] == $lseat){
$tell = " No more seat(s) available.";
}else{
$tell = $_SESSION['seat_no'] - $lseat. " Seat(s) remaining.";
}
}
}
?>
<!--Main layout-->
<main class="mt-5">
<!--Main container-->
<form action="details" method="POST">
<!--Grid row-->
<div class="row">
<div class="col-lg-12 title-header mb-3 mx-auto z-depth-1">
<div class="row">
<div class="col-lg-8">
<?php echo '<h2> '.$_SESSION['from']. ' to '. $_SESSION['to']. '</h2>'; ?><br/>
<b><?php echo $_SESSION['date']; ?> :: <?php if($_SESSION['nop'] < '2') { echo $_SESSION['nop'] . ' Adult'; }
elseif($_SESSION['nop'] > 1) { echo $_SESSION['nop'] . ' Adults'; }
?></b>
</div>
</div>
</div>
<div class="col-lg-12 mbody"> <label style="margin-left: 4%; font-weight:bolder; font-size:20px; color:#000;">Details </label> </div>
<div class="col-lg-12 mbody bg-white ">
<table class="table table_view" style = "width: 100%; margin-left: 4%; margin-right:4%;">
<tbody>
<tr>
<td><b><?php echo $_SESSION['model']; ?></b><br/><?php echo $_SESSION['from']. ' to '. $_SESSION['to']; ?>
<br/><?php if($_SESSION['ac'] == 'AC') { echo '<span class="alert-info ac">'. $_SESSION['ac'] .'</span>'; }
else{ echo '<span class="alert-warning">No AC</pan>'; } ?>
<?php if($_SESSION['more_legs'] == 'Yes') { echo '<span class="alert-info ac">More Leg Room</span>'; }
else{ echo '<span class="alert-warning no">More Leg Not Available</pan>'; } ?>
</td>
<td><b>Departing Time</b><br/><i class="fa fa-clock-o" aria-hidden="true"></i> <?php echo $_SESSION['time']; ?></td>
<td> <img id = "seatimg" src="../images/seatsLayout/av.gif" class="img-responsive"> <?php echo $tell; ?></td>
<td>Adult <b>₦<?php echo $_SESSION['amt']; ?></b></td>
</tr>
</tbody>
</table>
</div>
<div class="col-lg-12">
<div class="col-lg-12 mbody"> <label style="margin-left: 3%; font-weight:bolder; font-size:20px; color:#000;"><img id = "seatimg" src="../images/seatsLayout/av.gif" class="img-responsive"> Select Seat</label> </div>
<div class="row detail">
<!--Grid column-->
<div class="col-lg-7 animation slideUp" >
<div class="well" id="bus_seats_layout" >
<table class="table table-bordered" cellspacing = "1" id="seatstable">
<tr>
<td><img id = "driverimg" src="../images/seatsLayout/steering.png" class="img-responsive" width="25" height="25"></td>
<td colspan="2" rowspan="3">
<?php
for ($i = 1; $i <= $_SESSION['seat_no']; $i++) {
if(in_array($i,$mseat)){
echo "
<div class='checkbox_wrapper_pick'>
<label>".$i."</label>
</div>
";
}else{
echo "
<div class='checkbox_wrapper'>
<input type='checkbox' value=".$i." name='seat_book[]' />
<label>".$i."</label>
</div>
";
}
}
?>
</td>
</tr>
</table>
</div>
</div>
<div class="col-lg-5">
<ul class="bt">
<li><img src="../images/seatsLayout/seat_available.png" class="img-responsive"> Available</li>
<li><img src="../images/seatsLayout/picked.png" class="img-responsive"> Selected</li>
<li><img src="../images/seatsLayout/seat_booked.png" class="img-responsive"> Booked</li>
</ul>
</div>
</div>
<div class="col-lg-12">
<input type="hidden" name="bus_no" value="<?php echo $bno; ?>">
<input type="hidden" name="to" value="<?php echo $to; ?>">
<input type="hidden" name="from" value="<?php echo $from; ?>">
<input type="hidden" name="amt" value="<?php echo $nop*$a; ?>">
<input type="hidden" name="nop" value="<?php echo $nop; ?>">
<div class="form-group">
<div align="right">
<input type="submit" name="submit" class="bme" value="Continue">
</div>
</div>
</div>
</div>
</div>
</form>
</main>
<?php include("footer.php"); ?>
Hello so I have a site setup to where users can submit projects and it adds it to a upload folder and the database for user download anyway I want to have it so once a user submits a new project it creates a URL like “sitename.com/projects.html?projectname” or something like that. My code is below.
P.S Everything on my site works just need to learn how to create the url.
projects.html: Mainly used to display the recent projects.
<?php include("includes/header.php"); ?>
<?php
include_once 'dbconnect.php';
// fetch files
$sql = "select filename, title, description from tbl_files LIMIT 4";
$result = mysqli_query($con, $sql);
?>
<div id="container">
<div class="wrapper">
<div id="content">
<h2>Recent Projects <button style="float: right;">New Project</button></h2>
<p><table class="table table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th>File Name</th>
<th>Description</th>
<th>Download</th>
</tr>
</thead>
<tbody>
<?php
$i = 1;
while($row = mysqli_fetch_array($result)) { ?>
<tr>
<td><?php echo $i++; ?></td>
<td><?php echo $row['title']; ?></td>
<td><?php echo $row['description']; ?></td>
<td><a href="uploads/<?php echo $row['filename']; ?>" download>Download</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</p>
<div id="column">
<div class="holder">
<h2>Welcome!</h2>
<ul id="latestnews">
<li class="last"> <p><?php
session_start();
include_once "vendor/autoload.php";
$page = new membership\Page(1);
if ($page->isValid() == true){
echo "Hello " . $_SESSION["username"] . "!<br /><br />
<a href='logout.html'>Logout</a>\n";
} elseif ($page->isValid() == false) { echo "<center>Please <a href='login.php'>Log in</a> to share projects.<br /> <a href='register.php'>Need A Account?</a></center>";}
?><br />
</p>
<br /></p>
</li>
</ul>
</div>
</div>
<br class="clear" />
</div>
</div>
<?php
error_reporting(E_ALL & ~E_NOTICE);
include('includes/memberlistconfig.php');
// call this file only after database connection
require_once 'functions.php';
?>
<div id="container">
<div class="wrapper">
<div id="content">
<h2>Categories</h2>
<p>
<div class="height20"></div>
<?php echo $emsg; ?>
<article>
Click on one of the categories to see what’s inside.
<ul>
<?php
$res = fetchCategoryTreeList();
foreach ($res as $r) {
echo $r;
}
?>
</ul>
</article>
</div></p>
<br class="clear" />
</div>
</div>
<?php include("includes/footer.php"); ?>
new-project.html: Allows used to upload a new project.
<?php
include_once('includes/header.php'); ?>
<?php
include_once 'dbconnect.php';
// fetch files
$sql = "select filename from tbl_files";
$result = mysqli_query($con, $sql);
?>
<?php
session_start();
include_once "vendor/autoload.php";
$page = new membership\Page(1);
if ($page->isValid() == true) {
?>
<div id="container">
<div class="wrapper">
<div id="content">
<h2>New Project</h2>
<p><center>
<form action='upload.php' method='post' enctype='multipart/form-data'>
<legend>Select File to Upload:</legend>
<div class='form-group'>
Title: <br /><input type='text' name='title' maxlength="255"/><br /><br />
Description: <br /><textarea type='text' name='description' maxlength="2000"></textarea><br /><br />
<input type='file' name='file1' />
</div>
<div class='form-group'><br />
<input type='submit' name='submit' value='Upload' class='btn btn-info'/>
</div>
<?php if (isset($_GET['st'])) { ?>
<div class='alert alert-danger text-center'>
<?php
if ($_GET['st'] == "success") {
echo "File Uploaded Successfully!";
} else {
echo 'Invalid File Extension!';
}
?>
</div>
<?php } ?>
</form></center>
</p><?php } ?>
<br /></div>
</p>
<div id="column">
<div class="holder">
<h2>Project Upload Rules</h2>
<ul id="latestnews">
This is this rules you must follow for uploading a project.<br /><br />
- You must own the project / script.<br />
- Must be 100% clean / safe.<br />
- Code must be easy to read.<br />
- No outdated code.<br />
<br />
If you don’t follow the rules your account who be banned.
<br />
</p>
<br /></p>
</li>
</ul>
</div>
</div>
<br class="clear" />
</div>
</div>
<?php include_once('includes/footer.php'); ?>
upload.php: This file uploads the info to the database.
<?php include('dbconnect.php'); ?>
<?php
//check if form is submitted
if (isset($_POST['submit']))
{
$filename = $_FILES['file1']['name'];
//upload file
if($filename != '')
{
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$allowed = ['zip', 'rar', 'php', 'html', 'sql'];
//check if file type is valid
if (in_array($ext, $allowed))
{
// get last record id
$sql = 'select max(id) as id from tbl_files';
$result = mysqli_query($con, $sql);
if (count($result) > 0)
{
$row = mysqli_fetch_array($result);
$filename = ($row['id']+1) . '-' . $filename;
}
else
$filename = '1' . '-' . $filename;
//set target directory
$path = 'uploads/';
$created = #date('Y-m-d H:i:s');
move_uploaded_file($_FILES['file1']['tmp_name'],($path . $filename));
$title = '';
if(!empty($_POST['title']))
{
$title = mysqli_real_escape_string($con, $_POST['title']);
}
$description = '';
if(!empty($_POST['description']))
{
$description = mysqli_real_escape_string($con, $_POST['description']);
}
// insert file details into database
$sql = "INSERT INTO tbl_files(filename, created, title, description) VALUES('$filename', '$created', '$title', '$description')";
mysqli_query($con, $sql);
header("Location: new-project.html?st=success");
}
else
{
header("Location: new-project.html?st=error");
}
}
else
header("Location: new-project.html");
}
?>
I am having a summary page which will show all the customer name which is called readmsg.php and each of the customer has a unique msgid in MySQL database. The other page can view their details which are called readmsgdetail.php.
However, I am having the problem in using the msgid to display only one customer's details. For now, my readmsgdetail.php can show all the details for all customers.
The code for my readmsg.php:
<div class="row">
<?php
$stmt = $DB_con->prepare('SELECT firstname,lastname,phone,enquiry FROM user_message ORDER BY msgid DESC');
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<div class="col-xs-12">
<p><a class="page-header" href="readmsgdetail.php?msgdetail_id=<?php echo $row['msgid']; ?>"><?php echo $lastname . $firstname; ?></a></p>
</div>
<?php
}
} else {
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
</div>
The code for my readmsgdetail.php:
<?php
require_once 'dbconfig.php';
//////------------------------------------------------
session_start();
if (empty($_SESSION) || empty($_SESSION['login_id'])) {
header('location:login.php');
};
echo"Welcome!! " . $_SESSION['login_id'] . " ";
echo 'log out';
//-----------------------------------------------------
if (isset($_REQUEST['msgdetail_id']) && !empty($_REQUEST['msgdetail_id'])) {
$id = $_REQUEST['msgdetail_id'];
} else {
header("Location: readmsg.php");
}
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<link href="../bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="../bootstrap/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<div class="page-header">
<h1 class="h2">User review <a class="btn btn-default" href="readmsg.php"> all reviews </a></h1>
</div>
<?php
$stmt = $DB_con->prepare('SELECT firstname,lastname,phone,enquiry FROM user_message ORDER BY msgid DESC');
$stmt->execute();
if ($stmt->rowCount() > 0) {
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<form method="post" enctype="multipart/form-data" class="form-horizontal">
<table class="table table-bordered table-responsive">
<tr>
<td><label class="control-label">Name.</label></td>
<td><input class="form-control" type="text" name="name" value="<?php echo $lastname . $firstname; ?>" required /></td>
</tr>
<tr>
<td><label class="control-label">Phone </label></td>
<td><input class="form-control" type="text" name="phone" value="<?php echo $phone; ?>" required /></td>
</tr>
<tr>
<td><label class="control-label">Feedback / Enquiry.</label></td>
<td><input class="form-control" type="text" name="comment" value="<?php echo $enquiry; ?>" required /></td>
</tr>
<tr>
<td colspan="2">
<a class="btn btn-default" href="readmsg.php"> <span class="glyphicon glyphicon-backward"></span> back </a>
</td>
</tr>
</table>
</form>
<?php
}
} else {
?>
<div class="col-xs-12">
<div class="alert alert-warning">
<span class="glyphicon glyphicon-info-sign"></span> No Data Found ...
</div>
</div>
<?php
}
?>
</div>
</body>
</html>
The stucture of MySQL:
The current result for the webpage:
After I change my select statement to
$stmt = $DB_con->prepare("SELECT firstname,lastname,phone,enquiry FROM user_message where msgid = 'msgdetail_id'");
It shows 'no data found'.
The code in readmsg.php should change to :
$stmt = $DB_con->prepare('SELECT msgid, firstname,lastname,phone,enquiry FROM user_message ORDER BY msgid DESC');
The code in readmsgdetail.php should change to:
$stmt = $DB_con->prepare("SELECT firstname,lastname,phone,enquiry FROM user_message where msgid=$id");
This is woking now! Thx for the help from the comments!.
I am trying to add an, upload an image to a directory in my root. When I hit the submit button for the add image it shows the error in the if statement as if it was false.
I have no idea what I am doing wrong.
To see what I have live visit here: http://travismichael.net/SeniorProject
I have my uploads folder in my root and i made it writable.
Here is my Controller
function do_upload() {
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '32';
$config['max_width'] = '200';
$config['max_height'] = '200';
$this->load->library('upload', $config);
if ( !$this->upload->do_upload('userfile'))
{
echo '<p>IMAGE NOT WORKING</p>';
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('partials/upload_success', $data);
}
Here is my View
<!DOCTYPE html>
<?php $this->load->view('partials/page_head'); ?>
<body>
<body class="home">
<div id="container">
<div id="top">
<div class="topcenter">
<h2><a class="addbtn">Add Folder</a></h2>
<h2><a class="deletebtn" href="<?php echo base_url();?>index.php/home/delete">DeleteFolders</a></h2>
</div>
<div class="navdescription"><span>Home</span></div>
</div>
<div class="projectFolders">
<?php foreach($foldername as $row) { ?>
<div class="folder <?php echo $row->folderName; ?>">
<button class="<?php echo $row->folderName; ?>"><?php echo $row->folderName; ?> </button>
</div>
<script>
$(function () {
$('button.<?php echo $row->folderName; ?>').bind('click',
function() { $('.open.<?php echo $row->folderName;?>').show() });
$('.gohome').bind('click',
function() { $('.open.<?php echo $row->folderName;?>').hide() });
});
</script>
<?php } ?>
<?php foreach($foldername as $row) { ?>
<div class="open <?php echo $row->folderName; ?>">
<h1><?php echo $row->folderName;?></h1>
<a class="gohome">Home</a><a class="addimagebtn">Add Image</a>
<div class="edititable" contenteditable="true" focus="true">
Your Content Goes Here
</div>
</div>
<?php } ?>
<div class="uploadimage">
<?php echo form_open_multipart('home/do_upload');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="Add Image" />
</form>
</div>
</div>
<div id="bottom">
<div class="formWrapper">
<form accept-charset="utf-8" method="post" action="<?php echo base_url(); ?>index.php/home/create" id="cf_form">
<input type="text" name="folderName" placeholder="Enter new Folder" class="required" required/>
<?php echo form_submit('createFolder', 'Create Folder'); ?>
<?php echo form_close(); ?>
<?php echo validation_errors('<p class="error">'); ?>
</div>
</div>
</div><!-- End of container div -->
</body>
</html>
Some reason Codeignitor forgot to update their Documentation.
You need to add this line right above where you call the upload library
$this->upload->initialize($config);
I have the following navigation bar script:
<?php session_start();
require('includepath.inc.php');
require($include_path.'loginsysfunc.inc.php');
$current_page = $_SERVER['REQUEST_URI'];
?>
<div class="navbar">
<img class="navlogo" src="logo.png">
<div class="navbutton">Home</div>
<div class="navbutton">About</div>
<div class="navbutton">Donate</div>
<?php
if (loggedIn()){
?>
<div class="navusername"><?php echo $_SESSION['username']; ?></div>
<div class="navtoolsettings">Settings</div>
<div class="navtoollogout">Log out
<?php
} elseif ($current_page == '/login.php') {
?>
<div class="navregister">Register</div>
<?php
} else {
?>
<div class="navusername">Log in</div>
<?php
}
?>
</div>
For some reason, a strange "?>" is being displayed. I am super confused, so please help.
Here is includepath.inc.php (the only I reason it's there is because I am on a shared host, and I don't want to type '/home/bigdumbhash/public_html/include' everytime. But, here it is:
<?php
$include_path = '/home/a6595899/public_html/include/';
?>
Here is loginsysfunc.inc.php. These are functions that go with my login system to save time:
<?php
function valUser() {
session_regenerate_id();
$_SESSION['valid'] = true;
$_SESSION['username'] = $userid;
echo '<meta http-equiv="refresh" content="0;URL=\'index.php\'">';
}
function loggedIn()
{
if($_SESSION['valid'] == true) {
return true;
} else {
return false;
}
}
function createSalt() {
$string = $string = md5(uniqid(rand(), true));
return substr($string, 0, 3);
}
function logout()
{
$_SESSION = array();
session_destroy();
echo '<meta http-equiv="refresh" content="0;URL=\'index.php\'">';
}
?>
Here is the actual HTML of the page:
<!DOCTYPE html>
<html>
<head>
<link href="style.css" rel="stylesheet" type="text/css">
<title>
Log in
</title>
</head>
<body>
<div class="navbar">
<img class="navlogo" src="logo.png">
<div class="navbutton">Home</div>
<div class="navbutton">About</div>
<div class="navbutton">Donate</div>
<div class="navregister">Register</div>
</div> ?>
<div class="loginbox">
<h1>Log in</h1>
<form action="logingo.php" method="POST">
<input class="userpass" type="text" name="username" value="Username" onFocus="this.value='';">
<br>
<input class="userpass" type="password" name="password" value="Password" onFocus="this.value='';">
<br>
<input class="loginbutton" type="submit" value="Log in!">
</form>
</div>
</body>
</html>
<?php session_start();
require('includepath.inc.php');
require($include_path.'loginsysfunc.inc.php');
$current_page = $_SERVER['REQUEST_URI'];
?>
<div class="navbar">
<img class="navlogo" src="logo.png">
<div class="navbutton">Home</div>
<div class="navbutton">About</div>
<div class="navbutton">Donate</div>
<?php
if(loggedIn()){
?>
<div class="navusername"><?php echo $_SESSION['username']; ?></div>
<div class="navtoolsettings">Settings</div>
<div class="navtoollogout">Log out
<?
}else if($current_page == '/login.php'){
?>
<div class="navregister">Register</div>
<?
}else{
?>
<div class="navusername">Log in</div>
<?php
}
?>
</div>
According to the HTML output you posted, the problem seems to be somewhere in the file that displays <div class="loginbox"> (before that).
Have a look to the contents of that file.