Please help out. I have an html form with meant to be submitted to mysql database. I have written the html and the php script for inserting data but it does not insert data into mysql and it throws an error "something went wrong" as I have programmed it show when data is not inserted. My problem now is how do I find out the error message or how do I re-code it so it can be submitted successfully. Many thanks as I await your responses.
<?php
session_start();
if (!isset($_SESSION['SESSION_EMAIL'])) {
header("Location: index.php");
die();
}
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\Exception;
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
//Load Composer's autoloader
require 'vendor/autoload.php';
include 'includes/config.php';
include 'includes/db.php';
include 'includes/functions.php';
$msg = "";
if (isset($_POST['save'])) {
$fname = mysqli_real_escape_string($db, $_POST['fname']);
$mname = mysqli_real_escape_string($db, $_POST['mname']);
$lname = mysqli_real_escape_string($db, $_POST['lname']);
$gender = mysqli_real_escape_string($db, $_POST['gender']);
$phone = mysqli_real_escape_string($db, $_POST['phone']);
$email = mysqli_real_escape_string($db, $_POST['email']);
$birthdate = mysqli_real_escape_string($db, $_POST['birthdate']);
$community = mysqli_real_escape_string($db, $_POST['community']);
$lga = mysqli_real_escape_string($db, $_POST['lga']);
$caddress = mysqli_real_escape_string($db, $_POST['caddress']);
$haddress = mysqli_real_escape_string($db, $_POST['haddress']);
$flgac = mysqli_real_escape_string($db, $_POST['flgac']);
$mlgac = mysqli_real_escape_string($db, $_POST['mlgac']);
$nok = mysqli_real_escape_string($db, $_POST['nok']);
$nokphone = mysqli_real_escape_string($db, $_POST['nokphone']);
$nokemail = mysqli_real_escape_string($db, $_POST['nokemail']);
if (mysqli_num_rows(mysqli_query($db, "SELECT * FROM personalinfo WHERE Email='{$email}'")) > 0) {
echo $msg = "<div class='alert alert-danger'>{$email} - This email address already exists!.</div>";
} else {
$sql = "INSERT INTO personalinfo (Firstname, Middlename, Lastname, Gender, Phone, Email, DOB, Community, LGA, ContactAddress, HomeAddress, FatherLGACommunity, MotherLGACommunity, NOK, NOKPhone, NOKEmail) VALUES ('{$fname}', '{$mname}', '{$lname}', '{$gender}', '{$phone}', '{$email}', '{$birthdate}', '{$community}', '{$lga}', '{$caddress}', '{$haddress}', '{$flgac}', '{$mlgac}', '{$nok}', '{$nokphone}', '{$nokemail}')";
}
$result = mysqli_query($db, $sql);
if ($result) {
echo $msg = "<div class='alert alert-info'>Personal Info Saved Successfully!.</div>";
} else {
echo $msg = "<div class='alert alert-danger'>Something went wrong.</div>";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>HYPREP - Educational Support For Ogonis</title>
<!-- Favicon-->
<link rel="icon" type="image/x-icon" href="images/ORMLogo.jpg" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="d-flex" id="wrapper">
<!-- Sidebar-->
<div class="border-end bg-white" id="sidebar-wrapper">
<div class="sidebar-heading border-bottom bg-light">ORM Consult & Ltd</div>
<img src="images/ormconsult.jpg" alt="orm_logo" width="52" height="52" style="align:center">
<div class="list-group list-group-flush">
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="personalinfo.php">Personal Info</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="editpersonalinfo.php">Edit Personal Info</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="educationalinfo.php">Educational Info</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="editeducationalinfo.php">Edit Educational Info</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="bankinfo.php">Bank Info</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="editbankinfo.php">Edit Bank Info</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="documentinfo.php">Document Upload</a>
<a class="list-group-item list-group-item-action list-group-item-light p-3" href="editdocumentinfo.php">Edit Document</a>
</div>
</div>
<!-- Page content wrapper-->
<div id="page-content-wrapper">
<!-- Top navigation-->
<nav class="navbar navbar-expand-lg navbar-light bg-light border-bottom">
<div class="container-fluid">
<button class="btn btn-primary" id="sidebarToggle">Toggle Menu</button>
<h6>Welcome <?php $query = mysqli_query($db, "SELECT * FROM users WHERE email='{$_SESSION['SESSION_EMAIL']}'"); if (mysqli_num_rows($query) > 0) {$row = mysqli_fetch_assoc($query); echo $row['name'];}?></h6>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ms-auto mt-2 mt-lg-0">
<li class="nav-item active"><a class="nav-link" href="hyprep/index.php">Home</a></li>
<li class="nav-item"><a class="nav-link" href="changepassword.php">Change Password</a></li>
<li class="nav-item"><a class="nav-link" href="logout.php">Logout</a></li>
<!--<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" id="navbarDropdown" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#!">Action</a>
<a class="dropdown-item" href="#!">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#!">Something else here</a>
</div>
</li>-->
</ul>
</div>
</div>
</nav>
<!-- Page content-->
<div class="container-fluid">
<img src="images/Hyprep.jfif" alt="orm_logo" width="120" height="82" style="align:center">
<h2 class="mt-4">PERSONAL INFO</h2>
<br>
<?php echo $msg; ?>
<br>
<form method="post" action="personalinfo.php">
<div class="row">
<div class="form-group col-md-4">
<input type="text" class="form-control" id = "fname" name="fname" placeholder="First Name" required>
</div>
<div class="form-group col-md-4">
<input type="text" class="form-control" id="mname" name="mname" placeholder="Middle Name" required>
</div>
<div class="form-group col-md-4">
<input type="text" class="form-control" id = "lname" name="lname" placeholder="Last Name" required>
</div>
</div>
<!-- End of A Row-->
<br>
<div class="row">
<div class="form-group col-md-4">
<select id="gender" name="gender" class="form-control">
<option value="Select gender" selected>Select Gender</option>
<option value="M">Male</option>
<option value="F">Female</option>
</select>
</div>
<div class="form-group col-md-4">
<input type="text" class="form-control" id="phone" name="phone" maxlength="11" placeholder="Phone" required>
</div>
<div class="form-group col-md-4">
<input type="email" class="form-control" id ="email" name="email" placeholder="Email" value ="<?php $query = mysqli_query($db, "SELECT * FROM users WHERE email='{$_SESSION['SESSION_EMAIL']}'");
if (mysqli_num_rows($query) > 0) {
$row = mysqli_fetch_assoc($query);
echo $row['email'];
} ?>" required readonly>
</div>
</div>
<!-- End of A Row-->
<br>
<div class="row">
<div class="form-group col-md-4">
<input type="date" class="form-control" id="birthdate" name="birthdate" placeholder="Birth Date" required>
</div>
<div class="form-group col-md-4">
<input type="text" class="form-control" id= "community" name="community" placeholder="Community" required>
</div>
<div class="form-group col-md-4">
<select id="lga" name="lga" class="form-control">
<option value="Select LGA" selected>Select LGA</option>
<option value="E">Eleme</option>
<option value="G">Gokana</option>
<option value="K">Khana</option>
<option value="T">Tai</option>
</select>
</div>
</div>
<br>
<!-- End of A Row-->
<div class="row">
<div class="form-group col-md-4">
<input type="text" class="form-control" id = "caddress" name="caddress" placeholder="Contact Address" required>
</div>
<div class="form-group col-md-4">
<input type="text" class="form-control" id="haddress" name="haddress" placeholder="Home Address" required>
</div>
<div class="form-group col-md-4">
<input type="text" class="form-control" id="flgac" name="flgac" placeholder="Father LGA/Community" required>
</div>
</div>
<!-- End of A Row-->
<br>
<div class="row">
<div class="form-group col-md-3">
<input type="text" class="form-control" id = "mlgac" name="mlgac" placeholder="Mother LGA/Community" required>
</div>
<div class="form-group col-md-3">
<input type="text" class="form-control" id ="nok" name="nok" placeholder="Next of Kin Name" required>
</div>
<div class="form-group col-md-3">
<input type="text" class="form-control" id="nokphone" name="nokphone" maxlength="11" placeholder="Next of Kin Phone" required>
</div>
<div class="form-group col-md-3">
<input type="text" class="form-control" id = "nokemail" name="nokemail" placeholder="Next of Kin Email" required>
</div>
</div>
<!-- End of A Row-->
<br>
<?php echo $msg;?>
<br>
<button type="submit" id = "save" name="save" class="btn btn-primary">SAVE</button>
</form>
</div>
<!-- Bootstrap core JS-->
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>
Asuming there is an issue with the query check the error log using mysqli_error()
Related
I am just trying to create a record in my players table to test that my php works, but each time I click my submit I get a 500 error instead of my url error handlers that should return if my data is not correct for my domain or fields are empty.
I do have a session which is holding my user data.
My user creates php works which is what I based my player create php code off of. I will post my table so you can see the structure and my php include and my HTML please any help would be great
My php include code --------------
<?php
if (isset($_POST['submit'])) {
include_once 'dbh.php';
$player_first = mysqli_real_escape_string($conn, $_POST['player_first']);
$player_last = mysqli_real_escape_string($conn, $_POST['player_last']);
$player_mobile = mysqli_real_escape_string($conn, $_POST['player_mobile']);
$player_address = mysqli_real_escape_string($conn,
$_POST['player_address']);
$player_city = mysqli_real_escape_string($conn, $_POST['player_city']);
$player_state = mysqli_real_escape_string($conn, $_POST['player_state']);
$player_zip = mysqli_real_escape_string($conn, $_POST['player_zip']);
$player_dob = mysqli_real_escape_string($conn, $_POST['player_dob']);
$player_gender = mysqli_real_escape_string($conn, $_POST['player_gender']);
$player_id = mysqli_real_escape_string($conn, $_POST['player_id']);
//Error handlers
//Check for empty fields
if (empty($player_first) || empty($player_last) || empty($player_mobile) ||
empty($player_address) || empty($player_city) || empty($player_state)||
empty($player_zip)|| empty($player_dob)|| empty($player_gender) ||
empty($player_id)) {
header("Location: ../profile.php?profile=empty");
exit();
}
else {
//check if input characters are valid
if (!preg_match("/^[a-zA-Z]*$/", $player_first)
|| !preg_match("/^[a-zA-Z]*$/", $player_last)) {
header("Location: ../profile.php?profile=invalid");
exit();
}
else {
//check if email is valid
if (!filter_var($player_mobile, FILTER_SANITIZE_NUMBER_INT)) {
header("Location: ../profile.php?player=mobile");
exit();
} else {
$sql = "SELECT * FROM players WHERE player_id='$player_id'";
$result = mysqli_query($conn, $sql);
$resultCheck = mysqli_num_rows($result);
if ($resultCheck > 0) {
header("Location: ../profile.php?profile=playertaken");
exit();
} else {
//Insert the player into the database
$sql = "INSERT INTO players (player_first, player_last, ,
player_mobile, player_address, player_city, player_state, player_zip,
player_dob, player_gender, player_id) VALUES
('$player_first', '$player_last', '$player_address',
'$player_city', '$player_state', '$player_zip', '$player_dob',
'$player_gender', '$player_id');";
mysqli_query($conn, $sql);
header("Location: ../profile.php");
exit();
}
}
}
}
else {
header("Location: ../profile.php");
exit();
}
--------------------------------------------------------------End of php include
My html/php page code ----------------------------------------------------------
<?php
session_start();
include_once 'header.php';
include 'includes/dbh.php';
?>
<!-- ============================================================== -->
<!-- Page Content -->
<!-- ============================================================== -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Profile page</h4> </div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<button class="right-side-toggle waves-effect waves-
light btn-info btn-circle pull-right m-l-20"><i class="ti-settings text-
white"></i></button>
<ol class="breadcrumb">
<li>Dashboard</li>
<li class="active">Profile page</li>
</ol>
</div>
</div>
<div class="tab-pane active" id="settings">
<form class="form-horizontal form-material"
action="includes/profile-inc.php" method="POST">
<div class="form-group">
<label class="col-md-12">First
Name</label>
<div class="col-md-12">
<input type="text" required=""
name="player_first" value ="<?php echo $user_first ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-12">Last
Name</label>
<div class="col-md-12">
<input type="text" required=""
name="player_last" value ="<?php echo $user_last ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label for="example-email"
class="col-md-12">Mobile</label>
<div class="col-md-12">
<input type="text" required=""
name="player_mobile" value ="<?php echo $player_mobile ?>" class="form-
control form-control-line"> </div>
</div>
<div class="form-group">
<label for="example-email"
class="col-md-12">Address</label>
<div class="col-md-12">
<input type="address"
required="" name="player_address" value ="<?php echo $player_address ?>"
class="form-control form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">City</label>
<div class="col-md-12">
<input type="text" required=""
name="player_city" value ="<?php echo $player_city ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">State</label>
<div class="col-md-12">
<input type="text" required=""
name="player_state" value ="<?php echo $player_state ?>" class="form-
control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-12">Zip</label>
<div class="col-md-12">
<input type="text" required=""
name="player_zip" value ="<?php echo $player_zip ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-12">Date of
Birth</label>
<div class="col-md-12">
<input type="date" required=""
name="player_dob" value ="<?php echo $player_dob ?>" class="form-control
form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">Gender</label>
<div class="col-md-12">
<input type="text" required=""
name="player_gender" value ="<?php echo $player_gender ?>" class="form-
control form-control-line"> </div>
</div>
<div class="form-group">
<label class="col-md-
12">User_id</label>
<div class="col-md-12">
<input type="text" required=""
name="player_id" value ="<?php echo $user_id ?>" class="form-control form-
control-line"></div>
</div>
<div class="form-group">
<div class="col-sm-12">
<button class="btn btn-success"
type="submit" name="submit">Update Profile</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- /.row -->
<!--
============================================================== -->
<!-- Right sidebar -->
<!--
============================================================== -->
<!-- .right-sidebar -->
<div class="right-sidebar">
<div class="slimscrollright">
<div class="rpanel-title"> Service Panel <span><i
class="ti-close right-side-toggle"></i></span> </div>
<div class="r-panel-body">
<ul id="themecolors" class="m-t-20">
<li><b>With Light sidebar</b></li>
<li><a href="javascript:void(0)" data-
theme="default" class="default-theme">1</a></li>
<li><a href="javascript:void(0)" data-
theme="green" class="green-theme">2</a></li>
<li><a href="javascript:void(0)" data-
theme="gray" class="yellow-theme">3</a></li>
<li><a href="javascript:void(0)" data-
theme="blue" class="blue-theme">4</a></li>
<li><a href="javascript:void(0)" data-
theme="purple" class="purple-theme">5</a></li>
<li><a href="javascript:void(0)" data-
theme="megna" class="megna-theme">6</a></li>
<li><b>With Dark sidebar</b></li>
<br/>
<li><a href="javascript:void(0)" data-
theme="default-dark" class="default-dark-theme">7</a></li>
<li><a href="javascript:void(0)" data-
theme="green-dark" class="green-dark-theme">8</a></li>
<li><a href="javascript:void(0)" data-
theme="gray-dark" class="yellow-dark-theme">9</a></li>
<li><a href="javascript:void(0)" data-
theme="blue-dark" class="blue-dark-theme">10</a></li>
<li><a href="javascript:void(0)" data-
theme="purple-dark" class="purple-dark-theme">11</a></li>
<li><a href="javascript:void(0)" data-
theme="megna-dark" class="megna-dark-theme working">12</a></li>
</ul>
<ul class="m-t-20 all-demos">
<li><b>Choose other demos</b></li>
</ul>
</div>
</div>
</div>
<!--
============================================================== -->
<!-- End Right sidebar -->
<!--
============================================================== -->
</div>
<!-- /.container-fluid -->
<?php
include_once 'footer.php';
?>
------------------------------------------------------------End of html/php code
I'm hoping one of you experts can point out the error in my code for my database connection in my PHP. My page wont work at all.
I'm trying to create new users into my database. I've checked all the names in my table and they match up perfectly.
Here is my function:
<?php include('connection.php'); ?>
<?php
function createUser()
{
if(isset($_POST['submit']))
{
global $connection;
$username = $_POST['username'];
$password = $_POST['password'];
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$emailAddress = $_POST['emailAddress'];
$phoneNumber = $_POST['phoneNumber'];
$privilege = $_POST['privilege'];
$query = "INSERT INTO users(username,password,firstName,lastName,emailAddress,phoneNumber,privilege)";
$query .= "VALUES ('$username', '$password','$firstName','$lastName','$emailAddress','$phoneNumber','$privilege')";
$result = mysqli_query($connection, $query);
if(!$result)
{
die('Query Failed' . mysqli_error());
}
else
{
echo '<div class="modal-footer">
<div class="alert alert-success alert-block fade in" id="successAlert">
<button class="close" type="button" data-dismiss="alert" aria-label="close"><span aria-hidden="true">×</span></button>
<h4>Success!</h4>
<p>New user registered successfully</p>
</div>
</div>';
die;
}
}
}
?>
Here is my HTML:
I call the header.php into my home page but the functions are also called on in there.
<?php include('connection.php'); ?>
<?php include('functions.php'); ?>
<?php createUser(); ?>
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<button class="navbar-toggle" data-target=".navbar-responsive-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- end responsive-dropdown -->
RichmondMC
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li>Movie Database</li>
<li>Gallery</li>
<li>Ratings</li>
</ul>
<!-- end navbar-nav -->
<ul class="nav navbar-nav pull-right">
<li class="dropdown">
<span class="glyphicon glyphicon-user"></span> My Account <strong class="caret"></strong>
<ul class="dropdown-menu">
<li><span class="glyphicon glyphicon-wrench"></span> Settings</li>
<li><span class="glyphicon glyphicon-list-alt"></span> Register New User</li>
<li class="divider"></li>
<li><span class="glyphicon glyphicon-play"></span> Sign In</li>
<li><span class="glyphicon glyphicon-off"></span> Sign Out</li>
</ul>
<!-- end dropdown-menu -->
</li>
<!-- end dropdown -->
</ul>
<!-- end myAccount-dropdown -->
</div>
<!-- end nav-collapse -->
</div>
<!-- end container -->
</div>
<!-- end navbar -->
<div class="modal fade" id="registerModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
×
<h4 class="modal-title"><span class="glyphicon glyphicon-th-list"></span> New User Registration </h4>
</div>
<!-- end modal-header -->
<div class="modal-body">
<h5>Enter the New Members details including username/password to complete registration</h5><br>
<form action="" class="form-horizontal" method="post">
<div class="form-group">
<label for="username" class="col-lg-4 control-label">Username:</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="username" name="username" placeholder="Username" required>
</div>
</div>
<div class="form-group">
<label for="password" class="col-lg-4 control-label">Password:</label>
<div class="col-lg-8">
<input type="password" class="form-control" id="password" name="password" placeholder="Password" required>
</div>
</div>
<div class="form-group">
<label for="firstName" class="col-lg-4 control-label">First Name:</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="firstName" name="firstName" placeholder="First Name" required>
</div>
</div>
<div class="form-group">
<label for="lastName" class="col-lg-4 control-label">Last Name:</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="lastName" name="lastName" placeholder="Last Name" required>
</div>
</div>
<div class="form-group">
<label for="emailAddress" class="col-lg-4 control-label">Email Address:</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="emailAddress" name="emailAddress" placeholder="Email Address" required>
</div>
</div>
<div class="form-group">
<label for="phoneNumber" class="col-lg-4 control-label">Phone Number:</label>
<div class="col-lg-8">
<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" placeholder="Phone Number" required>
</div>
</div>
<div class="form-group">
<label for="role" class="col-lg-4 control-label">Privileges</label>
<div class="col-lg-8">
<select name="Role" id="role" class="form-control">
<option value="member" name="privilege">Member</option>
<option value="admin" name="privilege">Admin</option>
</select>
</div>
</div>
<button class="btn btn-success pull-right" type="submit" name="submit" id="alertMe">Submit</button><br>
</form>
<!-- end form -->
</div>
<!-- end modal-body -->
</div>
<!-- end modal-content -->
</div>
<!-- end modal-dialog -->
</div>
<!-- end modal -->
</body>
</html>
<html>
<head>
<title>
Installation
</title>
<script src="public/js/jquery-1.9.0.min.js"></script>
<script src="public/js/bootstrap3/js/bootstrap.js"></script>
<link media="all" type="text/css" rel="stylesheet" href="public/js/bootstrap3/css/bootstrap.min.css">
<link media="all" type="text/css" rel="stylesheet" href="public/js/bootstrap3/css/font-awesome.min.css">
<link media="all" type="text/css" rel="stylesheet" href="public/js/bootstrap3/css/main.css">
</head>
<body>
<div
class="navbar navbar-default navbar-fixed-top">
<div
class="container">
<div
class="navbar-header">
<button
type="button"
class="navbar-toggle"
data-toggle="collapse"
data-target=".navbar-collapse">
<span
class="icon-bar"></span>
<span
class="icon-bar"></span>
<span
class="icon-bar"></span>
</button>
<a
class="navbar-brand"
href="<?php // echo base_url()?>">Kingpabel
ATN</a>
</div>
<div
class="navbar-collapse collapse">
</div>
<!--/.nav-collapse -->
</div>
</div>
<div
class="rc">
<div
class="container main">
<div
class="col-md-3">
</div>
<div
class="col-md-6">
<form
method="post"
accept-charset="utf-8"
role="form"
class="form- signin form-horizontal">
<h2
class="form-signin-heading">Installation</h2>
<div
style="margin-top: 20px;">
<label
for="host_name"
class="col-sm-3 control-label"
style="color: black">
Host
Name
</label>
<div
class="input text database_host col-md-9">
<input
type="text"
name="host_name"
class="form-control"
placeholder="Database Host Name"
autofocus=""
required="required"
id="host_name">
</div>
</div>
<div>
<label
for="database_name"
class="col-sm-3 control-label"
style="color: black">
Database
Name
</label>
<div
class="input text database_name col-md-9">
<input
type="text"
name="database_name"
class="form-control"
placeholder="Database Name"
autofocus=""
required="required"
id="database_name">
</div>
</div>
<div>
<label
for="user_name"
class="col-sm-3 control-label"
style="color: black">
User
Name
</label>
<div
class="input text user_name col-md-9">
<input
type="text"
name="user_name"
class="form-control"
placeholder="Database User Name"
autofocus=""
required="required"
id="user_name">
</div>
</div>
<div>
<label
for="password"
class="col-sm-3 control-label"
style="color: black">
Password
</label>
<div
class="input text password col-md-9">
<input
type="password"
name="password"
class="form-control"
placeholder="Database Password"
autofocus=""
id="password">
</div>
</div>
<div>
<label
for="project_url"
class="col-sm-3 control-label"
style="color: black">
Project
Url
</label>
<div
class="input text project_url col-md-8 input-group input-group-sm">
<input
style=" margin-left: 13px;"
type="text"
name="project_url"
class="form-control"
placeholder="Project URL"
autofocus=""
id="project_url"
aria-describedby="basic-addon2">
<span
class="input-group-btn">
<button
class="btn btn-default"
type="button"
style="margin-top: -15px;">/public</button>
</span>
</div>
</div>
<button
type="submit"
class="btn btn-lg btn-login btn-block">Install</button>
</form>
</div>
</div>
</div>
<section
id="bottom"
style="margin-top: 50px">
</section>
<footer
id="footer">
<div
class="container">
<div
class="footer">
<div
class="row">
<div
class="col-md-12">
</div>
</div>
</div>
</div>
</footer>
</body>
</html>
<?php
if ($_POST) {
$envFile = file_get_contents('.env');
if (isset($_POST['host_name']) && $_POST['host_name'])
$envFile = str_replace('DB_HOST=localhost', "DB_HOST= {$_POST['host_name']}", $envFile);
if (isset($_POST['database_name']) && $_POST['database_name'])
$envFile = str_replace('DB_DATABASE=homestead', "DB_DATABASE={$_POST['database_name']}", $envFile);
if (isset($_POST['user_name']) && $_POST['user_name'])
$envFile = str_replace('DB_USERNAME=homestead', "DB_USERNAME={$_POST['user_name']}", $envFile);
if (isset($_POST['password']) && $_POST['password'])
$envFile = str_replace('DB_PASSWORD=secret', "DB_PASSWORD={$_POST['password']}", $envFile);
file_put_contents('.env', $envFile);
if (isset($_POST['project_url']) && $_POST['project_url']) {
file_get_contents('index.php');
file_put_contents('index.php', "<?php
header('Location: {$_POST['project_url']}/public');
");
}
}`
In above code, after submitting the form, the idex.php is rewriiten and changes. And i wanted to redirect to another page after submitting the form. But it is not being redirected.
Not sure what all your block of codes are for but perhaps try this..
On your
if (isset($_POST['project_url']) && $_POST['project_url']) {
file_get_contents('index.php');
file_put_contents('index.php', "<?php
header('Location: {$_POST['project_url']}/public');
");
}
change to
if (isset($_POST['project_url']) && $_POST['project_url']) {
$url = $_POST['project_url'] + '/public';
header('Location: $url');
}
checkout.php
...............
I use this code it. When i buy 2 or more items, only 1 item stored in my database. thanks in advance...................
<?php
session_start();
include('conn.php');
require('item.php');
if(isset($_POST['confirm'])){
$order=$_POST['order'];
$date = date('Y-m-d H:i:s');
$lname=$_POST['lname'];
$fname=$_POST['fname'];
$mname=$_POST['mname'];
$add=$_POST['add'];
$em=$_POST['email'];
$num=$_POST['number'];
if(empty($order)){
echo"<script>alert('Please choose your payment method.')</script>";
}
mysqli_query($con,"INSERT INTO `godgets`.`order` (`Lastname`, `Firstname`, `Middlename`, `Address`, `Email`, `Number`, `Date`) VALUES ('$lname', '$fname', '$mname', '$add', '$em', '$num', '$date')");
$orderid=mysqli_insert_id($con);
$cart=unserialize(serialize($_SESSION['cart']));
for ($i=0; $i<count($cart); $i++) {
$p_name=$cart[$i]->name;
$p_price=$cart[$i]->price;
$p_des=$cart[$i]->des;
$p_quantity=$cart[$i]->quantity;
$p_image=$cart[$i]->image;
$p_total=$cart[$i]->price * $cart[$i]->quantity;
mysqli_query($con,"INSERT INTO order_details (`ORDER_ID`, `P_name`, `P_price`, `P_quantity`, `Picture`,`Total`) VALUES
('.$orderid.', '$p_name.', '.$p_price.', '.$p_quantity.', '.$p_image.','.$p_total.')");
}
echo"<script>alert('Thankyou For Shopping!')</script>";
echo"<script>window.open('index.php','_self')</script>";
unset($_SESSION['cart']);
exit();
}
?>
help me please i`m a newbie :(
tnx
fds
item.php
<?php
class Item{
var $id;
var $name;
var $des;
var $quantity;
var $price;
var $image;
}
?>
addcart.php
<?php
session_start();
?>
<head>
<meta name="viewport" content="width=device-width, initial- scale=1">
<link rel="stylesheet" type="text/css" href="css\bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css\bootstrapValidator.min.css">
<script src="jq/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrapValidator.min.js"></script>
</head>
<body background="pic/bg3.jpg" style="background-attachment:fixed;background-size:cover;">
<?php include("navbar.php");
require('conn.php');
require('item.php');
if(!isset($_SESSION['username'])){
echo"<script>window.open('sign.php','_self')</script>";
exit();
}
if(isset($_GET['id']) && !isset($_POST['update'])){
$result=mysql_query('select * from products_db where P_ID ='.$_GET['id']);
$product=mysql_fetch_object($result);
$item= new Item();
$item->id= $product->P_ID;
$item->name=$product->P_NAME;
$item->des=$product->DESCRIPTION;
$item->price=$product->P_PRICE;
$item->image=$product->PICTURE;
$item->quantity=1;
//check product
$index=-1;
$cart=unserialize(serialize($_SESSION['cart']));
for($i=0; $i<count($cart);$i++)
if ($cart[$i]->id==$_GET['id']){
$index=$i;
break;
}
if($index==-1){
$_SESSION['cart'][]=$item;
}
else{
$_SESSION['cart']=$cart;
}
}
//delete
if(isset($_GET['index']) && !isset($_POST['update'])){
$cart=unserialize(serialize($_SESSION['cart']));
unset($cart[$_GET['index']]);
$cart=array_values($cart);
$_SESSION['cart']=$cart;
}
if (isset($_POST['update'])){
$arrQuantity=$_POST['quantity'];
// check quantity
$valid=1;
for($i=0; $i<count($arrQuantity);$i++)
if(!is_numeric($arrQuantity[$i]) || $arrQuantity[$i]< 1){
$valid=0;
break;
}
if($valid==1){
$cart=unserialize(serialize($_SESSION['cart']));
for($i=0; $i<count($cart);$i++){
$cart[$i]->quantity=$arrQuantity[$i];
}
$_SESSION['cart']=$cart;
}
else
$error='Quantity is Invalid';
}
?>
<div class="container">
<div class="row">
<div class="col-md-12 col-xs-12">
<div class="panel panel-info">
<div class="panel-heading">
<form method="POST">
<div class="panel-title">
<h5><span class="glyphicon glyphicon-shopping-cart" style="float:left;"></span> YOUR ITEM(s)
<label style="color:red;margin-left:400px;"><?php echo isset($error) ? $error : '';?></label>
<span class="glyphicon glyphicon-share-alt"></span> Continue Shopping
<button type="submit" name="update" style="float:right; margin-right:3%;"class="btn btn-info btn-sm "><span class="glyphicon glyphicon-floppy-saved"></span>Update Cart</button>
</h5>
</div>
</div>
<?php
$cart=unserialize(serialize($_SESSION['cart']));
$s=0;
$index=0;
for ($i=0;$i<count($cart); $i++){
$s+=$cart[$i]->price * $cart[$i]->quantity;
?>
<div class="panel-body">
<div class="row">
<div class="col-md-2 col-xs-12">
<img class="img-responsive" src="<?php echo $cart[$i]->image;?>" style="height:30%;width:100%;">
</div>
<div class="col-md-4 col-xs-12">
<h4 style="font-family:agency fb;"><strong><?php echo $cart[$i]->name;?></strong></h4>
<div><h4 style="font-family:agency fb;"><small><?php echo $cart[$i]->des;?></small></h4></div>
</div>
<div class="col-md-6 col-xs-12">
<div class="col-md-6 text-right">
<h4 style="font-family:agency fb;"><strong>Php <?php echo $cart[$i]->price;?></strong> x </h4>
</div>
<div class="col-md-4 col-xs-9">
<input type="text" name="quantity[]" value="<?php echo $cart[$i]->quantity;?>" class="form-control" style="width:50px;">
</div>
<div class="col-md-3 col-xs-2" style="margin-top:1%;">
<span class="glyphicon glyphicon-trash"></span>
</div>
</div>
</div>
</div>
<hr class="divider">
<?php
$index++;
}
?>
</form>
<div class="panel-footer" style="height:9%;">
<div>Empty Cart</div>
<div>Checkout</div>
<div style="float:right;margin-right:2%;font-family:agency fb;"><p class="form-control"><b>Total</b> Php: <?php echo $s;?></p></div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header" style="background-color:#cceaf6;">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel" style="font-family:agency fb;font-size:30px;">Costumer`s Information</h4>
</div>
<form method="POST" action="checkout.php">
<div class="modal-body">
<div class="form-group">
<div class="row col-md-12">
<div class="container inline col-md-4" >
<input type="radio" class="form-control" name="order" onclick="showhidediv(this);" value="paypal">
<img src="pic/paypal.jpg" style="width:200px;height:100px;">
</div>
<div class="col-md-4">
<center><span style="font-family:agency fb; font-size: 50px;">or</span></center>
</div>
<div class="col-md-4">
<input type="radio" class="form-control" name="order" onclick="showhidediv(this);" value="Cash On Delivery">
<img src="pic/cash.png" style="width:200px;height:100px;">
</div>
</div>
<div class="form-inline">
<input type="text" class="form-control" name="lname" placeholder="Lastname" required>
<input type="text" class="form-control" name="fname" placeholder="Firstname"required>
<input type="text" class="form-control" name="mname" placeholder="Middlename"required>
</div>
<br>
<input type="text" class="form-control" name="add" placeholder="Complete Address" style="width:596px;"required>
<br>
<input type="email" class="form-control" name="email" placeholder="Email Address"style="width:596px;"required>
<br>
<input type="text" class="form-control" name="number" placeholder="Contact Number"style="width:196px;" required>
<br>
<div id="one" style="display:none;">
<div style="background-color:#cceaf6;"><p>Bill to another address. (Optional)</p></div>
<div class="form-inline">
<input type="text" class="form-control" name="lname2" placeholder="Lastname">
<input type="text" class="form-control" name="fname2" placeholder="Firstname">
<input type="text" class="form-control" name="mname2" placeholder="Middlename">
</div>
<br>
<input type="text" class="form-control" name="add2" placeholder="Complete Address" style="width:596px;">
<br>
<input type="email" class="form-control" name="email2" placeholder="Email Address"style="width:596px;">
<br>
<input type="text" class="form-control" name="number2" placeholder="Contact Number"style="width:196px;">
</div>
</div>
</div>
<div class="modal-footer">
<button type="submit" name="confirm" class="btn btn-success" style="font-family:agency fb;font-size:15px;width:100px;">OK</button>
</div>
</form>
</div>
</div>
</body>
<script>
function goBack() {
window.history.back();
}
function showhidediv( rad )
{
var rads = document.getElementsByName( rad.name );
document.getElementById( 'one' ).style.display = ( rads[1].checked ) ? 'block' : 'none';
}
</script>
Error
only 1 item stored.
Hi you need to correct this: '.$cart[$i]->image.'
for ($i=0; $i<count($cart); $i++) {
mysql_query("INSERT INTO order_details VALUES ('.$orderid.', '.$cart[$i]->name.', '.$cart[$i]->price.', '.$cart[$i]->quantity.', '.$cart[$i]->image.', '.$cart[$i]->price * $cart[$i]->quantity.','.$order.')");
}
Also please highlight the error line in the code next time you ask such question.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 7 years ago.
Improve this question
I get getting this error:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE user_id = 1' at line 1
I have tried everything in '' or "", even '. .' and "'. .'".
I can't find anything wrong with it. Please help!
It should update the MySQL database but it only outputs that error.
<?
ob_start();
$mid = $_GET['id'];
include 'connect.php';
if($_SESSION['signed_in'] == false | $_SESSION['user_level'] != 2)
{
header('Location: index.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Group 5 Waggle</title>
<link rel="stylesheet" type="text/css" href="bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" type="text/css" href="font-awesome/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="css/local.css" />
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
</head>
<body>
<div id="wrapper">
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="index.php">Waggle</a>
</div>
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav">
<? if($_SESSION['signed_in'] == true && $_SESSION['user_level'] == 2 ) { ?>
<li> </li>
<li><i class="fa fa-table"></i> Add User</li>
<li><i class="fa fa-tasks"></i> Cream Forums</li>
<? } ?>
</ul>
<?
if($_SESSION['signed_in'])
{ ?>
<ul class="nav navbar-nav navbar-right navbar-user">
<li class="dropdown user-dropdown">
<i class="fa fa-user"></i> <?=htmlentities($_SESSION['user_name']); ?> <b class="caret"></b>
<ul class="dropdown-menu">
<li><i class="fa fa-user"></i> Profile</li>
<li><i class="fa fa-gear"></i> Edit Profile</li>
<li class="divider"></li>
<li><i class="fa fa-power-off"></i> Logout</li>
</ul>
</li>
</ul>
<? } ?>
</div>
</nav>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1>Update <small>User</small></h1>
</div>
</div>
<p> </p>
<div class="row">
<? if($_SERVER['REQUEST_METHOD'] != 'POST') {
$result1 = mysql_query("SELECT * FROM users WHERE user_id = '$mid'");
$row = mysql_fetch_array($result1);
?>
<form method="post" action="">
<div class="col-lg-12">
<div>
<label for="firstname" class="col-md-2">
Full Name:
</label>
<div class="col-md-9">
<input type="text" name="user_name" class="form-control" id="firstname" value="<?=$row[user_name];?>">
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="emailaddress" class="col-md-2">
Email address:
</label>
<div class="col-md-9">
<input type="text" name="user_email" class="form-control" id="emailaddress" value="<?=$row[user_email];?>">
<p class="help-block">
Example: yourname#domain.com
</p>
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="password" class="col-md-2">
Password:
</label>
<div class="col-md-9">
<input type="password" name="user_pass" class="form-control" id="password" placeholder="Enter Password">
<p class="help-block">
Min: 6 characters (Alphanumeric only)
</p>
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="password" class="col-md-2">
Password (again):
</label>
<div class="col-md-9">
<input type="password" name="user_pass_check" class="form-control" id="password" placeholder="Enter Password">
<p class="help-block">
Min: 6 characters (Alphanumeric only)
</p>
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="website" class="col-md-2">
Website:
</label>
<div class="col-md-9">
<input type="text" name="user_web" class="form-control" id="website" value="<?=$row[user_web];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="twitter" class="col-md-2">
Twitter:
</label>
<div class="col-md-9">
<input type="text" name="user_twitter" class="form-control" id="twitter" value="<?=$row[user_twitter];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="facebook" class="col-md-2">
Facebook:
</label>
<div class="col-md-9">
<input type="text" name="user_facebook" class="form-control" id="facebook" value="<?=$row[user_facebook];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="github" class="col-md-2">
Github:
</label>
<div class="col-md-9">
<input type="text" name="user_github" class="form-control" id="github" value="<?=$row[user_github];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="uploadimage" class="col-md-2">
Profile Image:
</label>
<div class="col-md-10">
<input type="file" name="uploadimage" id="uploadimage">
<p class="help-block">
Allowed Formats: jpeg, jpg, gif, png
</p>
</div>
</div>
<div>
<div class="col-md-2">
</div>
<div class="col-md-10">
<br />
<br />
<button type="submit" class="btn btn-info">
Save Profile
</button>
</div>
</div>
</div>
</form>
<? }
else {
/* so, the form has been posted, we'll process the data in three steps:
1. Check the data
2. Let the user refill the wrong fields (if necessary)
3. Save the data
*/
$errors = array(); /* declare the array for later use */
if(!isset($_POST['user_name']))
{
$errors[] = 'The username field must not be empty.';
}
if(isset($_POST['user_pass']))
{
if($_POST['user_pass'] != $_POST['user_pass_check'])
{
$errors[] = 'The two passwords did not match.';
}
}
else
{
$errors[] = 'The password field cannot be empty.';
}
if(!empty($errors)) /*check for an empty array, if there are errors, they're in this array (note the ! operator)*/
{ ?>
<div class="col-lg-4">
<div class="alert alert-dismissable alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
<ul>
<?
foreach($errors as $key => $value) {
echo '<li>' . $value . '</li>';
}
?>
</ul>
</div>
</div>
<br />
<form method="post" action="">
<div class="col-lg-12">
<div>
<label for="firstname" class="col-md-2">
Full Name:
</label>
<div class="col-md-9">
<input type="text" name="user_name" class="form-control" id="firstname" value="<?=$_POST['user_name'];?>">
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="emailaddress" class="col-md-2">
Email address:
</label>
<div class="col-md-9">
<input type="text" name="user_email" class="form-control" id="emailaddress" value="<?=$_POST['user_email'];?>">
<p class="help-block">
Example: yourname#domain.com
</p>
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="password" class="col-md-2">
Password:
</label>
<div class="col-md-9">
<input type="password" name="user_pass" class="form-control" id="password" placeholder="Enter Password">
<p class="help-block">
Min: 6 characters (Alphanumeric only)
</p>
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="password" class="col-md-2">
Password (again):
</label>
<div class="col-md-9">
<input type="password" name="user_pass_check" class="form-control" id="password" placeholder="Enter Password">
<p class="help-block">
Min: 6 characters (Alphanumeric only)
</p>
</div>
<div class="col-md-1">
<i class="fa fa-lock fa-2x"></i>
</div>
</div>
<div>
<label for="website" class="col-md-2">
Website:
</label>
<div class="col-md-9">
<input type="text" name="user_web" class="form-control" id="website" value="<?=$_POST['user_web'];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="twitter" class="col-md-2">
Twitter:
</label>
<div class="col-md-9">
<input type="text" name="user_twitter" class="form-control" id="twitter" value="<?=$_POST['user_twitter'];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="facebook" class="col-md-2">
Facebook:
</label>
<div class="col-md-9">
<input type="text" name="user_facebook" class="form-control" id="facebook" value="<?=$_POST['user_facebook'];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="github" class="col-md-2">
Github:
</label>
<div class="col-md-9">
<input type="text" name="user_github" class="form-control" id="github" value="<?=$_POST['user_github'];?>">
</div>
<div class="col-md-1">
</div>
</div>
<div>
<label for="uploadimage" class="col-md-2">
Profile Image:
</label>
<div class="col-md-10">
<input type="file" name="uploadimage" id="uploadimage">
<p class="help-block">
Allowed Formats: jpeg, jpg, gif, png
</p>
</div>
</div>
<div>
<div class="col-md-2">
</div>
<div class="col-md-10">
<br />
<br />
<button type="submit" class="btn btn-info">
Save Profile
</button>
</div>
</div>
</div>
</form>
<? }
else
{
$new_name = mysql_real_escape_string($_POST['user_name']);
$new_pass = sha1($_POST['user_pass']);
$new_email = mysql_real_escape_string($_POST['user_email']);
$new_web = mysql_real_escape_string($_POST['user_web']);
$new_twitter = mysql_real_escape_string($_POST['user_twitter']);
$new_facebook = mysql_real_escape_string($_POST['user_facebook']);
$new_github = mysql_real_escape_string($_POST['user_github']);
//the form has been posted without, so save it
//notice the use of mysql_real_escape_string, keep everything safe!
//also notice the sha1 function which hashes the password
$sql = "UPDATE `users` SET `user_name` = '$new_name', `user_pass` = '$new_pass', `user_email` = '$new_email', `user_web` = '$new_web', `user_twitter` = '$new_twitter', `user_facebook` = '$new_facebook', `user_github` = '$new_github', `user_level` = '0', WHERE user_id = $mid";
$result = mysql_query($sql);
if(!$result)
{
//something went wrong, display the error
echo $mid;
echo '<div class="well well-lg">Something went wrong while registering. Please try again later.</div>';
echo mysql_error(); //debugging purposes, uncomment when needed
}
else
{
header('Location: index.php');
}
}
}
?>
</div>
</div>
</div>
</body>
</html>
Your problem is in this query:
$sql = "UPDATE `users`
SET `user_name` = '$new_name', `user_pass` = '$new_pass', `user_email` = '$new_email', `user_web` = '$new_web', `user_twitter` = '$new_twitter', `user_facebook` = '$new_facebook', `user_github` = '$new_github', `user_level` = '0', WHERE user_id = $mid";
Particularly in this last part:
`user_level` = '0', WHERE user_id = $mid";
That last comma before the where should be removed.