How to display username as a value in PHP - php

I want to know how to display a user's username inside a textbox. I'm doing this because when they edit their settings and update them, it updates their email etc to blank fields in the database:
Here's the code i'd like to change
<input type="text" name="name" class="form-control" id="name" class="required" value="<? echo $row_settings['full_name']; ?>" />
I'd like to make the `value = $row_settings['full_name'];'
How can i do this?
ALL CODE:
<?php
/********************** MYSETTINGS.PHP**************************
This updates user settings and password
************************************************************/
include 'dbc.php';
page_protect();
$err = array();
$msg = array();
if($_POST['doUpdate'] == 'Update')
{
$rs_pwd = mysql_query("select pwd from users where id='$_SESSION[user_id]'");
list($old) = mysql_fetch_row($rs_pwd);
$old_salt = substr($old,0,9);
//check for old password in md5 format
if($old === PwdHash($_POST['pwd_old'],$old_salt))
{
$newsha1 = PwdHash($_POST['pwd_new']);
mysql_query("update users set pwd='$newsha1' where id='$_SESSION[user_id]'");
$msg[] = "Your new password is updated";
//header("Location: mysettings.php?msg=Your new password is updated");
} else
{
$err[] = "Your old password is invalid";
//header("Location: mysettings.php?msg=Your old password is invalid");
}
}
if($_POST['doSave'] == 'Save')
{
// Filter POST data for harmful code (sanitize)
foreach($_POST as $key => $value) {
$data[$key] = filter($value);
}
mysql_query("UPDATE users SET
`full_name` = '$data[name]',
`address` = '$data[address]',
`tel` = '$data[tel]',
`user_email` = '$data[user_email]',
`user_name` = '$data[user]',
`fax` = '$data[fax]',
`country` = '$data[country]',
`website` = '$data[web]'
WHERE id='$_SESSION[user_id]'
") or die(mysql_error());
//header("Location: mysettings.php?msg=Profile Sucessfully saved");
$msg[] = "Profile Sucessfully saved";
}
$rs_settings = mysql_query("select * from users where id='$_SESSION[user_id]'");
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="../../assets/ico/favicon.ico">
<script language="JavaScript" type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script language="JavaScript" type="text/javascript" src="js/jquery.validate.js"></script>
<script>
$(document).ready(function(){
$("#myform").validate();
$("#pform").validate();
});
</script>
<title>The Infibox - Edit Profile</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/indexSettings.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<?php if (isset($_SESSION['user_id'])) {?>
<a class="navbar-brand" href="#">Infibox</a>
<a class="navbar-brand">|</a>
<a class="navbar-brand" href="/recruitment">My Account</a>
<a class="navbar-brand" href="#">Settings</a>
<a class="navbar-brand" href="#">Logout</a>
<?php }
?>
<?php
if (checkAdmin()) {
/*******************************END**************************/
?>
<a class="navbar-brand" href="admin.php">Admin CP </a>
<?php } ?>
</div>
<div class="navbar-collapse collapse">
<form class="navbar-form navbar-right" role="form">
<div class="form-group">
<input type="text" placeholder="Email" class="form-control">
</div>
<div class="form-group">
<input type="password" placeholder="Password" class="form-control">
</div>
<button type="submit" class="btn btn-success">Sign in</button>
</form>
</div><!--/.navbar-collapse -->
</div>
</div>
<!-- Main jumbotron for a primary marketing message or call to action -->
<p>
<?php
if(!empty($err)) {
echo "<div class=\"msg\">";
foreach ($err as $e) {
echo "* Error - $e <br>";
}
echo "</div>";
}
if(!empty($msg)) {
echo "<div class=\"msg\">" . $msg[0] . "</div>";
}
?>
</p>
<!-- Show their details inside the correct box. E.g. their first name they registered with will be shown inside the "First Name" box. Does not occur with passwords. -->
<center>
<div class="wrapper">
<h2 class="title">Edit Profile</h2>
<?php while ($row_settings = mysql_fetch_array($rs_settings)) ?>
<form action="mysettings1.php" method="post" name="myform" id="myform">
<div class="input-group" id="fname">
<span class="input-group-addon">Name</span>
<input type="text" name="name" class="form-control" id="name" class="required" value="<? echo $row_settings['full_name']; ?>" />
</div>
<div class="input-group">
<span class="input-group-addon">Customer ID</span>
<input type="text" name="user" class="form-control" maxlength="6" id="web2" value="<? echo $row_settings['user_name']; ?>">
</div>
<div class="input-group">
<span class="input-group-addon">Email</span>
<input type="text" class="form-control" name="user_email" id="web3" value="<? echo $row_settings['user_email']; ?>">
</div>
<div class="input-group">
<span class="input-group-addon">Add Paypal Email</span>
<input type="text" class="form-control" name="tel" id="tel" class="required" value="<? echo $row_settings['tel']; ?>">
</div>
<div class="btn-group">
<input name="doSave" type="submit" id="doSave" value="Save" class="btn btn-success">
</div>
<hr class="hr" />
<!-- When Changing Password Old Password Must Be Entered + Correct-->
<h2 class="title2">Change Password</h2>
<div class="input-group">
<span class="input-group-addon">Old Password</span>
<input type="password" class="form-control" name="pwd_old" class="required password" id="pwd_old" >
</div>
<div class="input-group">
<span class="input-group-addon">New Password</span>
<input type="password" class="form-control" name="pwd_new" class="required password" id="pwd_new" >
</div>
<div class="btn-group">
<input name="doUpdate" type="submit" id="doUpdate" value="Update" class="btn btn-success">
</div>
</div>
</center>
</form>
<!-- ##################################################################################### -->
<!-- ##################################################################################### -->
</div>
</center>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>

You do not need a while loop:
Change
<?php while ($row_settings = mysql_fetch_array($rs_settings)) ?>
with
<?php $row_settings = mysql_fetch_array($rs_settings); ?>

Related

How to save the updated total of stocks after it minus ? [php-json]

How to save the updated total of stocks after it minus ? [php-json]
i need to get the current stocks and minus it to the quantity bought by the customer. and it will post to the order.json and get the total payment and
i need to update the food.json for the stocks and to put the orderlist on order.json
This is the code to get the value of buy product but the quantity entered by the customer do not minus on the stocks and do not get the total. I think there is wrong in my codes. Please Help me. Im just a beginner to json
<?php
if (isset($_GET["id"])) {
$id = (int) $_GET["id"];
$getfile = file_get_contents('food.json');
$jsonfile = json_decode($getfile, true);
$jsonfile = $jsonfile["records"];
$jsonfile = $jsonfile[$id];
}
if (isset($_POST["id"])) {
$id = (int) $_POST["id"];
$getfile = file_get_contents('food.json');
$all = json_decode($getfile, true);
$jsonfile = $all["records"];
$jsonfile = $jsonfile[$id];
$quan = $_POST['quan'];
$stocks = $stocks - $quan; // on minusing the stocks :<
$post["pname"] = isset($_POST["pname"]) ? $_POST["pname"] : "";
$post["price"] = isset($_POST["price"]) ? $_POST["price"] : "";
$post["stocks"] = isset($_POST["stocks"]) ? $_POST["stocks"] : "";
// $post["quan"] = isset($_POST["quan"]) ? $_POST["quan"] : "";
if ($jsonfile) {
unset($all["records"][$id]);
$all["records"][$id] = $post;
$all["records"] = array_values($all["records"]);
file_put_contents("food.json", json_encode($all));
}
header("Location:index_crudjson.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="tutorial-boostrap-merubaha-warna">
<meta name="author" content="ilmu-detil.blogspot.com">
<title></title>
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<style type="text/css">
.navbar-default {
background-color: #3b5998;
font-size:18px;
color:#ffffff;
}
</style>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<h4>JSON Bake Shop</h4>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
</div>
</div>
</nav>
<!-- /.navbar -->
<div class="container">
<div class="row">
<div class="row">
<h3>Buy a Product</h3>
</div>
<?php if (isset($_GET["id"])): ?>
<form method="POST" action="buy.php">
<div class="col-md-6">
<input type="hidden" value="<?php echo $id ?>" name="id"/>
<div class="form-group">
<label for="inputFName">Product Name</label>
<input type="text" class="form-control" required="required" id="inputFName" value="<?php echo $jsonfile["pname"] ?>" name="pname" placeholder="Product Name">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="inputLName">Price</label>
<input type="number" class="form-control" required="required" id="inputLName" value="<?php echo $jsonfile["price"] ?>" name="price" placeholder="Price">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="inputAge">Stocks</label>
<input type="number" required="required" class="form-control" id="inputAge" value="<?php echo $jsonfile["stocks"] ?>"
name="stocks" placeholder="Stocks">
<span class="help-block"></span>
</div>
<div class="form-group">
<label for="inputAge">Quantity</label>
<input type="number" required="required" class="form-control" id="inputAge" value="<?php echo $jsonfile["quan"] ?>"
name="quan" placeholder="Quantity">
<span class="help-block"></span>
</div>
<div class="form-actions">
<button type="submit" class="btn btn-warning">Buy</button>
<a class="btn btn btn-default" href="index_crudjson.php">Back</a>
</div>
</div>
</form>
<?php endif; ?>
</div> <!-- /row -->
</div> <!-- /container -->
</body>
</html>
This is the attached sample of order.json, food.json, index and buy.phpsample picturefood.json
You have a simple error on you $post assignment
$post["stocks"] = $stocks;
I could not understand clearly your logic, but $stocks is not used at all, and the real stocks value should not be in $_POST.

Form not submitting when I load it with ng-view

I have configured the angularjs file so that the view is loaded when i press on the 'add item' button in the navigation bar, however when I try submitting the form nothing happens. But if I load the php file separately it works without any problems and adds the data to my json file.
MY HTML
<head>
<title></title>
<link href="almstyle.css" type="text/css" rel="stylesheet">
<link href="Framework/css/mycss.css" type="text/css" rel="stylesheet">
<link href="Framework/css/bootstrap.min.css" type="text/css" rel="stylesheet">
<script src="Framework/js/jquery-3.1.1.min.js"></script>
<script src="Framework/js/bootstrap.min.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div class="container">
<!-- Start of header -->
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h4 id="banner">LOGO</h4>
</div>
</div>
<!-- End of header -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header navbar-left">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home <span class="sr-only">(current)</span></li>
<li>Hair</li>
<li>Shop</li>
<li>News</li>
<li>Add Item</li>
<li class="dropdown">
LifeStyle <span class="caret"></span>
<ul class="dropdown-menu">
<li>Food</li>
<li>Passion</li>
<li>Travel</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div data-ng-view></div>
</div>
<script type="text/javascript" src="https://code.angularjs.org/1.6.5/angular.js"></script>
<script type="text/javascript" src="../node_modules/angular-route/angular-route.js"></script>
<script src="app.js"></script>
<script src="home/home.js"></script>
<script src="addItem/addItem.js"></script>
</body>
</html>
My Php Template
<?php
$message = '';
$error = '';
if(isset($_POST["submit"]))
{
if(empty($_POST["item"]))
{
$error = "<label class='text-danger'>Enter Item Name</label>";
}
else if(empty($_POST["id"]))
{
$error = "<label class='text-danger'>Enter Item Id</label>";
}
else if(empty($_POST["size"]))
{
$error = "<label class='text-danger'>Enter a size for your item</label>";
}
else if(empty($_POST["price"]))
{
$error = "<label class='text-danger'>Enter a suitable price for the item</label>";
}
else
{
if(file_exists('items.json'))
{
$current_data = file_get_contents('items.json');
$array_data = json_decode($current_data, true);
$extra = array(
'item' => $_POST['item'],
'id' => $_POST["id"],
'selected' => $_POST["selected"],
'prices' => [[
'size' => $_POST["size"],
'price' => $_POST["price"]
]]
);
$array_data[] = $extra;
$final_data = json_encode($array_data);
if(file_put_contents('items.json', $final_data))
{
$message = "<label class='text-success'>The Item has been added successfully</p>";
}
}
else
{
$error = 'JSON File does not exist';
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add items</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<br />
<div class="container" style="width:500px;">
<h3 align="">Add items</h3><br />
<form method="post">
<?php
if(isset($error))
{
echo $error;
}
?>
<br />
<label>Item Name</label>
<input type="text" name="item" class="form-control" /><br />
<label>Item Id</label>
<input type="text" name="id" class="form-control" />
<input type="hidden" name="selected" value="0" class="form-control" hidden="hidden"/><br />
<div class="panel panel-default">
<div class="panel panel-heading">
Prices
</div>
<div class="panel panel-body">
<label>Size</label>
<input type="text" name="size" class="form-control" />
<label>Price</label>
<input type="number" name="price" class="form-control" />
</div>
<br />
</div>
<input type="submit" name="submit" value="Add Item" class="btn btn-info" /><br />
<?php
if(isset($message))
{
echo $message;
}
?>
</form>
</div>
<br />
</body>
This is what it should look like after submitting
few mistakes here ,
I don't see a form with the action attribute set as path to php resource.
For a form to submit, you should have a button of type submit. Some thing like this.
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
And your PHP file can be
<html>
<body>
Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>
</body>
</html>
I hope this helps you to resolve this
For a form to work "the angular way", you need a couple to specify a couple of extra bits.
You'll firstly need the name the ng-app after the opening html tag to indicate that the that block of code will be 'watched' by an angular module (which you will specify also in the code).
You'll also need to add an ng-controller tag to the form which you will name and then refer to in your javascript
In the angular form , add an ng-click to send it to submit the form if the form validates successfully: ng-click=”formsubmit(userForm.$valid)”
Here is some sample code:
<!DOCTYPE html>
<html ng-app="formExample">
<head>
<title>simple form with AngualrJS</title>
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css" />
<script src="js/angular.js" ></script>
<script src="js/formjs.js"></script>
</head>
<body>
<div ng-controller="formCtrl">
<form name="userForm" class="well form-search" >
<input type="text" ng-model="name" class="input-medium search-query" placeholder="Name" required >
<input type="email" ng-model="email" class="input-medium search-query" placeholder="Email" required >
<input type="text" ng-model="message" class="input-medium search-query" placeholder="Message" required >
<button type="submit" class="btn" ng-click="formsubmit(userForm.$valid)" ng-disabled="userForm.$invalid">Submit </button>
</form>
<pre ng-model="result">
{{result}}
</pre>
</div>
</body>
</html>
JS:
<pre class="lang:default decode:true " title="formjs.js" >
/**
* #filesource : formjs.js
* #author : Shabeeb <mail#shabeebk.com>
* #abstract : controller fo HTML page
* #package sample file
* #copyright (c) 2014, Shabeeb
* shabeebk.com/blog
*
* */
var app = angular.module('formExample', []);
app.controller("formCtrl", ['$scope', '$http', function($scope, $http) {
$scope.url = 'submit.php';
$scope.formsubmit = function(isValid) {
if (isValid) {
$http.post($scope.url, {"name": $scope.name, "email": $scope.email, "message": $scope.message}).
success(function(data, status) {
console.log(data);
$scope.status = status;
$scope.data = data;
$scope.result = data;
})
}else{
alert('Form is not valid');
}
}
}]);</pre>
submit:
<?php
/**
* #filesource : submit.php
* #author : Shabeeb <mail#shabeeb.com>
* #abstract : simple submission php form
* #package sample file
* #copyright (c) 2014, Shabeeb
*
*
* */
$post_date = file_get_contents("php://input");
$data = json_decode($post_date);
//saving to database
//save query
//now i am just printing the values
echo "Name : ".$data->name."n";
echo "Email : ".$data->email."n";
echo "Message : ".$data->message."n";
?>

Blank display when I click submit button from the form

I create form which contain text fields and upload file(register.php), and I want to send data to sendData.php and redirect to payment.php in order user to make payment for document review. I don't know where am wrong from sendData.php, I try to submit data from register.php to sendData and output is blank no error found, I try to check mysql error also no error found.
Page contain Form data
<?php
$errors = "";
if(isset($_GET["error"])){
if($_GET["error"] === "pwd"){
$errors = '<div class="alert alert-danger col-md-3><span class="glyphicon glyphiocn-remove-circle"></span> Passowrd dismatch, please try again</div>';
}
if($_GET["error"] === "undefined"){
$errors = '<div class="alert alert-danger col-md-3><span class="glyphicon glyphiocn-remove-circle"></span> File format dismatch, please try again</div>';
}
if($_GET["error"] === "found_file"){
$errors = '<div class="alert alert-danger col-md-3><span class="glyphicon glyphiocn-remove-circle"></span> Document found error, please try again</div>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>CentralAcademy: Register</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<link href="css/bootstrap-theme.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="stylesheet" href="css/jumbtron.css">
<link href="css/custom-file.css" rel="stylesheet">
<style type="text/css">
body{ padding-top: 80px; }
</style>
</head>
<body>
<?php require_once("includes/header.php"); ?>
<div class="container">
<div class="row">
<div class="col-lg-3 breadcrumb">
<h3 class="page-header">Payment</h3>
<p><img src="images/images.png" class="img img-responsive" width="70" height="50" style="display: block; float: left; padding-right:10px;"/> (+255)755-555-555</p><br>
<p><img src="images/airtelM.fw.png" class="img img-responsive" width="70" height="50" style="display: block; float: left; padding-right:10px;"/> (+255)685-555-555</p><br>
<p><img src="images/tigopesa.png" class="img img-responsive" width="70" height="50" style="display: block; float: left; padding-right:10px;"/> (+255)655-555-555</p><br>
</div>
<div class="col-lg-2"></div>
<div class="col-lg-7 breadcrumb">
<?php print $errors; ?>
<h3 class="page-header">Request for Document Review</h3>
<h5><font color="#FF0000">***</font> Please fill all fields required</h5><br>
<form action="sendData.php" method="post" enctype="multipart/form-data" class="form-horizontal">
<div class="form-group">
<div class="col-md-6">
<input name="fname" type="text" placeholder="Enter your FirstName" value="<?php echo isset($_POST['fname']) ? $_POST['fname'] : '' ?>" class="form-control" required id="fname">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="sname" type="text" class="form-control" value="<?php echo isset($_POST['sname']) ? $_POST['sname'] : '' ?>" placeholder="Enter your LastName" required id="sname">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="gender" type="radio" class="radio-inline" value="F" checked="CHECKED" required/>Female <input type="radio" name="gender" class="radio-inline" value="M" required/>Male</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="email" type="text" class="form-control" value="<?php echo isset($_POST['email']) ? $_POST['email'] : '' ?>" placeholder="Enter your Email Address" required id="email">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="phone" type="text" class="form-control" placeholder="Enter your Phone Number" value="<?php echo isset($_POST['phone']) ? $_POST['phone'] : '' ?>" maxlength="13" required id="phone" pattern="[\+]\d{3}\d{3}\d{6}">
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input type="radio" name="edlevel" value="bachelor" class="radio-inline" checked="CHECKED" required/>Bachelor
<input type="radio" name="edlevel" value="Post Graduate" class="radio-inline" />Post Grad
<input name="edlevel" type="radio" value="Masters" class="radio-inline" />Masters
<input name="edlevel" type="radio" value="PhD" class="radio-inline" />PhD
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="affi" type="text" class="form-control" value="<?php echo isset($_POST['affi']) ? $_POST['affi'] : '' ?>" placeholder="Enter organisation/College/University" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="title" type="text" class="form-control" value="<?php echo isset($_POST['title']) ? $_POST['title'] : '' ?>" placeholder="Enter your document title" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6 fileUpload">
<input type="file" name="files" id="file"/>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="password" type="password" class="form-control" placeholder="Choose Your Password" required>
</div>
</div>
<div class="form-group">
<div class="col-md-6">
<input name="password2" type="password" class="form-control" placeholder="Confirm Your Password" required>
</div>
</div>
<br>
<div class="form-group">
<div class="col-md-6">
<button name="Register" type="submit" class="btn btn-info"><span class="glyphicon glyphicon-user"></span> Register Now</button><br><br>
<p>If you are already registered please click here</p>
</div>
</div>
</form>
</div>
</div>
</div>
<div class="container marketing">
<!-- START THE FEATURETTES -->
<?php require_once("includes/footer.php"); ?>
</div><!-- /.container -->
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
//sendData.php
<?php
if(isset($_FILES['files']) && $_POST["password"] === $_POST["password2"]){
session_start();
require_once("includes/dbconnect.php");
$fname = $_POST["fname"];
$sname = $_POST["sname"];
$email = $_POST["email"];
$phone = $_POST["phone"];
$title = $_POST["title"];
$password = $_POST["password"];
$gender = $_POST["gender"];
$edlevel = $_POST["edlevel"];
$affi = $_POST["affi"];
//Keep all author data to session variable
$_SESSION["fname"] = $fname;
$_SESSION["sname"] = $sname;
$_SESSION["email"] = $email;
$_SESSION["phone"] = $email;
$_SESSION["passwprd"] = $password;
$_SESSION["gender"] = $gender;
$_SESSION["edlevel"] = $edlevel;
$_SESSION["affi"] = $affi;
$errors= array();
$extensions = array("docx");
$file_name = rand(1000,100000)."-".$_FILES['files']['name'];
$file_size = $_FILES['files']['size'];
$file_tmp = $_FILES['files']['tmp_name'];
$file_type = $_FILES['files']['type'];
$file_ext = strtolower(substr($_FILES['files']['name'],strrpos($_FILES['files']['name'],'.')+1));
if(in_array($file_ext,$extensions ) === true && $file_size < 2097152){
$result = $connect->query("INSERT INTO temp VALUES(NULL,'$title',$email','$file_name',now())");
if($result){
$desired_dir="AuthorReport";
if(empty($errors)===true){
if(is_dir($desired_dir)===false){
mkdir("$desired_dir", 0700); // Create directory if it does not exist
}
if(is_dir("$desired_dir/".$file_name)==false){
move_uploaded_file($file_tmp,"$desired_dir/".$file_name);
}else{ // rename the file if another one exist
$new_dir="$desired_dir/".$file_name.time();
rename($file_tmp,$new_dir) ;
}
header("location: payment.php");
exit();
}
else{ header("location:register.php?error=found_file"); exit(); }
}
}
else{ header("location:register.php?error=undefined"); exit(); }
}
else{ header("location:register.php?error=pwd"); exit(); }
?>
$email doesn't have start quote
$result = $connect->query("INSERT INTO temp VALUES(NULL,'$title',$email','$file_name',now())");
that's why you have the error.
and to be sure where are you entering these values exactly where you want use add also the column names in INSERT statement
$result = $connect->query("INSERT INTO temp
(column_title, column_email, column_filename, thedate)
VALUES
('$title','$email','$file_name',NOW() )" );

PHP doesn't post form values after migrating login page [duplicate]

This question already has answers here:
"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP
(29 answers)
Closed 6 years ago.
I've decided to change the design on our login page, however there is a issue.
In the new login page nothing pass after I press the login button however on the old page it still works as before.
Old page:
<?php
require_once('./files/functions.php');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="Social Panel">
<link rel="shortcut icon" href="images/favicon.png">
<title><?php echo($WebsiteName); ?> | Sign In</title>
<link href="bs3/css/bootstrap.min.css" rel="stylesheet">
<link href="css/bootstrap-reset.css" rel="stylesheet">
<link href="font-awesome/css/font-awesome.css" rel="stylesheet" />
<link href="css/style.css" rel="stylesheet">
<link href="css/style-responsive.css" rel="stylesheet" />
<!--[if lt IE 9]>
<script src="js/ie8-responsive-file-warning.js"></script><![endif]-->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
</head>
<body class="login-body">
<div class="container">
<form class="form-signin" method="POST">
<h2 class="form-signin-heading">sign in now</h2>
<div class="login-wrap">
<div class="user-login-info">
<input type="text" name="email" class="form-control" placeholder="User Name" autofocus required>
<input type="password" name="password" class="form-control" placeholder="Password" required>
</div>
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
<span class="pull-right">
<a data-toggle="modal" href="#myModal"> Forgot Password?</a>
</span>
</label>
<input type="submit" name="login" value="Sign In" class="btn btn-lg btn-login btn-block">
<div class="registration">
Don't have an account yet?
<a class="" href="registration.php">Create an account</a>
</div>
</div>
</form>
<?php
if(isset($_POST['login'])) {
if(isset($_POST['email']) && isset($_POST['password']) &&
is_string($_POST['email']) && is_string($_POST['password']) &&
!empty($_POST['email']) && !empty($_POST['password'])) {
$email = stripslashes(strip_tags($_POST['email']));
$password = md5($_POST['password']);
$stmt = $pdo->prepare('SELECT * FROM users WHERE UserEmail = :UserEmail');
$stmt->bindParam(':UserEmail', $email);
$stmt->execute();
if($stmt->rowCount() > 0) {
$stmt = $pdo->prepare('SELECT * FROM users WHERE UserEmail = :UserEmail AND UserPassword = :UserPassword');
$stmt->execute(array(':UserEmail' => $email, ':UserPassword' => $password));
if($stmt->rowCount() > 0) {
$row = $stmt->fetch();
$UserLevel = $row['UserLevel'];
if($UserLevel == 'banned') {
$display->ReturnError('Your account has been suspended.');
return false;
}
$UserID = $row['UserID'];
$time = time();
$IPAddress = $_SERVER['REMOTE_ADDR'];
$_SESSION['auth'] = $UserID;
$stmt = $pdo->prepare('INSERT INTO logs (LogUserID, LogDate, LogIPAddress) VALUES (:LogUserID, :LogDate, :LogIPAddress)');
$stmt->execute(array(':LogUserID' => $UserID, ':LogDate' => $time, ':LogIPAddress' => $IPAddress));
$display->ReturnSuccess('You was successfully logged in.');
$settings->forceRedirect('index.php', 2);
} else {
$display->ReturnError('Invalid user credentials.');
}
} else {
$display->ReturnError('User with these credentials does not exists.');
}
}
}
?>
</div>
<script src="js/jquery.js"></script>
<script src="bs3/js/bootstrap.min.js"></script>
<script src="js/sm-requests.js"></script>
<div aria-hidden="true" aria-labelledby="myModalLabel" role="dialog" tabindex="-1" id="myModal" class="modal fade">
<form method="POST">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Forgot Password ?</h4>
</div>
<div class="modal-body">
<p>Enter your user name below.</p>
<input type="text" id="username" name="username" placeholder="User Name" class="form-control placeholder-no-fix" autocomplete="off" required>
</div>
<div class="modal-body">
<p>Enter your e-mail address below.</p>
<input type="email" id="email" name="email" placeholder="Email" class="form-control placeholder-no-fix" autocomplete="off" required>
</div>
<div class="modal-footer">
<button data-dismiss="modal" class="btn btn-default" type="button">Cancel</button>
<button id="reset" class="btn btn-success" type="button">Reset</button>
<hr>
<div id="result"></div>
</div>
</div>
</div>
</form>
</div>
</body>
</html>
New Page:
<?php
require_once('./files/functions.php');
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>log in</title>
<!-- Vendors -->
<!-- Animate CSS -->
<link href="vendors/bower_components/animate.css/animate.min.css" rel="stylesheet">
<!-- Material Design Icons -->
<link href="vendors/bower_components/material-design-iconic-font/dist/css/material-design-iconic-font.min.css" rel="stylesheet">
<!-- Site CSS -->
<link href="css/app-1.min.css" rel="stylesheet">
</head>
<body>
<div class="login">
<form action="" >
<!-- Login -->
<div class="login__block toggled" id="l-login">
<div class="login__block__header">
<i class="zmdi zmdi-account-circle"></i>
Hi there! Please Sign in
<div class="actions login__block__actions">
<div class="dropdown">
<i class="zmdi zmdi-more-vert"></i>
<ul class="dropdown-menu pull-right">
<li><a data-block="#l-register" href="#">Create an account</a></li>
<li><a data-block="#l-forget-password" href="#">Forgot password?</a></li>
</ul>
</div>
</div>
</div>
<div class="login__block__body">
<form action="" >
<div class="form-group form-group--float form-group--centered form-group--centered">
<input type="text" class="form-control" name="email">
<label>Email Address</label>
<i class="form-group__bar"></i>
</div>
<div class="form-group form-group--float form-group--centered form-group--centered">
<input type="password" class="form-control" name="password">
<label>Password</label>
<i class="form-group__bar"></i>
</div>
<button name="login" class="btn btn--light btn--icon m-t-15"><i class="zmdi zmdi-long-arrow-right"></i></button>
</form>
</div>
<?php
if(isset($_POST['login'])) {
if(isset($_POST['email']) && isset($_POST['password']) &&
is_string($_POST['email']) && is_string($_POST['password']) &&
!empty($_POST['email']) && !empty($_POST['password'])) {
$email = stripslashes(strip_tags($_POST['email']));
$password = md5($_POST['password']);
$stmt = $pdo->prepare('SELECT * FROM users WHERE UserEmail = :UserEmail');
$stmt->bindParam(':UserEmail', $email);
$stmt->execute();
if($stmt->rowCount() > 0) {
$stmt = $pdo->prepare('SELECT * FROM users WHERE UserEmail = :UserEmail AND UserPassword = :UserPassword');
$stmt->execute(array(':UserEmail' => $email, ':UserPassword' => $password));
if($stmt->rowCount() > 0) {
$row = $stmt->fetch();
$UserLevel = $row['UserLevel'];
if($UserLevel == 'banned') {
$display->ReturnError('Your account has been suspended.');
return false;
}
$UserID = $row['UserID'];
$time = time();
$IPAddress = $_SERVER['REMOTE_ADDR'];
$_SESSION['auth'] = $UserID;
$stmt = $pdo->prepare('INSERT INTO logs (LogUserID, LogDate, LogIPAddress) VALUES (:LogUserID, :LogDate, :LogIPAddress)');
$stmt->execute(array(':LogUserID' => $UserID, ':LogDate' => $time, ':LogIPAddress' => $IPAddress));
$display->ReturnSuccess('You was successfully logged in.');
$settings->forceRedirect('index.php', 2);
} else {
$display->ReturnError('Invalid user credentials.');
}
} else {
$display->ReturnError('User with these credentials does not exists.');
}
}
}
?>
</form>
</div>
<!-- Register -->
<div class="login__block" id="l-register">
<div class="login__block__header palette-Blue bg">
<i class="zmdi zmdi-account-circle"></i>
Create an account
<div class="actions login__block__actions">
<div class="dropdown">
<i class="zmdi zmdi-more-vert"></i>
<ul class="dropdown-menu pull-right">
<li><a data-block="#l-login" href="#">Already have an account?</a></li>
<li><a data-block="#l-forget-password" href="#">Forgot password?</a></li>
</ul>
</div>
</div>
</div>
<div class="login__block__body">
<div class="form-group form-group--float form-group--centered">
<input type="text" class="form-control">
<label>Name</label>
<i class="form-group__bar"></i>
</div>
<div class="form-group form-group--float form-group--centered">
<input type="text" class="form-control">
<label>Email Address</label>
<i class="form-group__bar"></i>
</div>
<div class="form-group form-group--float form-group--centered">
<input type="password" class="form-control">
<label>Password</label>
<i class="form-group__bar"></i>
</div>
<div class="input-centered">
<div class="checkbox">
<label>
<input type="checkbox" value="">
<i class="input-helper"></i>
Accept the license agreement
</label>
</div>
</div>
<button class="btn btn--light btn--icon m-t-15"><i class="zmdi zmdi-plus"></i></button>
</div>
</div>
<!-- Forgot Password -->
<div class="login__block" id="l-forget-password">
<div class="login__block__header palette-Purple bg">
<i class="zmdi zmdi-account-circle"></i>
Forgot Password?
<div class="actions login__block__actions">
<div class="dropdown">
<i class="zmdi zmdi-more-vert"></i>
<ul class="dropdown-menu pull-right">
<li><a data-block="#l-login" href="#">Already have an account?</a></li>
<li><a data-block="#l-register" href="#">Create an account</a></li>
</ul>
</div>
</div>
</div>
<div class="login__block__body">
<p class="m-t-30">Lorem ipsum dolor fringilla enim feugiat commodo sed ac lacus.</p>
<div class="form-group form-group--float form-group--centered">
<input type="text" class="form-control">
<label>Email Address</label>
<i class="form-group__bar"></i>
</div>
<button class="btn btn--light btn--icon m-t-15"><i class="zmdi zmdi-check"></i></button>
</div>
</div>
</div>
<!-- Older IE Warning -->
<!--[if lt IE 9]>
<div class="ie-warning">
<h1>Warning!!</h1>
<p>You are using an outdated version of Internet Explorer, please upgrade <br/>to any of the following web browsers to access this website.</p>
<div class="ie-warning__container">
<ul class="ie-warning__download">
<li>
<a href="http://www.google.com/chrome/">
<img src="img/browsers/chrome.png" alt="">
<div>Chrome</div>
</a>
</li>
<li>
<a href="https://www.mozilla.org/en-US/firefox/new/">
<img src="img/browsers/firefox.png" alt="">
<div>Firefox</div>
</a>
</li>
<li>
<a href="http://www.opera.com">
<img src="img/browsers/opera.png" alt="">
<div>Opera</div>
</a>
</li>
<li>
<a href="https://www.apple.com/safari/">
<img src="img/browsers/safari.png" alt="">
<div>Safari</div>
</a>
</li>
<li>
<a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie">
<img src="img/browsers/ie.png" alt="">
<div>IE (New)</div>
</a>
</li>
</ul>
</div>
<p>Sorry for the inconvenience!</p>
</div>
<![endif]-->
<!-- Javascript Libraries -->
<!-- jQuery -->
<script src="vendors/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap -->
<script src="vendors/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Placeholder for IE9 -->
<!--[if IE 9 ]>
<script src="vendors/bower_components/jquery-placeholder/jquery.placeholder.min.js"></script>
<![endif]-->
<!-- Site Functions & Actions -->
<script src="js/app.min.js"></script>
</body>
</html>
your using <form> tags without no action attribute (takes the url link which will handle the form) and method attributes(set this to POST, that is method="POST"). look through your code and correct this.
Each time you use and input field and what to get the data which the user inputted, enclosed it inside a form tags like this:
<form action="form processor url here" method="POST">
<!--input fields here or fields that you want the to submit data-->
<input type=text name=username >
<button name=login value=login >
</form>

PHP not saving data to database in affiliate script

I am new to php, i have an affiliate script, in the add campaign page when i fill the form and submit the form it says "Campaign Added" but the form data was not saved in database,
My Add Campaign Form
<?php
session_start();
if(isset($_SESSION['myadminusername']))
{
$myusername = $_SESSION['myadminusername'];
include '../config.php';
header( 'Content-Type: text/html; charset=utf-8' );
}
else
{
echo"<script type='text/javascript'>
window.location.href='login.php';
</script>";
}
if( isset($_POST['text']) )
{
mysql_query("Insert into link values ('', '".addslashes($_POST['text'])."', '".addslashes($_POST['caption'])."', '".addslashes($_POST['description'])."', '".$_POST['img']."', '".$_POST['site_us_pc']."', '".$_POST['site_oth_pc']."', '".$_POST['site_us_mob']."', '".$_POST['site_oth_mob']."', '".$_POST['status']."', '".$_POST['catname']."', '".$_POST['us_cpc']."', '".$_POST['uk_cpc']."', '".$_POST['au_cpc']."', '".$_POST['in_cpc']."', '".$_POST['oth_cpc']."', '".$_POST['pak_cpc']."', '".$_POST['star']."', '0')");
echo"<script type='text/javascript'>
alert('Campaign Added');
</script>";
}
?>
<!doctype html>
<!--[if lte IE 9]> <html class="lte-ie9" lang="en"> <![endif]-->
<!--[if gt IE 9]><!--> <html lang="en"> <!--<![endif]-->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="initial-scale=1.0,maximum-scale=1.0,user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Remove Tap Highlight on Windows Phone IE -->
<meta name="msapplication-tap-highlight" content="no"/>
<link rel="icon" type="image/png" href="assets/img/favicon-16x16.png" sizes="16x16">
<link rel="icon" type="image/png" href="assets/img/favicon-32x32.png" sizes="32x32">
<title>Altair Admin v2.0.0</title>
<!-- uikit -->
<link rel="stylesheet" href="bower_components/uikit/css/uikit.almost-flat.min.css" media="all">
<!-- flag icons -->
<link rel="stylesheet" href="assets/icons/flags/flags.min.css" media="all">
<!-- altair admin -->
<link rel="stylesheet" href="assets/css/main.min.css" media="all">
<!-- matchMedia polyfill for testing media queries in JS -->
<!--[if lte IE 9]>
<script type="text/javascript" src="bower_components/matchMedia/matchMedia.js"></script>
<script type="text/javascript" src="bower_components/matchMedia/matchMedia.addListener.js"></script>
<![endif]-->
</head>
<?php include 'head.php'; ?>
<div id="page_content">
<div id="page_content_inner">
<h3 class="heading_b uk-margin-bottom">Blank Page</h3>
<div class="md-card">
<div class="md-card-content">
<div class="uk-grid" data-uk-grid-margin>
<div class="uk-width-1-1">
<form method="post" action="campaign_add.php">
<div class="form-group">
<label>Campaign Title</label>
<input class="md-input" name="text" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Suggested Caption</label>
<input class="md-input" name="caption" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign Image Link</label>
<input class="md-input" name="img" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign Description</label>
<input class="md-input" name="description" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign US PC Link</label>
<input class="md-input" name="site_us_pc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign Other PC Link</label>
<input class="md-input" name="site_oth_pc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign US Mob Link</label>
<input class="md-input" name="site_us_mob" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign Other Mob link</label>
<input class="md-input" name="site_oth_mob" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Campaign Status</label>
<select name="status">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
</div>
<br>
<br>
<div class="form-group">
<label>Campaign Category</label>
<select name="catname">
<?php
$results = mysql_query("Select * from link_cat");
while ($row = mysql_fetch_array($results))
{
echo'<option value="'.$row['id'].'">'.$row['catname'].'</option>';
}
?>
</select>
</div>
<br>
<br>
<div class="form-group">
<label>US Pay per click (INR)</label>
<input class="md-input" name="us_cpc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>UK Pay per click (INR)</label>
<input class="md-input" name="uk_cpc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Australia Pay per click (INR)</label>
<input class="md-input" name="au_cpc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>India Pay per click (INR)</label>
<input class="md-input" name="in+cpc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Pakistan Pay per click (INR)</label>
<input class="md-input" name="pak_cpc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Other Pay per click (INR)</label>
<input class="md-input" name="oth_cpc" type="text">
</div>
<br>
<br>
<div class="form-group">
<label>Star</label>
<select name="star">
<option value="false">No</option>
<option value="true">Yes</option>
</select>
</div>
<br>
<br>
<div class="form-group">
<input class="md-btn md-btn-primary" value="Add" type="submit">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- google web fonts -->
<script>
WebFontConfig = {
google: {
families: [
'Source+Code+Pro:400,700:latin',
'Roboto:400,300,500,700,400italic:latin'
]
}
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
</script>
<!-- common functions -->
<script src="assets/js/common.min.js"></script>
<!-- uikit functions -->
<script src="assets/js/uikit_custom.min.js"></script>
<!-- altair common functions/helpers -->
<script src="assets/js/altair_admin_common.min.js"></script>
<script>
$(function() {
// enable hires images
altair_helpers.retina_images();
// fastClick (touch devices)
if(Modernizr.touch) {
FastClick.attach(document.body);
}
});
</script>
<div id="style_switcher">
<div id="style_switcher_toggle"><i class="material-icons"></i></div>
<div class="uk-margin-medium-bottom">
<h4 class="heading_c uk-margin-bottom">Colors</h4>
<ul class="switcher_app_themes" id="theme_switcher">
<li class="app_style_default active_theme" data-app-theme="">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_a" data-app-theme="app_theme_a">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_b" data-app-theme="app_theme_b">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_c" data-app-theme="app_theme_c">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_d" data-app-theme="app_theme_d">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_e" data-app-theme="app_theme_e">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_f" data-app-theme="app_theme_f">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
<li class="switcher_theme_g" data-app-theme="app_theme_g">
<span class="app_color_main"></span>
<span class="app_color_accent"></span>
</li>
</ul>
</div>
<div class="uk-visible-large">
<h4 class="heading_c">Sidebar</h4>
<p>
<input type="checkbox" name="style_sidebar_mini" id="style_sidebar_mini" data-md-icheck />
<label for="style_sidebar_mini" class="inline-label">Mini Sidebar</label>
</p>
</div>
</div>
<script>
$(function() {
var $switcher = $('#style_switcher'),
$switcher_toggle = $('#style_switcher_toggle'),
$theme_switcher = $('#theme_switcher'),
$mini_sidebar_toggle = $('#style_sidebar_mini');
$switcher_toggle.click(function(e) {
e.preventDefault();
$switcher.toggleClass('switcher_active');
});
$theme_switcher.children('li').click(function(e) {
e.preventDefault();
var $this = $(this),
this_theme = $this.attr('data-app-theme');
$theme_switcher.children('li').removeClass('active_theme');
$(this).addClass('active_theme');
$('body')
.removeClass('app_theme_a app_theme_b app_theme_c app_theme_d app_theme_e app_theme_f app_theme_g')
.addClass(this_theme);
if(this_theme == '') {
localStorage.removeItem('altair_theme');
} else {
localStorage.setItem("altair_theme", this_theme);
}
});
// change input's state to checked if mini sidebar is active
if((localStorage.getItem("altair_sidebar_mini") !== null && localStorage.getItem("altair_sidebar_mini") == '1') || $('body').hasClass('sidebar_mini')) {
$mini_sidebar_toggle.iCheck('check');
}
// toggle mini sidebar
$mini_sidebar_toggle
.on('ifChecked', function(event){
$switcher.removeClass('switcher_active');
localStorage.setItem("altair_sidebar_mini", '1');
location.reload(true);
})
.on('ifUnchecked', function(event){
$switcher.removeClass('switcher_active');
localStorage.removeItem('altair_sidebar_mini');
location.reload(true);
});
// hide style switcher
$document.on('click keyup', function(e) {
if( $switcher.hasClass('switcher_active') ) {
if (
( !$(e.target).closest($switcher).length )
|| ( e.keyCode == 27 )
) {
$switcher.removeClass('switcher_active');
}
}
});
if(localStorage.getItem("altair_theme") !== null) {
$theme_switcher.children('li[data-app-theme='+localStorage.getItem("altair_theme")+']').click();
}
});
</script></body>
</html>
Database Table Column List screen short
You have to change:
<input class="md-input" name="in+cpc" type="text">
to:
<input class="md-input" name="in_cpc" type="text">
and to check the return value:
if(isset($_POST['text']))
{
$returnValue = mysql_query("Insert into link
values ('',
'".addslashes($_POST['text'])."',
'".addslashes($_POST['caption'])."',
'".addslashes($_POST['description'])."',
'".$_POST['img']."',
'".$_POST['site_us_pc']."',
'".$_POST['site_oth_pc']."',
'".$_POST['site_us_mob']."',
'".$_POST['site_oth_mob']."',
'".$_POST['status']."',
'".$_POST['catname']."',
'".$_POST['us_cpc']."',
'".$_POST['uk_cpc']."',
'".$_POST['au_cpc']."',
'".$_POST['in_cpc']."',
'".$_POST['oth_cpc']."',
'".$_POST['pak_cpc']."',
'".$_POST['star']."',
'0')");
if ($returnValue === FALSE) $message = 'Failure: '.mysql_error();
else $message = 'Campaign Added';
echo"<script type='text/javascript'>
alert('$message');
</script>";
}
I cannot garantee I found all errors. You might find my layout a bit strange, but I can read this much better.
NOTE: The mysql extension of PHP is depricated, and never insert user input directly in a query.

Categories