form is not centering in bootstrap - php

I'm using pure Bootstrap, the problem I'm facing is my form is not being fit to the center of the page, and I want it to be at center of the page.
I'm using laravel in this project so some laravel blade syntax is there.
I've the following code in welcome.blade.php
Side Bar in welcome.blade.php
<div class="sidebar" data-color="orange">
<!--
Tip 1: You can change the color of the sidebar using: data-color="blue | green | orange | red | yellow"
-->
<div class="logo">
<a href="http://www.creative-tim.com" class="simple-text logo-mini">
CT
</a>
<a href="http://www.creative-tim.com" class="simple-text logo-normal">
Creative Tim
</a>
</div>
<div class="sidebar-wrapper" id="sidebar-wrapper">
<ul class="nav">
<li class="active ">
<a href="./dashboard.html">
<i class="now-ui-icons design_app"></i>
<p>Measurement</p>
</a>
</li>
<li>
<a href="./icons.html">
<i class="now-ui-icons education_atom"></i>
<p>Icons</p>
</a>
</li>
<li>
<a href="./map.html">
<i class="now-ui-icons location_map-big"></i>
<p>Maps</p>
</a>
</li>
<li>
<a href="./notifications.html">
<i class="now-ui-icons ui-1_bell-53"></i>
<p>Notifications</p>
</a>
</li>
<li>
<a href="./user.html">
<i class="now-ui-icons users_single-02"></i>
<p>User Profile</p>
</a>
</li>
<li>
<a href="./tables.html">
<i class="now-ui-icons design_bullet-list-67"></i>
<p>Table List</p>
</a>
</li>
<li>
<a href="./typography.html">
<i class="now-ui-icons text_caps-small"></i>
<p>Typography</p>
</a>
</li>
<li class="active-pro">
<a href="./upgrade.html">
<i class="now-ui-icons arrows-1_cloud-download-93"></i>
<p>Upgrade to PRO</p>
</a>
</li>
</ul>
</div>
</div>
<div class="container">
#yield('signup')
</div>
This is the Bootstrap form, I'm copying from Bootstrap site and injecting into welcome.blade.php.
#section('signup')
<div class="row">
<div class="col-md-6 col-md-offset-3">
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
#endsection
The Problem is the form is going behind the sidebar, although I've used .col-md-6 and .col-md-offset-3 to center it to the page.
why this behavior ?
Please help , thanks in advance

try this one
HTML
#section('signup')
<div class="row">
<div class="col-md-6 col-md-offset-3 mx-auto">
<form>
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
<small id="emailHelp" class="form-text text-muted">We'll never share your email with anyone else.</small>
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="exampleCheck1">
<label class="form-check-label" for="exampleCheck1">Check me out</label>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
</div>
#endsection

Related

Laravel display image uploaded in view from database

I want to display images uploaded in view file to the database using laravel...the image are not loaded...
below is my view file where i want to display my image
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
#foreach($infor as $inform)
<div class="card mb-3">
<img src="{{ asset('storage/uploads/'.$inform->imogi) }}" style="max-width:20%;" alt="Wild Landscape"/>
<div class="card-body">
<div style="text-align: right;">
<small style="color:#3490dc;">{{$inform->organazation}}</small> <small><i class="fa fa-calendar" style="color:#3490dc" aria-hidden="true"></i> {{ $inform->created_at->format('d/m/Y') }}</small>
</div>
<h5 class="card-title"><i class="fa fa-user-circle-o" style="color:#3490dc" aria-hidden="true"></i> {{$inform->name}}</h5>
<!--LIVEWIRE online status-->
<div wire:key="UNIQUE_ID">
#if($inform->isOnline())
<small style="color:#3490dc;"> operative </small>
#else
<small style="color:#3490dc;"> detached</small>
#endif
</div>
<small><i class="fa fa-map-marker" style="color:#3490dc" aria-hidden="true"></i> {{$inform->location}}</small>
<hr/>
<h6 class="card-title"><b>{{$inform->title}}</b></h6>
<p class="card-text">
{{$inform->message}}
</p>
<small><small style="color:#3490dc;"><u><b>Qualifications:</b></u></small> {{$inform->qualifications}}</small>
<div style="text-align: right;">
<small><i class="fa fa-phone" style="color:#3490dc" aria-hidden="true"></i> {{$inform->contact}}</small>
</div>
</div>
</div>
<br/>
#endforeach
</div>
</div>
</div>
#include('footer')
#endsection
below is my upload controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class FileUploadController extends Controller
{
public function fileUpload()
{
return view('fileUpload');
}
//
public function fileUploadPost(Request $request)
{
$request->validate([
'file' => 'required|mimes:pdf,xlx,csv|max:2048',
]);
$fileName = time().'.'.$request->file->extension();
$request->file->move(public_path('uploads'), $fileName);
return back()
->with('success','You have successfully upload file.')
->with('file',$fileName);
}
}
Here is my storage path in filesystems.php
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
And below is the blade view where the image is being uploaded
#extends('layouts.app')
#section('content')
<div class="container">
<div class="row justify-content-center">
<div class="col-md-8">
<form action="message" method="POST">
#csrf
<div class="form-group">
<label for="exampleFormControlInput1"><i style="color:#3490dc" class="fa fa-user" style="font-size:24px"></i> Name</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name="name" value="{{ auth()->user()->name }}" readonly>
</div>
<div class="form-group">
<label for="exampleFormControlInput1"><i style="color:#3490dc" class="fa fa-building-o" style="font-size:24px"></i> Organazation</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name="organazation">
<span style="color: red;"><small>#error('organazation'){{$message}}#enderror</small></span>
<small>Type your organazation or state whether individual</small>
</div>
<div class="form-group">
<label for="exampleFormControlInput1"><i style="color:#3490dc" class="fa fa-map-marker" style="font-size:24px"></i> Location</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name="location">
<span style="color: red;"><small>#error('location'){{$message}}#enderror</small></span>
<small>Type your location</small>
</div>
<div class="form-group">
<label for="exampleFormControlInput1"><i style="color:#3490dc" class="fa fa-pencil" style="font-size:24px"></i> Job title</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name="title">
<span style="color: red;"><small>#error('title'){{$message}}#enderror</small></span>
<small>Enter the title for the job</small>
</div>
<div class="form-group">
<label for="exampleFormControlTextarea1"><i style="color:#3490dc" class="fa fa-pencil" style="font-size:24px"></i> Job description</label>
<textarea type="text" class="form-control" id="exampleFormControlTextarea1" rows="3" name="message"></textarea>
<span style="color: red;"><small>#error('message'){{$message}}#enderror</small></span>
<small>Describe the type of job being offered</small>
</div>
<div class="form-group">
<label for="exampleFormControlInput1"><i style="color:#3490dc" class="fa fa-file" style="font-size:24px"></i> Qualifications</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name="qualifications">
<span style="color: red;"><small>#error('qualifications'){{$message}}#enderror</small></span>
<small>Enter the qualifications and experience required</small>
</div>
<div class="form-group">
<label for="exampleFormControlInput1"><i style="color:#3490dc" class="fa fa-phone" style="font-size:24px"></i> Contacts</label>
<input type="text" class="form-control" id="exampleFormControlInput1" name="contact">
<span style="color: red;"><small>#error('contact'){{$message}}#enderror</small></span>
<small>Enter phone contacts</small>
</div>
<form action="{{ route('file.upload.post') }}" method="POST" enctype="multipart/form-data">
#csrf
<div class="row">
<div class="col-md-6">
<input type="file" class="form-control" name="imogi">
</div>
</div>
<span style="color: red;"><small>#error('imogi'){{$message}}#enderror</small></span>
<small>Select business logo if any or implicating image</small>
<br/>
<br/>
<button type="submit" class="btn btn-primary">Post</button>
</form>
<br/>
</form>
</div>
</div>
</div>
#include('footer')
#endsection
I can display any image in my view except the one i uploaded...i dont know where am getting this wrong...i will appreciate any kind of help
Thank You!
you should try:
{{ URL::asset('storage/uploads/'.$inform->imogi) }}

I have both Login And Register form Inside a tab content. So the Problem Is That I can set action for any one form. How can I sove it

<form id=reg_form action="includes/data.inc.php" method="POST">
<div class="login-modal-right">
<!-- Login Form -->
<div class="tab-content">
<div class="tab-pane active" id="login" role="tabpanel">
<h5 class="heading-design-h5">Login to your account</h5>
<fieldset class="form-group">
<label>Enter Email/Mobile number</label>
<input type="text" name="email_num" class="form-control" placeholder="123 456 7890" required>
</fieldset>
<fieldset class="form-group">
<label>Enter Password</label>
<input type="password" name="password" class="form-control" placeholder="********" required>
</fieldset>
<fieldset class="form-group">
<button type="submit" name="login-submit" class="btn btn-lg btn-secondary btn-block">Enter My Account</button>
</fieldset>
</div>
<!-- Register Form -->
<div class="tab-pane" id="register" role="tabpanel">
<h5 class="heading-design-h5">Register Now!</h5>
<fieldset class="form-group">
<label for="reg-name">Full Name</label>
<input type="text" name="fullname" id="reg-name" class="form-control" placeholder="Your Full Name" required>
</fieldset>
<p id="namechk"></p>
<fieldset class="form-group">
<label for="reg-email">Enter Email</label>
<input type="email" name="email" id="reg-email" class="form-control" placeholder="example#gmail.com" required>
</fieldset>
<p id="emailchk"></p>
<fieldset class="form-group">
<label for="reg-num">Enter Mobile Number</label>
<input type="text" name="number" id="reg-num" class="form-control" placeholder="123 456 7890" required>
</fieldset>
<p id="numchk"></p>
<fieldset class="form-group">
<label for="reg-pass">Enter Password</label>
<input type="password" name="pass" id="reg-pass" class="form-control" placeholder="********" required>
</fieldset>
<p id="passchk"></p>
<!-- <div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input">
<label class="custom-control-label" for="customCheck2">I Agree with Term and Conditions</label>
</div> -->
<fieldset class="form-group">
<input type="submit" id="reg-sub" value="Create Your Account" class="btn btn-lg btn-secondary btn-block" role="button">
</fieldset>
</div>
</div>
<div class="clearfix"></div>
<div class="text-center login-footer-tab">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#login" role="tab"><i class="mdi mdi-lock"></i> LOGIN</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#register" role="tab"><i class="mdi mdi-pencil"></i> REGISTER</a>
</li>
</ul>
</div>
<div class="clearfix"></div>
</div>
</form>
The Problem Is I can only set an action for any one form. Let say if I set the action for the registration form then where or how I can set the action for the login form. I have even tried separating them, but it actually breaks the design. If anyone can resolve it with design (Just in case if I did any error) then you are most welcome. Or if there's any way I can set action for both of them separately. I do tried manipulating both of them from the same page(action page) but again it doesn't work.
Put separate form tag for each tab
<div class="tab-pane active" id="login" role="tabpanel">
<form>
</form>
</div>
<div class="tab-pane" id="register" role="tabpanel">
<form>
</form>
</div>

Php link to contact form (DATABASEPHP)

</div>
<div class="row block-9">
<div class="col-md-6 order-md-last d-flex">
<form action="#" class="bg-white p-5 contact-form">
<form class="=contact-form" action="contact.php" method="post"
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Email">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Subject">
</div>
<div class="form-group">
<textarea name="" id="" cols="30" rows="7" class="form-control" placeholder="Message"></textarea>
</div>
<div class="form-group">
<input type="submit" value="Send Message" class="btn btn-primary py-3 px-5">
</div>
</form>
</div>
<div class="col-md-6 d-flex">
<iframe src="https://www.google.com/maps/embed?pb=!1m14!1m8!1m3!1d14884.226370030301!2d79.103842!3d21.150146!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x0%3A0x5106808b025223d!2sRajshri%20Traders!5e0!3m2!1sen!2sid!4v1566792666441!5m2!1sen!2sid" width="600" height="450" frameborder="0" style="border:0;" allowfullscreen=""></iframe>
</div>
</div>
</div>
</section>
<footer class="ftco-footer ftco-section">
<div class="container">
<div class="row">
<div class="mouse">
<a href="#" class="mouse-icon">
<div class="mouse-wheel"><span class="ion-ios-arrow-up"></span></div>
</a>
</div>
</div>
<div class="row mb-5">
<div class="col-md">
<div class="ftco-footer-widget mb-4">
<h2 class="ftco-heading-2">Rajshri Traders</h2>
<p>We provide the best Cctvs.</p>
<ul class="ftco-footer-social list-unstyled float-md-left float-lft mt-5">
<li class="ftco-animate"><span class="icon-twitter"></span></li>
<li class="ftco-animate"><span class="icon-facebook"></span></li>
<li class="ftco-animate"><span class="icon-instagram"></span></li>
</ul>
</div>
</div>
<div class="col-md">
<div class="ftco-footer-widget mb-4 ml-md-5">
<h2 class="ftco-heading-2">Menu</h2>
<ul class="list-unstyled">
<li>Shop</li>
<li>About</li>
<li> </li>
<li> </li>
</ul>
</div>
</div>
<div class="col-md-4">
<div class="ftco-footer-widget mb-4">
<h2 class="ftco-heading-2"> </h2>
<div class="d-flex">
<ul class="list-unstyled mr-l-5 pr-l-3 mr-4">
<li> </li>
<li> </li>
<li> </li>
<li> </li>
</ul>
<ul class="list-unstyled">
<li> </li>
<li> </li>
</ul>
</div>
</div>
</div>
<div class="col-md">
<div class="ftco-footer-widget mb-4">
<h2 class="ftco-heading-2">Have a Questions?</h2>
<div class="block-23 mb-3">
<ul>
<li><span class="icon icon-map-marker"></span><span class="text">Plot No 1, Nike buildings, Fawara Chouk,Gandhibag, Nagpur, Maharashtra 440032, India</span></li>
<li><span class="icon icon-envelope"></span><span class="text"> rajshirtraders#gmail.com</span></li>
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
</div>
</div>
</div>
</footer>
<!-- loader -->
<div id="ftco-loader" class="show fullscreen"><svg class="circular" width="48px" height="48px"><circle class="path-bg" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke="#eeeeee"/><circle class="path" cx="24" cy="24" r="22" fill="none" stroke-width="4" stroke-miterlimit="10" stroke="#F96D00"/></svg></div>
i am trying to link my php to the contact form but facing some issues please help
the format of the cotact us is also a bit messed up after sevral attempts to fix it i coudnt
i am using my sql for the php
i have the php file but dont know where to attach it in the contact us page (html)
i have tried a few solutions looking at youtube
but nothing works
please help
That's how work php/html:
HTML
<form class="=contact-form" action="contact.php" method="post">
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Name" name="name">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Your Email" name="email">
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Subject" name="subject">
</div>
<div class="form-group">
<textarea name="mess" id="" cols="30" rows="7" class="form-control" placeholder="Message" ></textarea>
</div>
<div class="form-group">
<input type="submit" value="Send Message" class="btn btn-primary py-3 px-5">
</div>
</form>
Here user will input data and sent to contact.php, i add name="" and we will create a variable with that.
PHP
// ALL VARIABLE FROM FORM
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
//NOW YOU CAN SENT EMAIL
$to = "somebody#example.com";
$headers = "From:".$email . "\r\n" .
"CC: somebodyelse#example.com";
mail($to,$subject,$message,$headers);

Submitting form without changing tab panes using only PHP

I'm using Bootstrap 4 and I've created a two pane form; registration and sign in forms.
I know using AJAX is more suitable for such situations that it won't make the page refresh, however, I'm asking if there is any way of achieving that the page refreshes and previews the same pane using only PHP.
Using PHP in the code. Is there any way that when I submit the form when in registration pane (the one on the right hand side), the page refreshes and stays in the same pane.
<!-- Tabs -->
<nav class="register-nav">
<div class="nav nav-tabs nav-justified" id="nav-tab" role="tablist">
<a class="nav-item nav-link active" id="nav-signin-tab" data-toggle="tab" href="#nav-signin" role="tab">Sign in</a>
<a class="nav-item nav-link" id="nav-signup-tab" data-toggle="tab" href="#nav-signup" role="tab">Create New Account</a>
</div>
</nav>
<!-- Content of Tabs -->
<div class="tab-content" id="nav-tabContent">
<!-- Sign in Tab Pane -->
<div class="tab-pane fade show active" id="nav-signin" role="tabpanel">
<form action="" method="POST">
<div class="form-group">
<div class="row">
<div class="col-sm-6">
<a class="btn btn-block btn-social btn-facebook">
<span class="fa fa-facebook"></span> Sign in with Facebook
</a>
</div>
<div class="col-sm-6">
<a class="btn btn-block btn-social btn-google">
<span class="fa fa-google"></span> Sign in with Google
</a>
</div>
</div>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Username / Email Address">
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Password">
</div>
<div class="form-group text-center mt-5">
<input type="submit" class="btn btn-outline-info" value="Sign in">
</div>
</form>
</div>
<!-- Sign Up Tab Pane -->
<div class="tab-pane fade" id="nav-signup" role="tabpanel">
<form action="" method="POST">
<div class="form-group">
<input type="text" class="form-control" placeholder="First name" required>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Last name" required>
</div>
<div class="form-group">
<input type="text" class="form-control" placeholder="Username" required>
</div>
<div class="form-group">
<input type="email" class="form-control" placeholder="Email Address" required>
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Password" required>
</div>
<div class="form-group">
<input type="password" class="form-control" placeholder="Confirm Password" required>
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" required>
<label class="form-check-label">By registering to
velocity, you agree to its
terms and conditions
</label>
</div>
<div class="form-group text-center mt-5">
<input id="register-btn" type="submit" class="btn btn-outline-success" value="Register" disabled>
</div>
</form>
</div>
</div>
It is really not a PHP thing, but you could use PHP to manipulate the HTML to move the active class to the other tab.
<?php
$signinTabIsActive = "active";
$signupTabIsActive = "";
if(isset($_POST['firstname'])){
$signinTabIsActive = "";
$signupTabIsActive = "active";
?>
<!-- Tabs -->
<nav class="register-nav">
<div class="nav nav-tabs nav-justified" id="nav-tab" role="tablist">
<a class="nav-item nav-link <?= $signinTabIsActive; ?>" id="nav-signin-tab" data-toggle="tab" href="#nav-signin" role="tab">Sign in</a>
<a class="nav-item nav-link <?= $signupTabIsActive; ?>" id="nav-signup-tab" data-toggle="tab" href="#nav-signup" role="tab">Create New Account</a>
</div>
</nav>
Add a hidden input with a value that indicaties which pane should open. When generating the form (with Php) decide which pane gets an active class based on this value in the $_POST array

MySQL Update using PHP: You have an error in your SQL syntax [closed]

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>&nbsp</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.

Categories