I would like to create a php form with image upload to database by store image path to database and store the image to your server or directory. I'm kind of not sure how to do image upload.
Database: dbtest
CREATE TABLE IF NOT EXISTS `tbl_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fullName` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
'pic' blob NOT NULL
PRIMARY KEY (`id`),
PHP:
<?php
session_start();
require_once 'class.user.php';
$user_home = new USER();
if(!$user_home->is_logged_in())
{
$user_home->redirect('index.php');
}
if(isset($_POST['btn-register']))
{
$fullName = $_POST['fullName'];
$email = $_POST['email'];
$stmt = $user_home->runQuery("SELECT * FROM bike WHERE id=:id");
$stmt->execute(array(":id"=>$_SESSION['userSession']));
$row = $stmt->fetch(PDO::FETCH_ASSOC);;
if($reg_user->register($email,$fullName))
{
$message = "
Thank You for registering with us!<br/>
<br />
Thanks,<br/>
<br />
Site Admin";
$subject = "Confirm Registration";
}
else
{
echo "sorry , query could no execute.";
}
}
?>
<!DOCTYPE html>
<html class="no-js">
<head>
<title><?php echo $row['email']; ?></title>
<!-- Bootstrap CSS -->
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/bootstrap-theme.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="../css/NewFile.css">
</head>
<body>
<script src="../js/jquery-1.12.3.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<?php include 'navBarLogin.php'; ?>
<?php if(isset($msg)) echo $msg; ?>
<form method="POST" action="" enctype="multipart/form-data">
<h2> Bicycle Register</h2>
<hr>
<table>
<tr>
<td>Full name:</td>
<td><input type="text" class="input-block-level" name="fullName" /></td>
</tr>
<tr>
<td>email:</td>
<td><input type="text" class="input-block-level" name="email" /></td>
</tr>
<tr>
<td>SPicture:</td>
<td><input type="file" name="pic" required />
</tr>
</table>
<button class="btn btn-large btn-primary" type="submit" name="btn-register">Register</button>
</form>
</body>
</html>
website created base on http://www.codingcage.com/2015/09/login-registration-email-verification-forgot-password-php.html